【问题标题】:Requests SSLError: HTTPSConnectionPool(host='www.recruit.com.hk', port=443): Max retries exceeded with url请求 SSLError: HTTPSConnectionPool(host='www.recruit.com.hk', port=443): url 超出最大重试次数
【发布时间】:2017-12-21 00:40:58
【问题描述】:

我对此感到非常困惑。

这是我正在使用的。

  • 请求 2.18.4
  • python 2.7.14

我正在构建一个爬虫并尝试使用requests.get() 连接到一个网址。

这是一个从确实跳转到另一个链接的链接。 代码如下:

r = rqs.get('https://www.indeed.hk/rc/clk?jk=ab794b2879313f04&fccid=a659206a7e1afa15')

这是引发的错误:

File "/Users/cecilialee/anaconda/envs/py2/lib/python2.7/site-packages/requests/adapters.py", line 506, in send
    raise SSLError(e, request=request)
SSLError: HTTPSConnectionPool(host='www.recruit.com.hk', port=443): Max retries exceeded with url: /jobseeker/JobDetail.aspx?jobOrder=L04146652 (Caused by SSLError(SSLEOFError(8, u'EOF occurred in violation of protocol (_ssl.c:661)'),))

设置verify = False 并不能解决这个错误。

我在网上搜索过,但找不到可以帮助解决我的问题的解决方案。有人可以帮忙吗?

【问题讨论】:

    标签: python python-2.7 ssl web-scraping python-requests


    【解决方案1】:

    您可以使用 HTTP(但不是 https)从站点获取信息。

    >>> response = requests.get('http://www.recruit.com.hk')
    >>> response.status_code
    200
    >>> len(response.text)
    

    我试过你的代码,没问题:

    >>> r = requests.get('https://www.indeed.hk/rc/clk?jk=ab794b2879313f04&fccid=a659206a7e1afa15')
    >>> r.status_code
    200
    >>> len(r.text)
    34272
    

    我的环境:

    python 2.7.10 请求==2.5.0

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-31
      • 1970-01-01
      • 2014-08-20
      • 1970-01-01
      • 1970-01-01
      • 2020-11-18
      • 2022-10-31
      • 1970-01-01
      相关资源
      最近更新 更多