基本上,你需要做的是这样的:
//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。
您可以获取新闻的RSS或XML提要吗?这会让事情变得更容易。 – dotty
我对此有点新,但是我想从新闻网站获得这个可能吗?因为我愿意尝试,如果是的话。任何提示? – Rad