Added ignoreHTTPErrors parameter

This commit is contained in:
Alessandro Romano
2018-08-09 15:03:15 +02:00
parent c59480bf15
commit b1a7acf33a
+3 -2
View File
@@ -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):