Advertisement
dereksir

Untitled

Nov 6th, 2023
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 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.         // Create a proxy object
  10.         var proxy = new Proxy
  11.         {
  12.             Kind = ProxyKind.Manual,
  13.             IsAutoDetect = false,
  14.             HttpProxy = "http://71.86.129.131:8080"
  15.         };
  16.  
  17.         // Create a ChromeOptions instance and assign it the proxy settings.
  18.         ChromeOptions options = new ChromeOptions();
  19.         options.Proxy = proxy;
  20.  
  21.         // Set up the ChromeDriver instance
  22.         IWebDriver driver = new ChromeDriver();
  23.  
  24.         // Navigate to target website
  25.         driver.Navigate().GoToUrl("https://ident.me");
  26.  
  27.         // Add a wait for three seconds
  28.         Thread.Sleep(3000);
  29.  
  30.         // Select the HTML body
  31.         IWebElement pageElement = driver.FindElement(By.TagName("body"));
  32.  
  33.         // Get and print the text content of the page
  34.         string pageContent = pageElement.Text;
  35.         Console.WriteLine(pageContent);
  36.  
  37.         // Close the browser
  38.         driver.Quit();
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement