Retrieving parent's next sibling? #188
-
I'm new to scrape, I can't seem to find how to retrieve text from parent's next sibling. So for example I have this HTML
So I'm trying to reach |
Beta Was this translation helpful? Give feedback.
Answered by
christian-draeger
Aug 9, 2022
Replies: 1 comment
-
hey, <p style="margin-bottom: 5px">
<strong>Producer</strong>
:
</p>
<p>
Foo, Bar
</p> you can do as follows to get the first sibling of the strongs parent element: val firstSiblingOfStrongParent = htmlDocument(someHtmlSnippet) {
strong {
findFirst {
parent {
siblings[0]
}
}
}
}
println(firstSiblingOfStrongParent.text) // will print: Foo, Bar with that |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
christian-draeger
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hey,
assuming you have a html snippet like this:
you can do as follows to get the first sibling of the strongs parent element:
with that