File size: 976 Bytes
f42927e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 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())
|