How can I set socks5 proxy for selenium webdriver? Python How can I set socks5 proxy for selenium webdriver? Python selenium selenium

How can I set socks5 proxy for selenium webdriver? Python


Chrome do not allow proxy with auth. I am not shure but after read so many informations I think so.... Only one way is working for me - to use proxy socks5 without auth by login and password.

 options = webdriver.ChromeOptions() proxy = '12.12.421.125:1949'    options.add_argument('--proxy-server=socks5://' + proxy) driver = webdriver.Chrome(options=options)


For FireFox's geckodriver if you just want to set socks5 host / socks5 proxy :-

form selenium import webdriverprofile = webdriver.FirefoxProfile()# Socks5 Host SetUp:-myProxy = "198.199.101.152:8388"ip, port = myProxy.split(':')profile.set_preference('network.proxy.type', 1)profile.set_preference('network.proxy.socks', ip)profile.set_preference('network.proxy.socks_port', int(port))driver = webdriver.Firefox(firefox_profile=profile)


Here is the code I used to connect to a Socks5 server with username/password auth.

from selenium import webdriverfrom webdriver_manager.chrome import ChromeDriverManagerfrom selenium.webdriver.common.desired_capabilities import DesiredCapabilitiescapabilities = dict(DesiredCapabilities.CHROME)capabilities['proxy'] = {    'proxyType': 'MANUAL',    'socksProxy': '<Your_IP>:<Your_Port>',    'socksVersion': 5,    'ftpProxy': '<Your_IP>:<Your_Port>',    'noProxy': 'localhost,127.0.0.1',    'class': "org.openqa.selenium.Proxy",    'autodetect': False}capabilities['proxy']['socksUsername'] = '<username>'capabilities['proxy']['socksPassword'] = '<password>'driver = Chrome(ChromeDriverManager().install(), desired_capabilities=capabilities)