在不关闭webdriver python selenium的情况下切换代理

2024-03-28 12:55:45 发布

您现在位置:Python中文网/ 问答频道 /正文

有没有一种方法可以在不关闭浏览器的情况下,通过重新加载来更改Selenium Chrome web驱动程序的代理ip地址?在

我知道你可以通过运行这个来添加一个代理,但是你怎么能改变它呢?公司名称:

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)

Tags: 方法ipweb代理port地址selenium驱动程序