Created
August 26, 2020 22:20
-
-
Save ramiro/877ef7f55b62e165da8e6d8962410ea7 to your computer and use it in GitHub Desktop.
Ungoogled Chromium + pyppetter
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
brew cask fetch eloston-chromium | |
brew cask install eloston-chromium | |
mkvirtualenv puppet | |
python -m pip install -U pip | |
python -m pip install pyppeteer | |
python -m pip install ipython | |
export PYPPETEER_CHROMIUM_REVISION=`python -c "import pyppeteer; print(pyppeteer.__chromium_revision__)"` | |
# Link the Ungoogled Chromium binary to the place pyppeteer expects it | |
# so it doesn't download an official Chromium one the first time we use it | |
ln -s Applications/Chromium.app ~/Library/Application\ Support/pyppeteer/local-chromium/${PYPPETEER_CHROMIUM_REVISION}/chrome-mac | |
ipython | |
... | |
In [1]: import asyncio | |
...: from pyppeteer import launch | |
...: | |
...: async def main(): | |
...: browser = await launch() | |
...: page = await browser.newPage() | |
...: await page.goto('https://example.com') | |
...: await page.screenshot({'path': 'example.png'}) | |
...: await browser.close() | |
...: | |
...: asyncio.get_event_loop().run_until_complete(main()) | |
In [2]: | |
Do you really want to exit ([y]/n)? | |
ls -l example.png | |
-rw-r--r-- 1 ramiro staff 25792 Aug 26 19:03 example.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment