coach-scraper/app/__main__.py

44 lines
1.0 KiB
Python
Raw Normal View History

import aiohttp
import argparse
import asyncio
from app.chesscom import Scraper as ChesscomScraper
2023-11-30 22:36:44 +00:00
from app.lichess import Scraper as LichessScraper
from app.scraper import Site
async def run():
parser = argparse.ArgumentParser(
prog="coach-scraper",
description="HTML scraping of chess.com coaches.",
)
parser.add_argument("-u", "--user-agent", required=True)
parser.add_argument(
"-s",
"--site",
required=True,
choices=[
Site.CHESSCOM.value,
2023-11-30 22:36:44 +00:00
Site.LICHESS.value,
],
)
args = parser.parse_args()
async with aiohttp.ClientSession(
headers={"User-Agent": f"BoardWise coach-scraper ({args.user_agent})"}
) as session:
if args.site == Site.CHESSCOM.value:
scraper = ChesscomScraper(session)
2023-11-30 22:36:44 +00:00
elif args.site == Site.LICHESS.value:
scraper = LichessScraper(session)
await scraper.scrape()
def main():
asyncio.run(run())
2023-11-28 12:28:21 +00:00
if __name__ == "__main__":
main()