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

Suggestion: Consistent content of html with CJK #32

Closed
JungWinter opened this Issue Feb 27, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@JungWinter
Copy link
Contributor

JungWinter commented Feb 27, 2018

Details of suggestion

In latest version that not yet released, requests_html.HTML.html works fine. But requests_html.Element.html works weird in CJK. I think cause of this happen is html property with default ASCII encoding in etree.tostring()

Problem

>>> import requests_html
>>> doc = '<div>한글<p>한글CJK</p></div>'
>>> page = requests_html.HTML(html=doc, url='fake_url')
>>> page.html
'<div>한글<p>한글CJK</p></div>'
>>> div = page.find('div', first=True)
>>> div
<Element 'div' >
>>> div.html
'<div>&#54620;&#44544;<p>&#54620;&#44544;CJK</p></div>'
>>> div.text
'한글\n한글CJK'

Expected behaviour

>>> doc = '<div>한글<p>한글CJK</p></div>'
>>> page = requests_html.HTML(html=doc, url='fake_url')
>>> page.html
'<div>한글<p>한글CJK</p></div>'
>>> div = page.find('div', first=True)
>>> div.html
'<div>한글<p>한글CJK</p></div>'

I'll work on it to fix this issue.

@kennethreitz

This comment has been minimized.

Copy link
Owner

kennethreitz commented Feb 27, 2018

v0.3.4 released, which fixes this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment