import requests
def check_proxy(proxy):
try:
response = requests.get('http://example.com', proxies={'http': proxy, 'https': proxy}, timeout=10)
if response.status_code == 200:
print(f"Proxy {proxy} is working!")
else:
print(f"Proxy {proxy} is not working. Status code: {response.status_code}")
except Exception as e:
print(f"Proxy {proxy} is not working. Exception: {e}")
# Replace 'http://example.com' with the URL you want to use for testing
# Replace 'proxy_ip:port' with the actual proxy IP and port
proxy_to_check = 'proxy_ip:port'
check_proxy(proxy_to_check)
Asendage kindlasti 'proxy_ip:port'
tegeliku puhverserveri IP ja pordiga, mida soovite kontrollida. See skript saadab päringu aadressile http://example.com
kasutades kaasasolevat puhverserverit ja kontrollib, kas vastuse olekukood on 200. Kui olekukood on 200, prindib välja, et puhverserver töötab; muidu prindib veateate. Vajadusel kohandage URL-i ja ajalõpu väärtust.
Kommentaarid (0)
Siin pole veel kommentaare, võite olla esimene!