本文最后更新于 2024-07-26T20:49:51+08:00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| import urllib.request url='http://www.baidu.com/s?wd=ip' headers={ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36' } req=urllib.request.Request(url=url,headers=headers)
proxies={ 'http':'125.77.25.177:8090' } handler=urllib.request.ProxyHandler(proxies=proxies)
opener=urllib.request.build_opener(handler) res=opener.open(req)
content=res.read().decode('utf-8') with open('daili.html','w',encoding='utf-8')as f: f.write(content)
|
urllib_代理的基本使用
https://ianwusb.blog/2024/07/26/urllib_代理的基本使用/