diff --git a/requests_html.py b/requests_html.py
index e8429c6..4f7da3b 100644
--- a/requests_html.py
+++ b/requests_html.py
@@ -50,7 +50,7 @@ class BaseParser:
return self._encoding
# Scan meta tags for chaset.
- self._encoding = html_to_unicode(self.default_encoding, self.html)[0]
+ self._encoding = html_to_unicode(self.default_encoding, self.html.encode(DEFAULT_ENCODING))[0]
return self._encoding if self._encoding else self.default_encoding
@@ -241,7 +241,7 @@ class Session(requests.Session):
if not response.encoding:
response.encoding = DEFAULT_ENCODING
- response.html = HTML(url=response.url, html=response.text, default_encoding=response.encoding)
+ response.html = HTML(url=response.url, html=response.content, default_encoding=response.encoding)
return response
diff --git a/tests/test_requests_html.py b/tests/test_requests_html.py
index f519dac..12c7ef6 100644
--- a/tests/test_requests_html.py
+++ b/tests/test_requests_html.py
@@ -59,7 +59,6 @@ def test_xpath():
html = r.html.xpath('/html', first=True)
assert 'no-js' in html.attrs['class']
-
if __name__ == '__main__':
- # test_file_get()
test_css_selector()
+