Pyppeteer minimal example

This script is a minimal example on how to use Pyppeteer to fetch a web page and extract the page title (the content of the .logo_default HTML element)

#!/usr/bin/env python3
import asyncio
from pyppeteer import launch

async def main():
    browser = await launch()
    page = await browser.newPage()
    await page.goto('')
    # Get the URL and print it
    title = await page.evaluate("() => document.querySelector('.logo-default').textContent")
    print(f"Page title: {title}") # prints Page title: TechOverflow
    # Cleanup
    await browser.close()


How to run:

sudo pip3 install pyppeteer