Python SSL 错误:WRONG_VERSION_NUMBER 几天前有效的代码
Python ERROR SSL: WRONG_VERSION_NUMBER on code that worked few days earlier
使用 google-搜索包 (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): Max retries exceeded with url: /search?q=tim+ferriss&num=11&hl=en (由 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)'))))
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。但是你正在使用的搜索库,我没有看到任何更改协议的选项......
我能够重现错误并使用以下技巧修复它。
尝试将下一行代码更改为:
result = search(searching_for,proxy="http")
使用 google-搜索包 (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): Max retries exceeded with url: /search?q=tim+ferriss&num=11&hl=en (由 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)'))))
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。但是你正在使用的搜索库,我没有看到任何更改协议的选项......
我能够重现错误并使用以下技巧修复它。
尝试将下一行代码更改为:
result = search(searching_for,proxy="http")