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

Update requests_html.py #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions requests_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def raw_html(self) -> _RawHTML:
if self._html:
return self._html
else:
return etree.tostring(self.element, encoding='unicode').strip().encode(self.encoding)
return etree.tostring(self.element, encoding='unicode', method='html').strip().encode(self.encoding)

@property
def html(self) -> _BaseHTML:
Expand All @@ -105,7 +105,7 @@ def html(self) -> _BaseHTML:
if self._html:
return self.raw_html.decode(self.encoding, errors='replace')
else:
return etree.tostring(self.element, encoding='unicode').strip()
return etree.tostring(self.element, encoding='unicode', method='html').strip()

@html.setter
def html(self, html: str) -> None:
Expand Down Expand Up @@ -229,7 +229,7 @@ def find(self, selector: str = "*", *, containing: _Containing = None, clean: bo
elements = []

for element in elements_copy:
element.raw_html = lxml_html_tostring(cleaner.clean_html(element.lxml))
element.raw_html = lxml_html_tostring(cleaner.clean_html(element.lxml,encoding='utf8'))
elements.append(element)

return _get_first_or_list(elements, first)
Expand Down