psf / requests-html

Pythonic HTML Parsing for Humans™

Home Page:http://html.python-requests.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to change the window size of the browser?

Socvest opened this issue · comments

Upon using the the arender method to render the page to load the javascript elements, the window size appears to be 800x600 width and height respectively. But this prevents all the necessary elements in my website to load.

Is there a way to make it bigger? I have tried the javascript method window.resizeTo(w,h) using the script parameter but it does not seem to affect it as upon returning the size of the browser, it remains at 800x600.

commented

pyppeteer is using a defaultView port size of 800x600.
The only way I was able to do it is by passing a parameter in the launch function called in requests_html.py.

In BaseSession class, under browser method, change-

self._browser = await pyppeteer.launch(ignoreHTTPSErrors=not(self.verify), headless=True, args=self.__browser_args)

to

self._browser = await pyppeteer.launch(ignoreHTTPSErrors=not(self.verify), headless=True, defaultViewport=None, args=self.__browser_args)

Maybe somebody can raise a PR and pass this argument to HTMLSession while creating it.