Android - 从网站上阅读新闻

时间:2012-06-04 15:58:10

标签: android html jsoup

我正在创建一个Android应用程序,我需要从这个页面阅读最新消息(以及“NYHEDER”标签: http://www.stormthebuildingfest.com/ 然后,当然,在屏幕上打印出来。

我见过不同的地方,也许JSOUP可以帮助解决这个问题 - 但是JSOUP的烹饪书似乎并没有帮助我。

甚至可以从此页面获取新闻吗?怎么样? 或者如果它是JSOUP - 有人可以向我推荐这本书的哪一部分适合这个问题吗? http://jsoup.org/cookbook/

提前致谢。

2 个答案:

答案 0 :(得分:0)

您可以使用函数XML pull解析器 - 为此,必须有XML / RSS。

http://android-developers.blogspot.co.uk/2011/12/watch-out-for-xmlpullparsernexttext.html

关于理论的好文章。

答案 1 :(得分:0)

基本上,你需要做的是:

//This line will get you the whole page
Document doc = Jsoup.connect("http://www.url.com/section.script").get();

//This other line will make sure you get the specific info you're looking for
Elements elems = doc.select("some element");


//Or if you wanna just print it all out, you can simply
System.out.println(doc);

//You can also print just the text (Without ANY tags, or charset issues)
System.out.println(doc.text())

//The .text(); method works for you the variable Elements as
//well. If you got some info, and just want its text, that's
//the best way to go

此外,我还会研究Jsoup selector API。

相关问题