mabinogi233 / UndetectedChromedriver

Custom Selenium Chromedriver for Java can pass almost all selenium check. It's the Java version for undetected-chromedriver
GNU General Public License v3.0
55 stars 11 forks source link

Proxy with auth #3

Open NiotGG opened 9 months ago

NiotGG commented 9 months ago

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

mabinogi233 commented 9 months ago

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 commented 9 months ago

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);
mabinogi233 commented 9 months ago

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.