Max retries exceeded with url

  • 寻找可用的ip

寻找可用的ip

import time
from lxml import html  # 把lxml是解析xml语言的库
etree = html.etree
import requestsproxy = []        #空的数组,用来存放IP
def askurl(url):head = {"User-Agent": "Mozilla/5.0"}  #设置请求头r = requests.get(url, time.sleep(1),headers=head)#requests模块,返回json格式数据html = etree.HTML(r.text)  #使用etree将字符串转换成element对象ips = html.xpath("//td[@data-title='IP']//text()")  #使用xpath语句获取到当前页面中的ipports = html.xpath("//td[@data-title='PORT']//text()")#同理获取到portfor ip, port in zip(ips, ports):   #对两个数组进行遍历line = ip+':'+port             #line为IP+端口号proxy_temp = {"http":'http://'+line}  #前面部分声明使用的协议,后面用于拼接proxy.append(proxy_temp)  #将拼接好的IP放到数组里urla =   # 目标网址for pro in proxy:  # 遍历代理池try:res = requests.get(urla, headers=head, proxies=pro)# print(res.text)print(res)print(pro)except Exception as e:  # 这里需要注意的是在python3.7往后必须使用 as e,不然会报错,之前版本使用的是 except Exception, e:print(pro)print(e)continueif __name__ == '__main__':askurl('https://www.kuaidaili.com/free/inha' )

参考:

【python爬虫错误】Max retries exceeded with url相关推荐

  1. python爬虫 关于Max retries exceeded with url 的错误

    爬取安逸花 https://vayh.msxf.com/ 时出现这种错误,总结如下: 1.https连接太多没有关闭导致的433,解决方法: import requests requests.adap ...

  2. python3 错误 Max retries exceeded with url 解决方法

    在爬取时出现这种错误, ConnectionError: HTTPConnectionPool(host='xxx.xx.xxx.xxx', port=xxxx): Max retries excee ...

  3. 爬虫时候遇到python connection error max retries exceeded whith url 怎么解决?

    import requests #关闭多余的连接 s = requests.session() s.keep_alive = False #增加重试连接次数 s.adapters.DEFAULT_RE ...

  4. Max retries exceeded with URL in requests

    爬虫的时候遇到的一个错误 Max retries exceeded with URL in requests requests.exceptions.ConnectionError: HTTPSCon ...

  5. 【爬虫 | Python】解决‘Requests Max Retries Exceeded With Url‘报错的问题

    [爬虫 | Python]解决'Requests Max Retries Exceeded With Url in Python'报错的问题 背景 解决方案 一.普遍方案 细致方案 一.问题重述 1. ...

  6. Python 中错误 ConnectionError: Max retries exceeded with url

    文章目录 使用 Retry 对象进行回退重试 使用 try/except 语句在发生错误时不重试 禁用 SSL 证书验证 使用 time.sleep() 方法实现请求之间的延迟 重复请求直到成功响应 ...

  7. Python Max retries exceeded with url错误

    进行requests库学习的时候,报Max retries exceeded with url错误,网上查询说是,用下面这个解决方法没用,后来关闭了fiddler后发现就可以了,可能fiddler开的 ...

  8. python HTTPConnectionPool(host:XX)Max retries exceeded with url

    python 出现HTTPConnectionPool(host:XX)Max retries exceeded with url问题 在每次数据传输前客户端要和服务器建立TCP连接,为节省传输消耗, ...

  9. 【Bug】python requests发起请求,报“Max retries exceeded with url”

    在本地机器上,高频率重复调用一个API接口,出现"Max retries exceeded with url",拒绝连接的情况. 楼主讲一下,遇到这个bug的过程: 在服务器上开发 ...

最新文章

  1. eclipse编辑窗口不见了(打开左边的java、xml文件,中间不会显示代码)
  2. 【OpenCV3】图像最大轮廓检测——cvFindBiggestContour()封装
  3. c/c++源文件为何要包含自己的头文件?(编译器检查定义和声明的一致性)(编译报错:undefined reference to...)
  4. Python之删除字符串中不需要的字符
  5. 包装类java_Java 包装类
  6. 51nod 1091 重叠的线段(贪心)
  7. Android 查看每个应用的最大可用内存
  8. Docker学习总结(51)——为什么不建议把数据库部署在 Docker 容器内的7大原因?
  9. [英语阅读笔记]Creating Master Detail Pages using GridView
  10. Ninth season eighth episode,Rachel‘s another sister,how is she???
  11. Android APP的沉浸式体验
  12. 做短视频必须要知道的几个视频设置参数,爆款必备。
  13. 李彦宏发布小度在家“解锁”中国家庭市场,被称作AI性价比之王
  14. 字体颜色 * 博客 * 好看
  15. 10---字符个数统计
  16. Communication error with Jack server
  17. 新用户注册之验证码短信、语音解决方案
  18. KioptrixVM3-writeup
  19. 视频教程-wordpress建站教程之环境部署详解课程-PHP
  20. 在前端培训班内该如何学习入门

热门文章

  1. WPF 模拟Windows 7 气象组件
  2. 【OpenCV学习笔记】之图像混合、叠加和对比度、亮度调整
  3. CSS3系列 12 栅格布局
  4. HTML-CSS基础上的小特别总结(1)
  5. python 控制鼠标点击需要100ms为什么_用 Python3 和 OpenCV 替我玩一玩微信小游戏 — 跳一跳 (这算外挂么)...
  6. OCiOS开发:录音与音效
  7. halcon18算子:最小包围矩形smallest_rectangle2()
  8. 一分钟弄清表内和表外业务
  9. 国产ETL工具 etl-engine
  10. 咏月华暮思别沉——寄予我的大学生活