Onyxl commited on
Commit
f42927e
·
verified ·
1 Parent(s): c9f192c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import asyncio
2
+ from playwright.async_api import async_playwright
3
+
4
+ # Your list of 100+ sites
5
+ SITES = [
6
+ "https://example.com",
7
+ "https://example.com",
8
+ # ... add up to 100+ URLs here ...
9
+ ]
10
+
11
+ async def browse_sites():
12
+ async with async_playwright() as p:
13
+ # Launch browser in headless mode
14
+ browser = await p.chromium.launch(headless=True)
15
+ context = await browser.new_context()
16
+ page = await context.new_page()
17
+
18
+ for url in SITES:
19
+ try:
20
+ print(f"Navigating to: {url}")
21
+ await page.goto(url, timeout=15000) # 15 sec timeout
22
+ title = await page.title()
23
+ print(f"Successfully loaded: {title}")
24
+
25
+ # Perform your scraping/interaction here
26
+
27
+ except Exception as e:
28
+ print(f"Failed to load {url}: {e}")
29
+
30
+ await browser.close()
31
+
32
+ if __name__ == "__main__":
33
+ asyncio.run(browse_sites())