Advertisement
dereksir

Untitled

Mar 28th, 2024 (edited)
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. package com.example;
  2.  
  3. // import the required dependencies
  4. import org.openqa.selenium.*;
  5. import org.openqa.selenium.chrome.*;
  6.  
  7. import io.github.bonigarcia.wdm.WebDriverManager;
  8.  
  9. public class Main {
  10.     public static void main(String[] args) {
  11.         // set Chrome options for headless mode
  12.         ChromeOptions options = new ChromeOptions();
  13.         options.addArguments("--headless"); // run in headless mode
  14.        
  15.         WebDriver driver = new ChromeDriver(options);
  16.  
  17.         // navigate to the target website
  18.         driver.get("https://scrapeme.live/shop/Pikachu/");
  19.  
  20.         // retrieve the product's price
  21.         WebElement priceElement = driver.findElement(By.cssSelector("#product-752 > div.summary.entry-summary > p.price > span"));
  22.         String price = priceElement.getText();
  23.         System.out.println("Product Price: " + price);
  24.  
  25.         // close the browser
  26.         driver.quit();
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement