【发布时间】:2015-02-18 14:36:39
【问题描述】:
以下代码在 netbeans 中运行良好,但在 eclipse ADT 中,doc.select("div#tickertape_eng a").size() 返回 0。
try {
Document doc = Jsoup.connect("http://bdnews24.com").get();
if (doc != null) {
Elements links = doc.select("div#tickertape_eng a");
for (Element link : links) {
headlines.add(link.text());
headlinks.add(link.absUrl("href"));
}
} else {
Toast.makeText(getActivity(), "Doc not found",
Toast.LENGTH_LONG).show();
}
} catch (IOException e) {
e.printStackTrace();
}
在 netbeans 中,我可以打印 link.text() 和 link.absUrl("href"),但不能在 eclipse 中。 Eclipse 在 logcat 中打印 doc.title() 很好,但是为什么 doc.select("div#tickertape_eng a") 不起作用?如何让它发挥作用?
【问题讨论】:
-
您希望在
a标签和url内添加文本? -
是的,div id="tickertape_eng"
标签: android eclipse netbeans jsoup adt