基本上,你需要做的是這樣的:
//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