'Change chrome proxy during runtime
Using the launch options from puppeteer sharp I can launch a Chrome browser with proxy options. Is there also a way to change the proxy during runtime for this browser without restarting the instance? I cannot use a Cef based browser which would make this a lot easier as I have to be able to login to google services. After a lot of searching I couldn't find an example. The code I have so far:
public static Browser _browser;
private static readonly LaunchOptions puppeteer_launchOptions = new LaunchOptions
{
Headless = false,
IgnoreHTTPSErrors = true,
Args = new[] {
"--no-sandbox",
"--disable-infobars",
"--disable-setuid-sandbox",
"--ignore-certificate-errors",
$"--proxy-server='1.2.3.4:5678'"
},};
private async void Button_Click_2(object sender, RoutedEventArgs e)
{
await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);
_browser = await Puppeteer.LaunchAsync(puppeteer_launchOptions);
PuppeteerSharp.Page _page = await _browser.NewPageAsync();
await _page.SetViewportAsync((new ViewPortOptions { Width = 1920, Height = 938 }));
_page.DefaultNavigationTimeout = 100000;
await _page.GoToAsync("https://www.whatismyip.com/");
await _page.WaitForTimeoutAsync(2000);
Console.WriteLine("My Public IP is:");
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
