UndetectedChromedriver icon indicating copy to clipboard operation
UndetectedChromedriver copied to clipboard

Proxy with auth

Open NiotGG opened this issue 1 year ago • 3 comments

I am trying use proxy with auth

`String proxyAddress = "brd.superproxy.io"; int proxyPort = 22225; String proxyUsername = "PROXY_USER"; String proxyPassword = "PROXY_PASS";

    String proxyUrl = "https://" + proxyUsername + ":" + proxyPassword + "@" + proxyAddress + ":" + proxyPort;

    options.addArguments("--proxy-server=" + proxyUrl);

    Proxy proxy = new Proxy();
    proxy.setHttpProxy(proxyUrl);
    proxy.setSslProxy(proxyUrl);
    options.setCapability(CapabilityType.PROXY, proxy);`

But the ip simply remains the same

NiotGG avatar Oct 03 '23 14:10 NiotGG

you could use this:

String proxyUrl = "https://" + proxyUsername + ":" + proxyPassword + "@" + proxyAddress + ":" + proxyPort;

ChromeOptions chrome_options = new ChromeOptions();

chrome_options.addArguments("--proxy-server="+ proxyUrl);

ChromeDriver chromeDriver = new ChromeDriverBuilder()
        .build(chrome_options,driver_home);

mabinogi233 avatar Oct 04 '23 04:10 mabinogi233

I did as you said, but I still have the same problem, something interesting is that if I remove the password and username from the proxy it works, but it requests the username and password within the browser

you could use this:

String proxyUrl = "https://" + proxyUsername + ":" + proxyPassword + "@" + proxyAddress + ":" + proxyPort;

ChromeOptions chrome_options = new ChromeOptions();

chrome_options.addArguments("--proxy-server="+ proxyUrl);

ChromeDriver chromeDriver = new ChromeDriverBuilder()
        .build(chrome_options,driver_home);

NiotGG avatar Oct 04 '23 07:10 NiotGG

Oh, if you use proxy has username and password, this will not work because proxy in chrome will use some js script to use it (I think), and this ChromeDriver is open a chrome process and give control to the program, so it will not generate this script.

To make it work, you could set proxy on your OS.

mabinogi233 avatar Oct 05 '23 05:10 mabinogi233