Advertisement
dereksir

Untitled

Oct 31st, 2023
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System;
  2. using OpenQA.Selenium;
  3. using OpenQA.Selenium.Chrome;
  4.  
  5. class Scraper
  6. {
  7.     static async Task Main()
  8.     {
  9.         string url = "https://scrapeme.live/shop/Pikachu/";
  10.  
  11.         // Set up Chrome WebDriver
  12.         IWebDriver driver = new ChromeDriver();
  13.  
  14.         // Navigate to the URL
  15.         driver.Navigate().GoToUrl(url);
  16.  
  17.         // Find the stock amount element using XPath
  18.         IWebElement stockElement = driver.FindElement(By.XPath("//*[@id="product-752"]/div[2]/p[2]"));
  19.  
  20.         // Extract the stock amount text
  21.         string stockAmount = stockElement.Text;
  22.         Console.WriteLine("Stock Amount: " + stockAmount);
  23.  
  24.         // Close the WebDriver
  25.         driver.Quit();
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement