python爬虫中解决被网站禁止访问的方法
*代理服务器,ProxyHeader实现IP代理
代理的数据格式为字典
key : http/https
value 代理IP地址+端口号
httpbin.org可以方便查看http请求的一些参数
方法:/ip,/get
使用代码代理
from urllib import request
url='httpbin.org/ip'
handler=request.ProxyHandler({http:"<你要获得的代理ip>"})
opener=request.build_opener(handler)
resp=opener.open(url)
*