python - 使用 headless Chrome 通过 Python 为 Selenium 禁用代理

标签 python google-chrome selenium selenium-chromedriver

我在 Python 2.7 中使用 Chrome 和 Selenium。

我曾尝试在 headless 模式下运行 Chrome,但它会显着降低我的测试速度。

一种解决方法是禁用代理设置,但我不知道如何在 python 中执行此操作。

到目前为止,这是我的代码:

from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument('headless')
chrome_options.add_argument('--hide-scrollbars')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('???') # which option?
self.driver = webdriver.Chrome("C:\Python27\Scripts\chromedriver.exe", chrome_options=chrome_options)

有人知道怎么解决吗?

最佳答案

试试这个:

chrome_options.add_argument('--no-proxy-server')

关于python - 使用 headless Chrome 通过 Python 为 Selenium 禁用代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49032878/

相关文章:

python - 如何在 alembic 迁移中禁用 DDL 事务

python - linux crontab 不能运行带图形界面的程序?

javascript - 在 iOS Chrome 中获取连续滚动事件

python - Python 中的 Selenium 启动时禁止安全模式?

linux - 如何使用 VNC(docker standalone ff 和常规 ff)之类的东西访问 linux 上的浏览​​器 GUI)

python - 将从 Urlretrieve 下载的文件保存到另一个文件夹 other

python - Plotly:始终显示悬停文本

python - 如何在Python中仅丢弃html标签并提取关联文本

javascript - chrome 中的非连续选择?

java - Java 跳过 html 表的第一行