logo
Loading...

出現requests.exceptions.SSLError: HTTPSConnectionPool(host='rate.bot.com.tw', port=443): Max retries exceeded with url: /xrt?Lang=zh-TW (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),))錯誤 - Cupoy

D15解題過程中 發生SSL無法傳送回應這段代碼﹐該如何解決requests.exceptions....

pycrawler

出現requests.exceptions.SSLError: HTTPSConnectionPool(host='rate.bot.com.tw', port=443): Max retries exceeded with url: /xrt?Lang=zh-TW (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),))錯誤

2019/12/13 上午 11:50
Python網路爬蟲討論版
王得宇
觀看數:139
回答數:3
收藏數:1
pycrawler

D15解題過程中 發生SSL無法傳送回應這段代碼﹐該如何解決

requests.exceptions.SSLError: HTTPSConnectionPool(host='rate.bot.com.tw', port=443): Max retries exceeded with url: /xrt?Lang=zh-TW (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),))

回答列表

  • 2019/12/13 下午 00:37
    John
    贊同數:2
    不贊同數:0
    留言數:1

    把resp那行改成

    resp = requests.get(url,verify = False)

    後面多增加一個verify = False 就可以了 !

    那個的意思是忽略對SSL的驗證

    我也有這樣的問題,加上這個就沒問題了

    希望對你有幫助

  • 2019/12/13 下午 05:03
    張維元 (WeiYuan)
    贊同數:0
    不贊同數:0
    留言數:2

    嗨,這個錯誤的原因是比較新的版本中,Python 跟 Request 的安全機制比較嚴格,在請求時會檢查 SSL 驗證。主要有兩種解法:


    1. 把驗證關掉(可以參考嘉恩的做法)

    2. 安裝 SSL 驗證


    ```

    $ sudo pip uninstall -y certifi 

    $ pip install certifi

    ```


    更多細節可以看這邊:https://stackoverflow.com/questions/27835619/urllib-and-ssl-certificate-verify-failed-error).

  • 2019/12/15 下午 05:48
    張維元 (WeiYuan)
    贊同數:0
    不贊同數:0
    留言數:2

    碩涵,試試看安裝這兩個套件:


    ```

    $ pip install pyOpenSSL

    $ pip install -U certifi

    ```


    如果無法安裝的話,可以先更新一下 pip:


    ```

    $ pip install --upgrade pip

    ```