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)
Zorg ervoor dat u vervangt 'proxy_ip:port'
met het daadwerkelijke proxy-IP en de poort die u wilt controleren. Dit script stuurt een verzoek naar http://example.com
gebruikt de meegeleverde proxy en controleert of de antwoordstatuscode 200 is. Als de statuscode 200 is, wordt afgedrukt dat de proxy werkt; anders wordt er een foutmelding afgedrukt. Pas de URL en de time-outwaarde indien nodig aan.
Opmerkingen (0)
Er zijn hier nog geen reacties, jij kunt de eerste zijn!