mirror of
https://github.com/kennethreitz/requests-html.git
synced 2026-06-05 14:50:20 +00:00
Added ignoreHTTPErrors parameter
This commit is contained in:
+3
-2
@@ -645,7 +645,7 @@ class HTMLSession(requests.Session):
|
||||
amongst other things.
|
||||
"""
|
||||
|
||||
def __init__(self, mock_browser=True):
|
||||
def __init__(self, mock_browser=True, ignoreHTTPSErrors=False):
|
||||
super(HTMLSession, self).__init__()
|
||||
|
||||
# Mock a web browser's user agent.
|
||||
@@ -653,6 +653,7 @@ class HTMLSession(requests.Session):
|
||||
self.headers['User-Agent'] = user_agent()
|
||||
|
||||
self.hooks = {'response': self._handle_response}
|
||||
self.ignoreHTTPSErrors = ignoreHTTPSErrors
|
||||
|
||||
@staticmethod
|
||||
def _handle_response(response, **kwargs) -> HTMLResponse:
|
||||
@@ -677,7 +678,7 @@ class HTMLSession(requests.Session):
|
||||
def browser(self):
|
||||
if not hasattr(self, "_browser"):
|
||||
self.loop = asyncio.get_event_loop()
|
||||
self._browser = self.loop.run_until_complete(pyppeteer.launch(headless=True, args=['--no-sandbox']))
|
||||
self._browser = self.loop.run_until_complete(pyppeteer.launch(ignoreHTTPSErrors=self.ignoreHTTPSErrors, headless=True, args=['--no-sandbox']))
|
||||
return self._browser
|
||||
|
||||
def close(self):
|
||||
|
||||
Reference in New Issue
Block a user