Advertisement
dereksir

Untitled

Mar 19th, 2024 (edited)
605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. public class Main {
  2.     public static void main(String[] args) {
  3.         //...
  4.  
  5.         // create Chrome Web Client instance using specified proxy settings.
  6.         try (final WebClient webClient = new WebClient(BrowserVersion.CHROME, PROXY_HOST, PROXY_PORT))  {
  7.  
  8.             // navigate to target web page
  9.             Page page = webClient.getPage("https://httpbin.io/ip");
  10.  
  11.             // extract the content as string
  12.             String pageContent = page.getWebResponse().getContentAsString();
  13.  
  14.             // print the content
  15.             System.out.println(pageContent);
  16.         } catch (Exception e) {
  17.             e.printStackTrace();
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement