-1

Is it possible to get the codes of “elements” which is shown to me when I press F12 by using JAVA?

I recently need to get a specific information from the element code from thousands of webpage with the same coding format.

  • As far as I understood, you need a web scraping utility in Java. See here: https://stackoverflow.com/questions/3202305/web-scraping-with-java – omalyutin Jul 13 '20 at 07:18

1 Answers1

0

You can do it using Selenium:

    WebClient webClient = new WebClient();
    webClient.getOptions().setCssEnabled(false);
    webClient.setCssErrorHandler(new SilentCssErrorHandler());
    String url = "https://www.google.com";
    HtmlPage page = webClient.getPage(url);
    System.out.println(page.asXml());

    webClient.close();

Include Dependency:

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>htmlunit-driver</artifactId>
    <version>2.40.0</version>
</dependency>

Include any other dependency if required.

ProGamer
  • 420
  • 5
  • 16