0

I try to parse the source file of a website called dgtle.com In order to get the top news, I coded as :

    Document doc = Jsoup.connect("http://www.dgtle.com").get();
    Elements blocks = doc.getElementsByClass("listcs1");

I got nothing but NullPointerExecption while doing this. But the Div with the class of "listcs1" really exists. This troubles me and I'm wondering whether anybody can help me deal with this.

4

1 回答 1

0

使用 doc.select 而不是 getElementsByClass..

前任。

Elements blocks = doc.select("div.listcs1");

这将获得所有具有“listcs1”类的div

Jsoup 在这里列出了所有的选择组合:http: //jsoup.org/cookbook/extracting-data/selector-syntax

于 2012-05-02T16:25:17.280 回答