Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //..
- static async Task<Browser> LaunchBrowserWithRandomProxy(List<string> proxies)
- {
- // Select a random proxy from the list
- var random = new Random();
- int randomIndex = random.Next(proxies.Count);
- string randomProxy = proxies[randomIndex];
- // Launch PuppeteerSharp with the selected proxy
- var browserFetcher = new BrowserFetcher();
- await browserFetcher.DownloadAsync();
- var browser = await Puppeteer.LaunchAsync(new LaunchOptions
- {
- Headless = true,
- Args = new[] { $"--proxy-server={randomProxy}" }
- });
- return (Browser)browser;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement