-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (26 loc) · 992 Bytes
/
Copy pathmain.py
File metadata and controls
31 lines (26 loc) · 992 Bytes
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
from multiprocessing import Process
from scraper import BusinessScraper, ScraperConfig
import traceback
def run_scraper_task(config):
try:
print(f"🚀 Starting scrape: {config.output_file}")
scraper = BusinessScraper(config)
scraper.run()
print(f"✅ Finished: {config.output_file}")
except Exception as e:
print(f"❌ Error in {config.output_file}: {str(e)}")
traceback.print_exc()
if __name__ == "__main__":
configs = [
ScraperConfig(categories=["real estate"], states=["FL"], output_file="FL.csv"),
ScraperConfig(categories=["consulting"], states=["CA"], output_file="CA.csv"),
ScraperConfig(categories=["tax services"], states=["NY"], output_file="NY.csv"),
]
processes = []
for config in configs:
p = Process(target=run_scraper_task, args=(config,))
p.start()
processes.append(p)
for p in processes:
p.join()
print("🎯 All scrapers finished.")