Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using OpenQA.Selenium;
- using OpenQA.Selenium.Chrome;
- using System;
- class Program
- {
- static void Main()
- {
- var proxies = new List<string>
- {
- "http://211.193.1.11:80",
- "http://138.68.60.8:8080",
- "http://209.13.186.20:80"
- // Add more proxy configurations as needed
- };
- // Select a random proxy configuration
- var random = new Random();
- int randomIndex = random.Next(proxies.Count);
- string randomProxy = proxies[randomIndex];
- // Create a new ChromeOptions instance
- ChromeOptions options = new ChromeOptions();
- // Assign proxy to chrome instance using AddArgument
- options.AddArgument($"--proxy-server={randomProxy}");
- options.AddArgument("headless");
- // Set up the ChromeDriver instance
- IWebDriver driver = new ChromeDriver(options);
- // Navigate to target website
- driver.Navigate().GoToUrl("http://ident.me");
- // Add a wait for three seconds
- Thread.Sleep(3000);
- // Select the HTML body
- IWebElement pageElement = driver.FindElement(By.TagName("body"));
- // Get and print the text content of the page
- string pageContent = pageElement.Text;
- Console.WriteLine(pageContent);
- // Close the browser
- driver.Quit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement