Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example;
- // import the required classes
- import com.gargoylesoftware.htmlunit.WebClient;
- import com.gargoylesoftware.htmlunit.BrowserVersion;
- import com.gargoylesoftware.htmlunit.Page;
- public class Main {
- public static void main(String[] args) {
- // create Chrome Web Client instance
- try (final WebClient webClient = new WebClient(BrowserVersion.CHROME)) {
- // navigate to target web page
- Page page = webClient.getPage("https://httpbin.io/ip");
- // extract the content as string
- String pageContent = page.getWebResponse().getContentAsString();
- // print the content
- System.out.println(pageContent);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement