Advertisement
dereksir

Untitled

Nov 6th, 2023
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. using OpenQA.Selenium;
  2. using OpenQA.Selenium.Chrome;
  3. using System;
  4.  
  5. class Program
  6. {
  7.     static void Main()
  8.     {
  9.         ChromeOptions options = new ChromeOptions();
  10.  
  11.         // Set up the ChromeDriver instance with proxy configuration using AddArgument
  12.         options.AddArgument("--proxy-server=http://71.86.129.131:8080");
  13.        
  14.  
  15.         // Set up the ChromeDriver instance
  16.         IWebDriver driver = new ChromeDriver(options);
  17.  
  18.         // Navigate to target website
  19.         driver.Navigate().GoToUrl("http://ident.me");
  20.  
  21.         // Add a wait for three seconds
  22.         Thread.Sleep(3000);
  23.  
  24.         // Select the HTML body
  25.         IWebElement pageElement = driver.FindElement(By.TagName("body"));
  26.  
  27.         // Get and print the text content of the page
  28.         string pageContent = pageElement.Text;
  29.         Console.WriteLine(pageContent);
  30.  
  31.         // Close the browser
  32.         driver.Quit();
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement