Hi all,
I'm looking to use pyppeteer, but running sample code, I keep getting pyppeteer.errors.BrowserError: Browser closed unexpectedly:
import asyncio
from pyppeteer import launch
async def main():
# launch chromium browser in the background
browser = await launch()
# open a new tab in the browser
page = await browser.newPage()
# add URL to a new page and then open it
await page.goto("https://www.python.org/")
# create a screenshot of the page and save it
await page.screenshot({"path": "/home/greencracker/sandbox/python.png"})
# close the browser
await browser.close()
print("Starting...")
asyncio.get_event_loop().run_until_complete(main())
print("Screenshot has been taken")
result is
Traceback (most recent call last):
File "/home/greencracker/sandbox/sandbox.py", line 22, in <module>
asyncio.get_event_loop().run_until_complete(main())
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/home/greencracker/sandbox/sandbox.py", line 11, in main
browser = await launch()
File "/home/greencracker/.virtualenvs/puppeteer/lib/python3.9/site-packages/pyppeteer/launcher.py", line 307, in launch
return await Launcher(options, **kwargs).launch()
File "/home/greencracker/.virtualenvs/puppeteer/lib/python3.9/site-packages/pyppeteer/launcher.py", line 168, in launch
self.browserWSEndpoint = get_ws_endpoint(self.url)
File "/home/greencracker/.virtualenvs/puppeteer/lib/python3.9/site-packages/pyppeteer/launcher.py", line 227, in get_ws_endpoint
raise BrowserError('Browser closed unexpectedly:\n')
pyppeteer.errors.BrowserError: Browser closed unexpectedly: