Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
84 views
in Technique[技术] by (71.8m points)

Android JSoup Example

I was just wondering has anyone got a sample eclipse project with a working implementation of JSoup? Im trying to use it to pull information from websites and have gone all over google trying to get it to work but cant. If anyone could help I'd really appreciate it.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

JSoup is really easy to use, look at these exemples from the JSoup cookbook:here

First, You have to connect to the webpage you want to parse using:

Document doc = Jsoup.connect("http://example.com/").get();

Then, you can select page elements using the JSoup selector syntax.

For instance, say you want to select all the content of the div tags with the id attribute set to test, you just have to use:

Elements divs = doc.select("div#test");

to retrieve the divs, then you can iterate on them using:

for (Element div : divs)
    System.out.println(div.text());
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...