Support for passing browser options to pyppeteer#555
Open
tverona1 wants to merge 1 commit intopsf:masterfrom
Open
Support for passing browser options to pyppeteer#555tverona1 wants to merge 1 commit intopsf:masterfrom
tverona1 wants to merge 1 commit intopsf:masterfrom
Conversation
|
This is really useful, also faced the same issue when I wanted to pass Would love to see this merged. In my case I decided to monkey patch over the original library: from requests_html import BaseSession, HTMLSession
import asyncio
import pyppeteer
class MyBaseSession(BaseSession):
def __init__(self, *args, **kwargs):
super(MyBaseSession, self).__init__(*args, **kwargs)
@property
async def browser(self):
if not hasattr(self, "_browser"):
# override browser args to pass default chromium location
self._browser = await pyppeteer.launch(executablePath="/usr/bin/chromium", ignoreHTTPSErrors=not(self.verify), headless=True, args=['--no-sandbox'])
return self._browser
# multiple inheritance: due to how super() works
# property "browser" is searched for in HTMLSession then instead of going to BaseSession.browser as normal
# it goes to MyBaseSession where we have it overriden to pass custom pyppeteer args
class MyHTMLSession(HTMLSession, MyBaseSession):
def __init__(self, **kwargs):
super(MyHTMLSession, self).__init__(**kwargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.