Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // import the required libraries
- using OpenQA.Selenium;
- using OpenQA.Selenium.Chrome;
- public class Example
- {
- static void Main(string[] args)
- {
- // set ChromeOptions to run in headless mode
- ChromeOptions options = new ChromeOptions();
- options.AddArgument("--headless");
- // set up ChromeDriver
- IWebDriver driver = new ChromeDriver(options);
- // navigate to the target url
- string target_url = "https://scrapeme.live/shop/Pikachu/";
- driver.Navigate().GoToUrl(target_url);
- // find the element containing the product price
- IWebElement priceElement = driver.FindElement(By.CssSelector("#product-752 > div.summary.entry-summary > p.price > span"));
- // extract the text of the product price
- string productPrice = priceElement.Text;
- // print the extracted product price
- Console.WriteLine("Product Price: " + productPrice);
- // close the browser
- driver.Quit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement