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)
确保更换 'proxy_ip:port'
以及您要检查的实际代理 IP 和端口。此脚本将请求发送到 http://example.com
使用提供的代理并检查响应状态代码是否为 200。如果状态代码为 200,则打印代理正在工作;否则,打印错误消息。根据需要调整 URL 和超时值。
评论 (0)
这里还没有评论,你可以成为第一个评论者!