Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example;
- // import the required dependencies
- import org.openqa.selenium.*;
- import org.openqa.selenium.chrome.*;
- import io.github.bonigarcia.wdm.WebDriverManager;
- public class Main {
- public static void main(String[] args) {
- // set Chrome options for headless mode
- ChromeOptions options = new ChromeOptions();
- options.addArguments("--headless"); // run in headless mode
- WebDriver driver = new ChromeDriver(options);
- // navigate to the target website
- driver.get("https://scrapeme.live/shop/Pikachu/");
- // retrieve the product's price
- WebElement priceElement = driver.findElement(By.cssSelector("#product-752 > div.summary.entry-summary > p.price > span"));
- String price = priceElement.getText();
- System.out.println("Product Price: " + price);
- // close the browser
- driver.quit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement