Ben
Ben

Reputation: 1849

Parsing html with changing div id

I'm trying to parse the following HTML in order to get to the link that I marked below by using jsoup:

enter image description here

In order to do so, I did the following:

Document doc = Jsoup.parse( url );
Elements links = doc.select(".list-item-wrapper").select(".list-item")----> HERE IM STUCK

I would have continued by using:

doc.select(".list-item-wrapper").select(".list-item").select(#SEARCH_RESULT_RECORDID_dedupmrg914683993).select()....

But the problem is that _dedupmrg914683993 is changed between every page.

I also tried:

doc.select(".list-item-wrapper").select(".list-item").select(.list-item-primary-content result-item-primary-content layout-row).select()....

But I got 0 results.

How can I parse it so I could get eventually to the link inside <img class="main-img fan-img-1"...>?

Thank you

Upvotes: 1

Views: 78

Answers (1)

pavelbere
pavelbere

Reputation: 972

You can search for string match on any attribute, if your id always start with SEARCH_RESULT_RECORDID string you can look for it using the following syntax

doc.select(".list-item-wrapper").select(".list-item").select('[id^=SEARCH_RESULT_RECORDID]').select()....

I assuming that selectors are using jquery scheme

Upvotes: 1

Related Questions