Skip to content

Commit

Permalink
Merge pull request psf#193 from pennyarcade/master
Browse files Browse the repository at this point in the history
Update requests_html.py
  • Loading branch information
kennethreitz committed Sep 18, 2018
2 parents 16c0dbe + 96dbba8 commit 5d7c859
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions requests_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ class HTMLSession(requests.Session):
amongst other things.
"""

def __init__(self, mock_browser=True):
def __init__(self, mock_browser=True, browser_args=['--no-sandbox']):
super(HTMLSession, self).__init__()

# Mock a web browser's user agent.
Expand All @@ -656,6 +656,8 @@ def __init__(self, mock_browser=True):

self.hooks = {'response': self._handle_response}

self.__browser_args = browser_args

@staticmethod
def _handle_response(response, **kwargs) -> HTMLResponse:
"""Requests HTTP Response handler. Attaches .html property to
Expand All @@ -679,7 +681,7 @@ def request(self, *args, **kwargs) -> HTMLResponse:
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(headless=True, args=self.__browser_args))
return self._browser

def close(self):
Expand Down

0 comments on commit 5d7c859

Please sign in to comment.