使用 google-search 包 ( 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 引起('您的代理似乎只使用 HTTP 而不是 HTTPS,請嘗試將您的代理 URL 更改為 HTTP。請參閱: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)'))))
uj5u.com熱心網友回復:
我能夠重現錯誤并使用以下技巧修復它。
嘗試將下一行代碼更改為:
result = search(searching_for,proxy="http")
uj5u.com熱心網友回復:
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。但是您正在使用的搜索庫,我沒有看到任何更改協議的選項。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/412060.html
標籤:
上一篇:連接抓取的資料
下一篇:<span>內沒有類的BS4文本
