标签:import open this UI port rand data www. hand
import random
import urllib.request
ippools=[
"39.104.50.71:8080",
"39.104.50.160:8080",
"39.104.14.202:8080",
"39.104.50.137:8080",
"39.104.50.29:8080"
]
def ip(ippools):
thisip=random.choice(ippools)
print(thisip)
proxy=urllib.request.ProxyHandler({"http": thisip})
opener=urllib.request.build_opener(proxy,urllib.request.HTTPHandler)
urllib.request.install_opener(opener)
for i in range(0,5):
try:
ip(ippools)
url="http://www.baidu.com"
data=urllib.request.urlopen(url).read()
print(len(data.decode()))
except Exception as err:
print(err)
标签:import open this UI port rand data www. hand
原文地址:http://www.cnblogs.com/xiesongyou/p/7881628.html