Skip to content

Instantly share code, notes, and snippets.

@korakot
Created February 10, 2024 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korakot/3dc9547c4eabf00249e51ae87326c77d to your computer and use it in GitHub Desktop.
Save korakot/3dc9547c4eabf00249e51ae87326c77d to your computer and use it in GitHub Desktop.
Using playwright in Google Colab
!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