Browser / app.py
Onyxl's picture
Create app.py
f42927e verified
raw
history blame contribute delete
976 Bytes
import asyncio
from playwright.async_api import async_playwright
# Your list of 100+ sites
SITES = [
"https://example.com",
"https://example.com",
# ... add up to 100+ URLs here ...
]
async def browse_sites():
async with async_playwright() as p:
# Launch browser in headless mode
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) # 15 sec timeout
title = await page.title()
print(f"Successfully loaded: {title}")
# Perform your scraping/interaction here
except Exception as e:
print(f"Failed to load {url}: {e}")
await browser.close()
if __name__ == "__main__":
asyncio.run(browse_sites())