Advertisement
dereksir

Untitled

Jun 19th, 2024
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. .thenAccept(htmlContent -> {
  2.  
  3.     //...
  4.  
  5.     // iterate through each product
  6.     for (Element productElement : productElements) {
  7.         // retrieve the product title
  8.         String productTitle = productElement.select("h2").text();
  9.         // retrieve the image URL
  10.         String imageUrl = productElement.select("img[src]").attr("src");
  11.         // retrieve the link
  12.         String link = productElement.select("a[href]").attr("href");
  13.  
  14.         System.out.println("Product Title: " + productTitle + "\nImage URL: " + imageUrl + "\nLink: " + link + "\n");
  15.  
  16.     }
  17.  
  18. })                 
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement