我在 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/