简体   繁体   中英

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

Using google-search package ( https://pypi.org/project/googlesearch-python/ ) to open few google search results straight from cmd. Worked fine few days ago. Now that trying to launch the code I get SSL: WRONG_VERSION_NUMBER Error

Any ideas how to fix? And if ideas what caused the error that would be interesting.

Code:

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)

ERROR raise 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 (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] wrong version number (_ssl.c:997)'))))

I was able to reproduce the error and fix it using the following trick.

try changing the next line of code to this:

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',

It says that you can try using HTTP on the URL. But the search library that you are using, I don't see any options for changing the protocol.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM