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

如何在pythonanywhere.com平台中使用Firefox webdriver?

Pythonanywhere使用Firefox Driver的方法

Pythonanywhere环境默认已经预装了Firefox浏览器与对应的GeckoDriver驱动,无需手动下载配置驱动文件,只需调整Selenium的初始化参数即可使用,对应示例代码如下:

from selenium import webdriver

firefox_options = webdriver.FirefoxOptions()
firefox_options.add_argument("--headless")
# 出现共享内存不足报错时可取消注释下一行
# firefox_options.add_argument("--disable-dev-shm-usage")

browser = webdriver.Firefox(options=firefox_options)

browser.get("https://www.youtube.com/")
print("Done")
browser.quit()

注意事项

  • 请确保运行环境已安装Selenium库,推荐使用4.0及以上版本,可通过pip install selenium命令安装
  • 无需额外配置GeckoDriver路径,系统默认路径会被自动识别
  • 若运行时出现访问超时,检查对应目标网站是否在Pythonanywhere的白名单访问范围内,免费用户仅可访问白名单内站点

内容的提问来源于stack exchange,提问作者Ankit Sharma

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.05 16:36:04