我使用的代码是:
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中设置这样的代理?我找到了这个示例,但不是很有帮助。当我运行脚本时,没有任何React(Chrome浏览器没有启动)。
7条答案
按热度按时间k4aesqcs1#
lyr7nygr2#
对我很有效...
des4xlb03#
I had an issue with the same thing. ChromeOptions is very weird because it's not integrated with the desiredcapabilities like you would think. I forget the exact details, but basically ChromeOptions will reset to default certain values based on whether you did or did not pass a desired capabilities dict.
I did the following monkey-patch that allows me to specify my own dict without worrying about the complications of ChromeOptions
change the following code in /selenium/webdriver/chrome/webdriver.py:
all that changed was the "skip_capabilities_update" kwarg. Now I just do this to set my own dict:
fhg3lkii4#
这很简单!
首先,定义代理url
然后,创建Chrome功能设置并向其添加代理
最后,创建webdriver并传递所需的功能
整体看起来像这样
x6h2sr285#
这对我来说就像一个魅力:
ifsvaxew6#
对于那些询问如何在需要身份验证的chrome中设置代理服务器的人,应该按照以下步骤操作。
1.在proxy.py项目中创建www.example.com文件,使用此code并从
proxy.py ,您需要传递代理服务器、端口和用户名密码等参数进行身份验证。
esyap4oy7#