Created
February 10, 2024 10:56
-
-
Save korakot/3dc9547c4eabf00249e51ae87326c77d to your computer and use it in GitHub Desktop.
Using playwright in Google Colab
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
!pip install playwright | |
!playwright install | |
# colab need this for async | |
import nest_asyncio | |
nest_asyncio.apply() | |
# start browser, not to use 'with' context | |
from playwright.async_api import async_playwright | |
playwright = await async_playwright().start() | |
browser = await playwright.chromium.launch() | |
# go to a page, print its source | |
page = await browser.new_page() | |
await page.goto("https://playwright.dev/") | |
print(await page.content()) | |
# end session | |
await browser.close() | |
await playwright.stop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you @korakot!