velthat
Пользователь
НЕ ПРОВЕРЕН
НЕ ПРОВЕРЕН
- Регистрация
- 13.03.26
- Сообщения
- 3
- Реакции
- 0
- Репутация
- 0
Приветствую!
Хотел бы поделиться с вами скриптом быстрой проверки вашего IP (на прокси, скорость, гео и тп).
Скрипт разработан на python и требует некоторые библиотеки, которые можно установить командой:
Итак, сам скрипт:
Хотел бы поделиться с вами скриптом быстрой проверки вашего IP (на прокси, скорость, гео и тп).
Скрипт разработан на python и требует некоторые библиотеки, которые можно установить командой:
Код:
pip install requests colorama psutil
Итак, сам скрипт:
Код:
import requests
import time
from colorama import Fore, Style
import psutil
import warnings
from urllib3.exceptions import InsecureRequestWarning
warnings.simplefilter('ignore', InsecureRequestWarning)
interfaces = psutil.net_if_stats()
def measure_download_speed(url):
start_time = time.time()
response = requests.get(url, stream=True, verify=False)
total_bytes = 0
for chunk in response.iter_content(chunk_size=1024):
total_bytes += len(chunk)
end_time = time.time()
duration = end_time - start_time
speed_bps = total_bytes * 8 / duration
speed_mbps = speed_bps / (1024 * 1024)
return speed_mbps
def measure_upload_speed(url, data_size_mb=10):
data = b'a' * (data_size_mb * 1024 * 1024)
start_time = time.time()
response = requests.post(url, data=data)
end_time = time.time()
elapsed_time = end_time - start_time
data_bits = len(data) * 8
speed_bps = data_bits / elapsed_time
speed_mbps = speed_bps / (1024 * 1024)
return speed_mbps
def get_public_ip():
try:
response = requests.get('https://api.ipify.org')
response.raise_for_status()
return response.text
except requests.RequestException as e:
return f"Ошибка при получении IP: {e}"
def get_country_by_ip(ip):
url = f"http://ip-api.com/json/{ip}"
response = requests.get(url)
if response.status_code == 200:
data = response.json()
return data['country']
else:
return None
print("")
print(Fore.LIGHTCYAN_EX + Style.BRIGHT + "YOUR IP: " + Style.RESET_ALL+get_public_ip())
print("")
print(Fore.LIGHTGREEN_EX + Style.BRIGHT + "Type: " + Style.RESET_ALL+"IPv4")
print(Fore.LIGHTGREEN_EX + Style.BRIGHT + "Status: " + Style.RESET_ALL+"Public")
print(Fore.LIGHTGREEN_EX + Style.BRIGHT + "Country: " + Style.RESET_ALL+get_country_by_ip(get_public_ip()))
response = requests.get(f'https://ipinfo.io/{get_public_ip()}/json')
data = response.json()
city = data.get('city')
print(Fore.LIGHTGREEN_EX + Style.BRIGHT + "City: " + Style.RESET_ALL+city)
for name, stats in interfaces.items():
if stats.isup:
if "wlan" in name or "wifi" in name.lower():
print(Fore.LIGHTGREEN_EX + Style.BRIGHT + f"Connection Type: {Style.RESET_ALL}Wi-Fi")
elif "eth" in name:
print(Fore.LIGHTGREEN_EX + Style.BRIGHT + f"Connection Type: {Style.RESET_ALL}Ethernet")
elif "wwan" in name.lower() or "cell" in name.lower():
print(Fore.LIGHTGREEN_EX + Style.BRIGHT + f"Connection Type: {Style.RESET_ALL}Mobile")
download_url = 'https://speed.hetzner.de/100MB.bin'
download_speed = measure_download_speed(download_url)
print(Fore.LIGHTGREEN_EX + Style.BRIGHT + f"Download Speed: {Style.RESET_ALL}{download_speed:.2f} Mbits/s")
upload_url = 'https://httpbin.org/post'
upload_speed = measure_upload_speed(upload_url, data_size_mb=10)
print(Fore.LIGHTGREEN_EX + Style.BRIGHT + f"Upload speed: {Style.RESET_ALL}{upload_speed:.2f} Mbits/s")
Профиль пользователя НЕ ПРОВЕРЕН! Будьте внимательны при работе с ним!
Подробнее о снятии "НЕ ПРОВЕРЕН" >>>здесь<<<
Подробнее о снятии "НЕ ПРОВЕРЕН" >>>здесь<<<



