Search code examples
pythongoogle-app-engine

Taking a Screenshot for a given URL on Google Cloud Platform


I have been trying to take a screenshot of given URL using pyppeteer & FAST in Python. But after many attempts and fixing various errors, I managed to get it installed as an App Engine.

I am using python 3.10 and entry point for my app engine is

gunicorn main:app --timeout 540

But after looking at the logs, every time, the code seems to break at the time of launch of browser. I did try providing executable path, no-sandbox arguments, but the application keeps on failing with Browser terminated with "BrowserError: Browser closed unexpectedly:" error.

For taking screenshot, few other options were also evaluated like html2image, but that seems to require Chrome executable and not chrome driver.

Any help here would be appreciated.


Solution

  • You can't 'install browsers' on GAE Standard (see this & this response)

    It's the same reason why you can't run Selenium in GAE standard.

    You can do this on Cloud Run