2015-11-22 66 views
0

我想用JSoup解析一个Twitter列表(例如https://twitter.com/spdbt/lists/spd-bundestagsabgeordnete/members)。我的问题是,该网页是动态的,即我只收到页面的前20个结果。有没有什么办法JSoup可以获取整个页面?JSoup:解析Twitter列表

目前,我的代码如下所示:

Document doc = Jsoup.connect(listAdress).get(); 
Elements usernames = doc.select(".username.js-action-profile-name"); 
Elements realNames = doc.select(".fullname.js-action-profile-name"); 
// iterate over usernames and realNames and do something 

提前感谢!

+0

我不认为这是可能的:[更多信息](http://stackoverflow.com/questions/25749309/using-jsoup-to-parse-a-dynamic-page) –

回答

0

终于通过使用Twitter的库解决了这个问题,但感谢你的帮助。

0

一些变通使用Selenium

  • 加载页面完全
  • 得到使用Selenium方法页面的源代码,实现与上述网址这个

    • 启动浏览器。
    • 将此内容传递给JSOUP
    • 解析它。

    逻辑

    WebDriver driver = new FirefoxDriver(); 
    driver.get("https://twitter.com/spdbt/lists/spd-bundestagsabgeordnete/members") 
    //some logic to scroll or you do it manually 
    String pageContent = driver.getPageSource(); 
    Document doc = Jsoup.parse(pageContent); 
    //from here write your logic to get the required values