0
import com.gargoylesoftware.htmlunit.WebClient;

public class Main {
    public static void main(String[] args) throws Exception  {
        WebClient webClient = new WebClient();
        HtmlPage page = webClient.getPage("http://www.google.com");
    }
}

But I received the following error:

Error:(6, 9) java: cannot find symbol
 symbol:   class WebClient
 location: class Main

I tried to search for the error on the web. I got 404.

Mr. Polywhirl
  • 42,981
  • 12
  • 84
  • 132
test_postage
  • 13
  • 1
  • 5

1 Answers1

2

Above mentioned code is working for me

import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;

import java.io.IOException;


public class Demo {

    public static void main(String[] args) throws IOException {

        WebClient webClient = new WebClient();
        HtmlPage page = webClient.getPage("http://www.google.com");
        System.out.println(page.asText());
    }
}

gradle Dependency

  compile group: 'net.sourceforge.htmlunit', name: 'com.springsource.com.gargoylesoftware.htmlunit', version: '2.6.0'