【爬虫】查看代理IP是否有效

代码格式如下:

# 查询代理ip是否有效
import telnetlib
print('------------------------connect---------------------------')
# 连接Telnet服务器
try:
    tn = telnetlib.Telnet('211.147.226.4',port='8118',timeout=20)
except:
    print('该代理IP  无效')
else:
    print('该代理IP  有效')
 
print('-------------------------end----------------------------')

猜你喜欢

转载自blog.csdn.net/IT_SoftEngineer/article/details/107600612