import randomimport urllib.requestippools=[ "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)
时间: 2024-11-12 05:23:57