build.gradle
to have JSoup as a dependencyInspect
and element with target data.Inspect
<h3>
tagdocument.querySelectorAll
to see what other <h3>
elements exist on the page.<h3>
elements happen to also be course titles..class-title
CSS rule<h3>
elements will be sufficient<h3>
elementsInspect
to find if there’s an easy HTML/CSS selector to
obtain the element containing these totals.table.infobox
table itself.<tr>
elements inside the table.infobox
"Popular vote"
<td>
elements inside the one matching <tr>
.text()
try/catch
statements to deal with any page that might not
be formatted exactly as the first one.Thread
that will download the page
asynchronously, all in parallel, concurrently.Document doc = Jsoup.connect("http://en.wikipedia.org/").get();
log(doc.title());
Elements newsHeadlines = doc.select("#mp-itn b a");
for (Element headline : newsHeadlines) {
log("%s\n\t%s",
headline.attr("title"), headline.absUrl("href"));
}
Add JSoup as a dependency in your build.gradle
file.
dependencies {
compile 'org.jsoup:jsoup:1.11.1'
}