我正在使用此代码:
profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", "proxy.server.address")
profile.set_preference("network.proxy.http_port", "port_number")
profile.update_preferences()
driver = webdriver.Firefox(firefox_profile=profile)
在 python webdriver 中为 FF 设置代理。这适用于FF。如何在 Chrome 中设置这样的代理?我找到了 exmaple但不是很有帮助。当我运行脚本时没有任何反应(Chrome 浏览器未启动)。
最佳答案
from selenium import webdriver
PROXY = "23.23.23.23:3128" # IP:PORT or HOST:PORT
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % PROXY)
chrome = webdriver.Chrome(options=chrome_options)
chrome.get("http://whatismyipaddress.com")
关于python - 如何在 python webdriver 中为 chrome 设置代理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11450158/