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('https://www.techoverflow.net') # 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() asyncio.get_event_loop().run_until_complete(main())
How to run:
sudo pip3 install pyppeteer python3 PyppeteerExample.py