|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- proxies = {
- 'https':'http://'+host_proxies,
- 'http':'http://'+host_proxies
- }
-
-
- headers = {
- 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36',
- 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
- 'Accept-Language':'en-US,en;q=0.5',
- 'Accept-Encoding':'gzip',
- 'DNT':'1',
- 'Connection':'close'
- }
- res =requests.get(url,headers=headers,proxies=proxies)
复制代码
为什么会报错呢
- ProxyError: HTTPConnectionPool(host='192.168.43.27', port=8080): Max retries exceeded with url: http://guba.eastmoney.com/list,600641,f_1.html (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000020C4A35FE80>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。')))
复制代码
proxies要填代理服务器的ip,不填自己的ip,也不填你在网上查的自己的ip。
内网ip在去公网的时候,会被路由器或防火墙nat。请看我上面我画的图?
大规模爬取,那么你要准备代理池的。
|
|