-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunner.py
43 lines (35 loc) · 1.06 KB
/
runner.py
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
35
36
37
38
39
40
41
42
43
from write import combine_data, write_to_csv
import asyncio
from plus_ev import calc_evs
from devtools import debug
from urls import url_db, scraping_functions
import sys
filepath = "/mnt/c/Users/bucks/OneDrive/Documents/coding/Python/betting2"
async def main(sport: str = None):
print("running scrape")
if not sport:
sport = "UFC"
urls = url_db[sport]
results = {}
async with asyncio.TaskGroup() as tg:
for key in urls.keys():
results[key] = tg.create_task(scraping_functions[key](urls[key]))
results = {key: result.result() for key, result in results.items()}
big_dict = combine_data(sport, **results)
calc_evs(big_dict)
write_to_csv(big_dict, filepath + f"/{sport}.xlsx")
print("completed scrape")
async def run_scraper():
async with asyncio.TaskGroup() as tg:
if len(sys.argv) > 1:
for sport in sys.argv[1:]:
tg.create_task(main(sport))
else:
tg.create_task(main())
if __name__ == "__main__":
asyncio.run(run_scraper())
"""
Sports:
NFL
UFC
"""