| import asyncio |
| from playwright.async_api import async_playwright |
|
|
| |
| SITES = [ |
| "https://example.com", |
| "https://example.com", |
| |
| ] |
|
|
| async def browse_sites(): |
| async with async_playwright() as p: |
| |
| browser = await p.chromium.launch(headless=True) |
| context = await browser.new_context() |
| page = await context.new_page() |
|
|
| for url in SITES: |
| try: |
| print(f"Navigating to: {url}") |
| await page.goto(url, timeout=15000) |
| title = await page.title() |
| print(f"Successfully loaded: {title}") |
| |
| |
| |
| except Exception as e: |
| print(f"Failed to load {url}: {e}") |
|
|
| await browser.close() |
|
|
| if __name__ == "__main__": |
| asyncio.run(browse_sites()) |
|
|