【问题标题】:Scraping Google Group page with HtmlUnit使用 HtmlUnit 抓取 Google Group 页面
【发布时间】:2012-12-21 04:44:47
【问题描述】:
public static void main(String[] args) throws IOException, InterruptedException
    {
        WebClient webClient = new WebClient();

    WebRequest request = new WebRequest(new URL("https://groups.google.com/forum/?fromgroups#!forum/mobile-social-networking-nepal"));
    HtmlPage page = webClient.getPage(request);
    webClient.waitForBackgroundJavaScript(1000000);
    System.out.println(page.asXml());
    webClient.closeAllWindows();


    }

我已经编写了上面的代码,用于抓取上述 URL 给出的 google 组页面,没有任何运气。我得到的是空的 div 和 span 元素。我已经尝试过使用其他 URL 并且可以正常工作,但是使用 google 群组页面似乎无法正常工作。而且,即使是不受欢迎的输出,也需要很长时间。需要帮助。

【问题讨论】:

  • 如果他们使用富 Web 客户端,我不会感到惊讶,并且页面的初始呈现基本上是空白的,使用 AJAX 调用来填充所有数据。

标签: java ajax web-scraping htmlunit google-groups


【解决方案1】:

如下实例化网络客户端,它对我有用:

WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3_6);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多