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)
Make sure to replace 'proxy_ip:port'
with the actual proxy IP and port you want to check. This script sends a request to http://example.com
using the provided proxy and checks if the response status code is 200. If the status code is 200, it prints that the proxy is working; otherwise, it prints an error message. Adjust the URL and timeout value as needed.
Comments (0)
There are no comments here yet, you can be the first!