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 com.jauntium.*;
- public class Main {
- public static void main(String[] args) {
- // use WebDriver manager to set up ChromeDriver
- WebDriverManager.chromedriver().setup();
- // create Chrome options object
- ChromeOptions options = new ChromeOptions();
- // specify headless mode
- options.addArguments("--headless");
- try {
- // create a new browser window
- Browser browser = new Browser(new ChromeDriver(options));
- // navigate to target URL
- browser.visit("https://scrapeme.live/shop/Pikachu/");
- // extract product price.
- Element priceElement = browser.doc.findFirst("<p class=price>");
- String price = priceElement.getText();
- System.out.println("Product Price: " + price);
- browser.quit();
- }
- // if element isn't found, handle JauntiumException.
- catch(JauntiumException e){
- System.err.println(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement