scrape an angularjs website with java

后端 未结 2 801
梦谈多话
梦谈多话 2021-01-03 16:47

I need to scrape a website with content \'inserted\' by Angular. And it needs to be done with java.

I have tried Selenium Webdriver (as I have used Selenium before

2条回答
  •  太阳男子
    2021-01-03 17:12

    Here is the perfect Solution to scrap any web page with JSoup & WebDriver with java

    ChromeOptions chromeOptions = new ChromeOptions();
    chromeOptions.addArguments("--headless");
    WebDriver driver = new romeDriver(chromeOptions);
    driver.get(bean.getDomainQuery().trim());
    Document doc = Jsoup.parse(driver.getPageSource());
    

    And then use JSoup selectors to read any tag info

提交回复
热议问题