import urllib.requests
def proxy_user():
proxy_list=[#自己去网上搜免费的或者是付费的
{"http":"183.154.55.162:9999"},
{"http":"117.88.177.141:3000"},
{"http":"222.189.191.165:9999"},
{"http":"121.237.148.59:3000"}]
for proxy in proxy_list:
#利用遍历出来的ip创建处理器
proxy_handler = urllib.request.ProxyHandler(proxy)
#创建opener
opener = urllib.request.build_opener(proxy_handler)
try:
opener.open("http://www.baidu.com")
print("haha")
except Exception as e:
print(e)
proxy_user()
python爬虫——设置多个ip代理
最新推荐文章于 2023-09-21 18:16:26 发布