user2923535 user2923535 - 8 months ago 32
HTML Question

Jsoup how to get values from html

So I'm trying to get specific information from this link:

I don't really understand html so this is a bit harder for me.

I'm looking specifically get information from here:

<span class="dark_text">Studios:</span>
<a href="/anime/producer/2/Kyoto_Animation" title="Kyoto Animation">Kyoto Animation</a> </div>

<div class="spaceit">

What I'm trying to do is search for when it says "Studios" and then get the title of the href link (Kyoto Animation).

So for I have managed to get this:

Document doc = Jsoup.connect("").get();

Elements studio ="a[href][title]");
for(Element link : studio){

And it's outputting this:

Pony Canyon
Ponycan USA
Kyoto Animation
Kyoto Animation
Go to the Last Post
Go to the Last Post
Anime You Should Watch Before Their Sequels Air This Fall 2016 Season
Follow @myanimelist on Twitter


It should be"span:contains(Studios) + a[href][title]");

of I assume that span is common element for list header.

So basicly this selector gets all span elements that contains text Studios and then gets 1 level children a elements having attributes href and title

Just in case, given selector will select only one link and in span More universal could be

*:contains(Studio) > a[title]

and that means - take every a element that has title attribute and is direct children of any (*) element that contains test Studio. Contains takes into account all text from descending children as well. For text of specific element :textOwn is used.