Spaces:
Sleeping
Sleeping
Download scraper/batch_meta.py from Brainw/UdemyScout: direct link, hf CLI and curl.
- Browser
- Download file 500 Bytes
-
https://huggingface.co/spaces/Brainw/UdemyScout/resolve/main/scraper/batch_meta.py
- Command line
-
hf download hf://spaces/Brainw/UdemyScout/scraper/batch_meta.py
-
curl -L -o batch_meta.py https://huggingface.co/spaces/Brainw/UdemyScout/resolve/main/scraper/batch_meta.py
500 Bytes
| import httpx | |
| import asyncio | |
| from scraper.course_meta import fetch_course_meta, HEADERS | |
| async def fetch_meta_batch(courses, limit=8): | |
| sem = asyncio.Semaphore(limit) | |
| async with httpx.AsyncClient(headers=HEADERS, timeout=10, follow_redirects=True) as client: | |
| async def safe(c): | |
| async with sem: | |
| meta = await fetch_course_meta(client, c["url"]) | |
| return {**c, **meta} | |
| return await asyncio.gather(*[safe(c) for c in courses]) |