如何在硒镀铬机上使用经过认证的代理? [英] How to use authenticated proxy in selenium chromedriver?
问题描述
我需要通过selenium使用不同的经过验证的(非公共)代理服务器来运行Chrome,以便每次运行。
PROXY_IP =<某个IP地址>
UID =<用户id>
PWD =<密码>
options = webdriver.ChromeOptions()
options.add_argument( - proxy-server =%s:%s @%s%(UID,PWD,PROXY_IP))
driver = webdriver.Chrome(executable_path =。\\driver\\chromedriver.exe,
chrome_options = options)
driver.get(< site网址>)
Chrome会启动并显示错误信息:
此网页不可用
ERR_NO_SUPPORTED_PROXIES
如果我使用一个公共代理,不需要像这样的认证...
PROXY_IP =< public代理IP地址>
options = webdriver.ChromeOptions()
options.add_argument( - proxy-server =%s%PROXY_IP)
driver = webdriver.Chrome可执行文件路径=。\\driver\\chromedriver.exe,
chrome_options = options)
driver.get(< site URL>)
$ c
$ b ...它运行得很好,并在使用代理时显示网站。
我还在用户标识前面尝试了 http://
的变体:
options.add_argument(--proxy-server = http://%s:%s @%s%(UID,PWD,PROXY_IP))
事实上,我搜遍了很多地方,还没有找到解决方案,这让我相信没有任何解决方案可以存在。
我确实发现了这一点,但我无法理解它:
不确定什么 browswermob-proxy
是或应该做什么或者如何在Python中实现和测试。我讨厌堆放创可贴的解决方案,除非他们是绝对必要的。
我最终安装了一个可以设置认证的扩展程序通过 Chrome代理API 提供的代理信息。
这是一篇关于如何操作的文章
After searching for many hours I am starting to think this is impossible.
I need to run Chrome through selenium using different authenticated (not public) proxy's for each run.
PROXY_IP = "<some IP address>"
UID = "<the user id>"
PWD = "<the password">
options = webdriver.ChromeOptions()
options.add_argument("--proxy-server=%s:%s@%s" % (UID,PWD,PROXY_IP))
driver = webdriver.Chrome(executable_path=".\\driver\\chromedriver.exe",
chrome_options=options)
driver.get("<site URL>")
Chrome will fire-up and display the error:
This webpage is not available
ERR_NO_SUPPORTED_PROXIES
If I use a public proxy requiring no authentication like this...
PROXY_IP = "<public proxy IP address>"
options = webdriver.ChromeOptions()
options.add_argument("--proxy-server=%s" % PROXY_IP)
driver = webdriver.Chrome(executable_path=".\\driver\\chromedriver.exe",
chrome_options=options)
driver.get("<site URL>")
...it runs just fine and displays the site while using the proxy.
I also tried a variant with http://
in front of the user ID:
options.add_argument("--proxy-server=http://%s:%s@%s" % (UID,PWD,PROXY_IP))
The fact that I have searched far and wide and haven't found a solution leads me to believe none might exist.
I did find this but I can't make sense out of it:
selenium chromedriver authentication proxy
Not sure what browswermob-proxy
is or is supposed to do or how to implement and test in Python. I hate piling up band-aid solutions unless they are absolutely necessary.
解决方案 I ended up installing an extension, which can set authenticated proxy info via Chrome Proxy API.
Here's a post of how to do it
这篇关于如何在硒镀铬机上使用经过认证的代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!