selenium - Undetected chromedriver 如何添加带有用户名/密码的 proxy?

我正在以这种方式添加 chrome 选项,如果我使用 proxy ip 身份验证,它就可以工作。

options = webdriver.ChromeOptions() 
    options.headless = True
    options.add_argument('--proxy-server=92.128.165.143:3399')
    driver = uc.Chrome(options=options)

但是,我有一个 proxy 以这种格式进行身份验证: http://username:password@91.92.128.165.143:3399

如果我像这样添加它

options.add_argument('--proxy-server=http://username:password@91.92.128.165.143:3399')

它不起作用。如何使用用户名/密码添加它?这仅适用于未检测到的 chrome 驱动程序。

回答1

使用以下代码添加带有用户名和密码的 proxy :

from selenium import webdriver

PROXY = "http://username:password@91.92.128.165.143:3399"

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % PROXY)

driver = webdriver.Chrome(chrome_options=chrome_options)

编辑:

我发现这个 https://stackoverflow.com/questions/55582136/how-to-set-proxy-with-authentication-in-selenium-chromedriver-python

相似文章

c# - 提高 scraper 速度

我正在创建一个小程序来刮proxies,它可以正常工作,唯一的缺点是时间太长,我尝试使用并行来缩短时间但是仍然很慢,有什么办法可以加快速度过程?Stopwatchstopwatch=newStopwa...

随机推荐

最新文章