我需要使用socks 5代理运行Selenium Webdriver,该代理具有用户名和密码。
我试图在Selenium中使用内置解决方案,但它不使用我的代理(我在whatsmyip网站上检查它)。
proxy = Proxy()
proxy.proxy_type = ProxyType.MANUAL
proxy.socks_proxy = "socks5://1.2.3.4:59101"
proxy.socks_username = "username"
proxy.socks_password = "password"
proxy.socks_version = 5
desired_capabilities = webdriver.DesiredCapabilities.CHROME.copy()
proxy.add_to_capabilities(desired_capabilities)
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(
executable_path="C:\\Users\\User\\Downloads\\chromedriver-win64\\chromedriver.exe",
options=options,
desired_capabilities=desired_capabilities,
)
已经尝试使用selenium-ware和其他解决方案从chatgpt和谷歌,没有工作改变url到socks 5://用户名:email protected(https://stackoverflow.com/cdn-cgi/l/email-protection):59101也不工作
1条答案
按热度按时间ggazkfy81#
对于带auth的socks5代理,可以使用https://github.com/seleniumbase/SeleniumBase:
pip install seleniumbase
,并在设置变量后使用python
运行以下命令: