如何使用JSoup从网站中提取段落?

时间:2011-12-18 04:24:16

标签: jsoup

我需要从此网址抓取文章正文:

Aggie Headline

我知道这篇文章在div class =“article-body”标签内。如何将其作为字符串提取?

2 个答案:

答案 0 :(得分:0)

试试这段代码

Document doc = Jsoup.connect("http://www.ncataggies.com//ViewArticle.dbml?DB_OEM_ID=24500&ATCLID=205346437").get();
            Elements element = doc.getElementsByClass("article-body");
            String text = element.text();
             System.out.println(text);

答案 1 :(得分:0)

Document doc = Jsoup.connect("http://www.ncataggies.com/ViewArticle.dbml?DB_OEM_ID=24500&ATCLID=205346437").get();
Element element = doc.select("div.article-body").first();
String text = element.text();
System.out.println(text);