1、爬虫知识(0204隐藏)
import urllib.request
import random
url=‘http://www.whatismyip.com.tw’
iplist=[‘115.239.24.140:9999’,‘119.6.144.73:81’,‘183.203.208.166:8118’]
proxy_support=urllib.request.ProxyHandler({‘http’:random.choice(iplist)})
opener=urllib.request.build_opener(proxy_support)
opener.addheaders=[{‘User-Agent’,‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36’}]
urllib.request.install_opener(opener)
response=urllib.request.urlopen(url)
html=response.read().decode(‘utf.8’)
print(html)
来源:CSDN
作者:爱吃爱困爱生活、
链接:https://blog.csdn.net/y_j_6666/article/details/104174059