You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python使用requests_html模块时遇Chromium下载OSError问题求助

解决requests_html调用render时Chromium下载失败的问题

问题描述

使用Python的requests_html模块进行网页动态渲染时,调用render()方法出现Chromium下载失败的问题,代码片段如下:

response = session.get(url)
response.html.render(timeout=20)

触发的错误信息:

OSError: Chromium downloadable not found at https://storage.googleapis.com/chromium-browser-snapshots/Win_x64/1181205/chrome-win.zip: Received

return (<Code>NoSuchKey</Code>)
The specified key does not exist.No such object: chromium-browser-snapshots/Win_x64/1181205/chrome-win.zip

已尝试更换requests_html版本、寻找自定义可执行文件路径的方法,但均未解决。

解决方案

方案1:直接指定本地Chrome/Chromium可执行文件路径

如果本地已安装Chrome或Chromium,直接在render()方法中通过executable_path参数指定其路径即可:

  • Windows示例:
response = session.get(url)
response.html.render(timeout=20, executable_path="C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe")
  • macOS示例:
response = session.get(url)
response.html.render(timeout=20, executable_path="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome")
  • Linux示例:
response = session.get(url)
response.html.render(timeout=20, executable_path="/usr/bin/google-chrome")

方案2:通过环境变量指定Chromium路径

  1. 手动下载对应系统的可用Chromium快照版本,解压后找到可执行文件的完整路径;
  2. 设置系统环境变量CHROMIUM_EXECUTABLE_PATH,值为上述可执行文件路径;
  3. 重启Python运行环境,原代码无需修改,requests_html会自动读取该环境变量并使用指定的浏览器。

方案3:升级requests_html到最新版本

部分旧版本的requests_html绑定的Chromium版本已被官方移除,升级到最新版本会更新默认的Chromium版本号,解决下载路径无效的问题:

pip install --upgrade requests-html

内容的提问来源于stack exchange,提问作者Satya Bharadwaj

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 15:17:37