mirror of
https://github.com/kennethreitz/requests-html.git
synced 2026-06-05 14:50:20 +00:00
better native interface
Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
This commit is contained in:
+1
-1
@@ -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'}
|
||||
|
||||
|
||||
@@ -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
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user