Advertisement
dereksir

Untitled

Mar 28th, 2024 (edited)
990
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. package com.example;
  2.  
  3. // import required library
  4. import com.microsoft.playwright.*;
  5.  
  6. public class Main {
  7.     public static void main(String[] args) {
  8.         // initialize Playwright
  9.         try (Playwright playwright = Playwright.create()) {
  10.             // launch browser
  11.             Browser browser = playwright.webkit().launch();
  12.             // open a new page
  13.             Page page = browser.newPage();
  14.             // navigate to target web page
  15.             page.navigate("https://scrapeme.live/shop/Pikachu/");
  16.  
  17.             // extract product price using selector
  18.             String price = page.innerText("#product-752 > div.summary.entry-summary > p.price > span");
  19.             System.out.println("Product Price: " + price);
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement