How to install SOCKS5 proxy with auth for Chrome in selenium Python?

I am trying to use the SOCKS5 proxy provided by the PIA ( https://www.privateinternetaccess.com ). I created a user / password for SOCKS5 on my website, but I can’t use this information because I don’t know where to put it. I tried using ChromeOptions , but it does not work.

 def create_browser(self, proxy): """ proxy = "xGeneratedUser: GeneratedPass@proxy-nl.privateinternetaccess.com :1080" """ chrome_options = webdriver.ChromeOptions() if proxy: chrome_options.add_argument("--proxy-server=socks5://" + proxy) try: self.browser = webdriver.Chrome('./chromedriver', chrome_options=chrome_options) self.browser.set_window_size(800, 600) except Exception as error: return False 
+6
source share
5 answers

selenium.webdriver.chrome.webdriver

 WebDriver(executable_path='chromedriver', port=0, chrome_options=None, service_args=None, desired_capabilities=None, service_log_path=None) 

Argi:

  • executable_path - path to the executable file. If the default value is used, assumes the executable is in $ PATH
  • port - the port you want to start, if you leave 0, a free port will be found.
  • desired_capabilities : a non-browser dictionary object with only features like proxies or loggingPref.
  • chrome_options : this requires an instance of ChromeOptions

You can follow the table below the URL to write a proxy dictionary object for your desired features. DesiredCapabilities - JSON Proxy Object

0
source

You can try the following alternative: -

  • In your .bashrc proxy kit that will be used by chrome itself: -

     export http_proxy="xGeneratedUser: GeneratedPass@proxy-nl.privateinternetaccess.com :1080" export https_proxy="xGeneratedUser: GeneratedPass@proxy-nl.privateinternetaccess.com :1080" 
  • Otherwise, you can use this tool: - autoplay proxy server

In the windows for the http / https proxy server with or without authentication, run one of the following commands in cmd.exe: -

 set http_proxy=http://your_proxy:your_port set http_proxy=http://username: password@your _proxy:your_port set https_proxy=https://your_proxy:your_port set https_proxy=https://username: password@your _proxy:your_port 
0
source

If someone stumbles upon this ...

I tried to connect to socks5 proxy server with selenium and believe that the problem is that the proxy server requires user / password authentication, and since I used a chrome recorder, it did not work because chrome does not support this.

Try connecting to the socks5 proxy server, which does not require authorization or searching for a driver that supports this - without knowing what / what it might be.

0
source

I'm also at a dead end. I also want to use the authorization proxy in Chrome WebDriver Selen. I tried using httpProxy or PAC in which we cannot use the username and password.

And then I saw socksUsername and socksPassword but it is still useless. Because the error is:

 selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: cannot parse capability: proxy from invalid argument: Specifying 'socksProxy' requires an integer for 'socksVersion' (Driver info: chromedriver=73.0.3683.20 (8e2b610813e167eee3619ac4ce6e42e3ec622017),platform=Mac OS X 10.14.3 x86_64) 

I found that the chrome code says that socksProxy key, but the current selenium does not support socksProxy, see selenium code .

Therefore, I have to choose a different path:

0
source

Yes, try the following:

var client = require ('webdriverio'). remote ({host: 'username: password@127.0.0.1 ' port: 1234, Required features: {browserName: 'chrome'}})

-1
source

Source: https://habr.com/ru/post/1266529/


All Articles