fysh711426 / UndetectedChromeDriver

GNU General Public License v3.0
166 stars 61 forks source link

How to setup a proxy? #9

Open gokanil opened 2 years ago

gokanil commented 2 years ago

I tried the code below but my ip address did not change. How to connect to proxy?

options.AddArguments("--proxy-server=x.x.x.x:8080");

fysh711426 commented 2 years ago

Yes, that's right. I tested proxy and it works fine.

You can refer to some discussions in this issue. https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/587#issuecomment-1096591305

gokanil commented 2 years ago

Okay, This worked thanks. options.AddArgument($"--proxy-server=socks5://{proxy}");

I want to ask something off topic. When I change my location, websites can detect that it is fake. Do you have a solution?

fysh711426 commented 2 years ago

Sorry, I have less experience in this.

I suggest you can go to undetected-chromedriver to see their discussionm, they have a lot of experience and solutions.

This repo is C# implementation of undetected-chromedriver, many solutions is generic.

gokanil commented 2 years ago

I opened an employment for the Location issue. Now I'll tell you something different.

var options = new ChromeOptions(); options.AddExtension("test.crx");

Nothing happens when I try to install an extension. But it works when I use the same code with 'OpenQa.Selenium.Chrome'. Can you look at this?

fysh711426 commented 2 years ago

Try it.

options.AddArgument("--load-extension=test.crx")

In UndetectedChromeDriver, other functions except AddArgument cannot be used, the code will use the Arguments parameter to start the chrome process.

var args = options.Arguments
    .Select(it => it.Trim())
    .Aggregate("", (r, it) => r + " " +
        (it.Contains(" ") ? $"\"{it}\"" : it));
var info = new ProcessStartInfo(options.BinaryLocation, args);
...
var browser = Process.Start(info);
gokanil commented 2 years ago

With 'load-extension' I can only load unpackaged (folder) plugins. So I had to extract my crx file. He's seen my work for now. It would be much better for me if I could install it as a package file. Thank you.

ref: link

fysh711426 commented 2 years ago

Sadly can only do that, or use userDataDir and then install the package manually.

vudonblog commented 2 years ago

I can't load 2 extension folders at once. it only accepts the last extension options.AddArgument("--load-extension=" + pathex1); options.AddArgument("--load-extension=" + pathex2); it only accepts extension pathex2

fysh711426 commented 2 years ago

Use commas to concate.

--load-extension=extension1,extension2