better native interface

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
This commit is contained in:
2018-02-27 12:22:29 -05:00
parent 227580e396
commit 5f5d260785
3 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -151,7 +151,7 @@ You can also use this library without Requests:
>>> from requests_html import HTML
>>> doc = """<a href='https://httpbin.org'>"""
>>> html = HTML(html=doc, url='fakeurl', default_encoding='utf-8')
>>> html = HTML(html=doc)
>>> html.links
{'https://httpbin.org'}
+1 -1
View File
@@ -173,7 +173,7 @@ You can also use this library without Requests:
>>> from requests_html import HTML
>>> doc = """<a href='https://httpbin.org'>"""
>>> html = HTML(html=doc, url='fakeurl', default_encoding='utf-8')
>>> html = HTML(html=doc)
>>> html.links
{'https://httpbin.org'}
+2 -1
View File
@@ -17,6 +17,7 @@ from w3lib.encoding import html_to_unicode
DEFAULT_ENCODING = 'utf-8'
DEFAULT_URL = 'https://example.org/'
useragent = UserAgent()
@@ -204,7 +205,7 @@ class Element(BaseParser):
class HTML(BaseParser):
"""An HTML document, ready for parsing."""
def __init__(self, *, url, html, default_encoding=DEFAULT_ENCODING) -> None:
def __init__(self, *, url=DEFAULT_URL, html, default_encoding=DEFAULT_ENCODING) -> None:
super(HTML, self).__init__(
element=PyQuery(html)('html'),
html=html,