You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<spanclass="h-card"><aclass="u-url mention" href="http://localhost/" rel="nofollow noopener noreferrer" target="_blank">
@
<span>
matched text
</span></a></span>
Some text which is missing.
I'm not sure if this is desired behavior or a bug.
For comparison I tried BeautifulSoup and html2text and both consider the additional text and return it.
>>> import bs4, html2text, requests_html
>>> html ="<span class=\"h-card\"><a class=\"u-url mention\" href=\"http://localhost/\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">@<span>matched text</span></a></span> Some text which is missing."
>>> print(bs4.BeautifulSoup(html, features="html.parser").get_text('\n'))
@
matched text
Some text which is missing.
>>> print(html2text.html2text(html))
[@matched text](http://localhost/) Some text which is missing.
>>> print(requests_html.HTML(html=html).text)
@matched text
>>>
P.S.: great to see this package is maintained again! ❤️
The text was updated successfully, but these errors were encountered:
It wouldn't be the first time that I see this, for example the Scala HTML/XML parser implementation used by Spark in Azure has this behavior. Talked to Microsoft about it and it is intended behavior.
Parsing HTML is hard since pretty much almost any string is 'valid' HTML, anyway, without going too deep into the pyquery/lxml implementation I wouldn't be surprised if it was intended.
With some HTML like:
only the text of the
a
tag is matched but not the text beyong (the HTML snippet corresponds to the returnedcontent
field in the Mastodon API, https://docs.joinmastodon.org/methods/statuses/#get).I'm not sure if this is desired behavior or a bug.
For comparison I tried BeautifulSoup and html2text and both consider the additional text and return it.
P.S.: great to see this package is maintained again! ❤️
The text was updated successfully, but these errors were encountered: