python检验代理ip是否可用、代理ip检验
安装相关模块:
pip install requests
验证代理IP是否可用脚本:
import random
import telnetlib
import requests def test_ip(ip,port):
try:
telnetlib.Telnet(ip,port,timeout=2)
print("ip "+ip+":"+port+" yes")
except:
print("ip "+ip+":"+port+" ---") ip_list = [
"222.74.202.227:9999",
"61.135.185.152:80",
"118.25.187.125:8080",
] for ip_str in ip_list:
ip_arr = ip_str.split(":")
test_ip(ip_arr[0], ip_arr[1])
pass