簡體   English   中英

Python 錯誤 SSL: WRONG_VERSION_NUMBER 在幾天前工作的代碼上

[英]Python ERROR SSL: WRONG_VERSION_NUMBER on code that worked few days earlier

使用 google-search package ( https://pypi.org/project/googlesearch-python/ ) 直接從 cmd 打開幾個 google 搜索結果。 前幾天工作正常。 現在嘗試啟動代碼我得到 SSL: WRONG_VERSION_NUMBER 錯誤

任何想法如何解決? 如果想法是什么導致了有趣的錯誤。

代碼:

from googlesearch import search
import webbrowser, sys

searching_for = input(("Input search words: "))

num_results = int(input("How many results : ") or "3")

result = search(searching_for)
for i in result[:num_results]:
    webbrowser.open(i)

錯誤引發 ProxyError(e, request=request) requests.exceptions.ProxyError: HTTPSConnectionPool(host='www.google.com', port=443): url: /search?q=tim+ferriss&num=11&hl= en (Caused by ProxyError('Your proxy appears to only use HTTP and not HTTPS, try changing your proxy URL to be HTTP. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html #https-proxy-error-http-proxy' , SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] 錯誤的版本號 (_ssl.c:997)'))))

我能夠重現錯誤並使用以下技巧修復它。

嘗試將下一行代碼更改為:

result = search(searching_for,proxy="http")

Caused by ProxyError('Your proxy appears to only use HTTP and not HTTPS, try changing your proxy URL to be HTTP. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#https-proxy-error-http-proxy',

它說您可以嘗試在 URL 上使用 HTTP。 但是您正在使用的搜索庫,我沒有看到任何更改協議的選項。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM