diff --git a/requests_html.py b/requests_html.py index eb27eba..a6c80e8 100644 --- a/requests_html.py +++ b/requests_html.py @@ -416,9 +416,9 @@ class HTML(BaseParser): if isinstance(html, str): html = html.encode(DEFAULT_ENCODING) + pq = PyQuery(html) super(HTML, self).__init__( - # Convert unicode HTML to bytes. - element=PyQuery(html)('html') or PyQuery(f'{html}')('html'), + element=pq('html') or pq.wrapAll('')('html'), html=html, url=url, default_encoding=default_encoding