Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Is it possible to fetch text between two given nodes? #369

Closed
maxiride opened this issue Jan 4, 2021 · 2 comments
Closed

[Question] Is it possible to fetch text between two given nodes? #369

maxiride opened this issue Jan 4, 2021 · 2 comments

Comments

@maxiride
Copy link

maxiride commented Jan 4, 2021

The library has been powerful! However, I am stuck on resolving a little caveat.

Given the below minimal example, how can I retrieve the text "Get me!"?
The given methods like .Text yields all the text in a given node, as shown here the first node <span id="id1000"> might contain a lot of other parts of the document, however I can be certain it will end with the next <h1>.

<span id="id1000">
<h1 class="title">Title</h1>
 Get me!
<br>
<br>
<h1 class="title"></h1>
... truncated
</span>
@mna
Copy link
Member

mna commented Jan 4, 2021

Hello Federico,

You're correct about the Text() method, that's how it works. There's no direct method to do what you want, but you can use the solution mentioned in #287 .

Hope this helps!
Martin

@maxiride
Copy link
Author

maxiride commented Jan 7, 2021

Thanks, it somewhat worked but I am afraid the page I am trying to parse is simply badly written.

@maxiride maxiride closed this as completed Jan 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants