Advertisement
dereksir

Untitled

Mar 19th, 2024 (edited)
579
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. package com.example;
  2.  
  3. // import the required classes
  4. import com.gargoylesoftware.htmlunit.WebClient;
  5. import com.gargoylesoftware.htmlunit.BrowserVersion;
  6. import com.gargoylesoftware.htmlunit.Page;
  7.  
  8. public class Main {
  9.     public static void main(String[] args) {
  10.         // define proxy settings
  11.         String PROXY_HOST = "129.80.134.71";
  12.         int PROXY_PORT = 3128;
  13.  
  14.         // create Chrome Web Client instance using specified proxy settings.
  15.         try (final WebClient webClient = new WebClient(BrowserVersion.CHROME, PROXY_HOST, PROXY_PORT))  {
  16.            
  17.             // navigate to target web page
  18.             Page page = webClient.getPage("https://www.amazon.com/Lumineux-Teeth-Whitening-Strips-Treatments-Enamel-Safe/dp/B082TPDTM2/");
  19.  
  20.             // extract the content as string
  21.             String pageContent = page.getWebResponse().getContentAsString();
  22.  
  23.             // print the content
  24.             System.out.println(pageContent);
  25.         } catch (Exception e) {
  26.             e.printStackTrace();
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement