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)
まだコメントはありません。あなたが最初のコメントを投稿できます!