Getting Final HTML with Javascript rendered Java as String

前端 未结 3 909
借酒劲吻你
借酒劲吻你 2020-12-03 04:04

I want to fetch data from an HTML page(scrape it). But it contains reviews in javascript. In normal java url fetch I am only getting the HTML(actual one) without Javascript

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-03 04:39

    The simple way to solve that problem. Hello, you can use HtmlUnit is java API, i think it can help you to access the executed js content, as a simple html.

    WebClient webClient = new WebClient();
    HtmlPage myPage = (HtmlPage) webClient.getPage(new URL("YourURL"));
    System.out.println(myPage.getVisibleText());
    

提交回复
热议问题