How to run Playwright in Jupyter notebooks?

You can run Playwright in Jupyter notebooks by making use of Playwright's async API. This is required because Jupyter notebooks use an asyncio event loop and you need to use Playwright's async API as well.

Here is some sample code that navigates to ScrapingBee's homepage while making use of the async API:

from playwright.async_api import async_playwright

pw = await async_playwright().start()
browser = await pw.chromium.launch(headless = False)
page = await browser.new_page()

await page.goto("")

Related Playwright web scraping questions: