<div class="username_container">
<div id="yui-gen11" class="popupmenu memberaction">
<a id="yui-gen13" class="username offline popupctrl" href="member.php?u=276113" title="PilotPhill is offline"><strong>**PilotPhill**</strong></a>
<ul id="yui-gen12" class="popupbody memberaction_body">
<li class="left">
I am trying to extract the author names of a forum thread using jsoup. It is the name inside the strong tags. I have tried close to everything and just can't get it.
Any tips? I've been using jSoup.select() but if there are other methods, I'd be happy to try.
You just have to use Document.select
as you already found out.
Document doc = Jsoup.connect("http://www.foo.com").get();
Elements usernames = doc.select("a.username strong");
for (Element username: usernames) {
System.out.println("found username: " + username.text();
}
a.username strong
means: tags strong
inside tag a
with attribute class
having the value username
as in :
<a id="yui-gen13" class="username offline popupctrl"
href="member.php?u=276113" title="PilotPhill is offline">
<strong>**PilotPhill**</strong>
</a>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.