使用requests-html的render方法出错
第一次使用Render方法时,会出现urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘storage.googleapis.com’, port=443): Max retries exceeded with url: /chromium-browser-snapshots/Win/575458/chrome-win32.zip (Caused by SSLError(SSLError(“bad handshake: Error([(‘SSL routines’, ‘tls_process_server_certificate’, ‘certificate verify failed’)])”)))错误提示。
这是因为:调用render 方法启动pyppeteer,pyppeteer需要与浏览器(chromium)进行交互,第一次使用时pyppeteer没有绑定Chromium的话,会从新下载一个Chrome浏览器。
由于其指定的路径被墙,没有科学上网或者SS/SSR之类的,就会出现下载错误从而导致方法中断。
实际上,可以使用系统上原来装有的Chrome,在requests-html源代码
(如C:\Users\XXX\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\requests_html.py)的
第714行:
原句:
self._browser = await pyppeteer.launch(ignor

在使用requests-html的Render方法时遇到MaxRetryError和SSLError,原因是pyppeteer尝试下载Chrome但因网络问题失败。解决办法是手动指定已安装的Chrome路径,避免下载。通过修改requests_html.py文件第714行,添加executablePath设置为Chrome的实际路径,例如'./path/to/Chrome.exe'。参考了多个博客文章进行解决。
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



