28 lines
759 B
Python
28 lines
759 B
Python
"""
|
|
util/scrape.py
|
|
|
|
Utility functions for scaping web data relative to selected games
|
|
"""
|
|
|
|
import httpx
|
|
import pandas as pd
|
|
from bs4 import BeautifulSoup
|
|
|
|
|
|
def scrape_url(game: str, year: int | None) -> pd.DataFrame:
|
|
"""
|
|
Scrape game data from the url provided. This function requires specific environment variables be present
|
|
in order to function properly.
|
|
:param:game The target game to scrape.
|
|
:param:year The year to scrape. If no year is provided, scrapes games from the current year.
|
|
|
|
:return: Pandas DataFrame
|
|
|
|
Examples:
|
|
>>>scrape_url(game='mega-millions')
|
|
pd.DataFrame()
|
|
|
|
>>>scrape_url(game='mega-millions', year=2020)
|
|
pd.DataFrame()
|
|
"""
|