Scripts
ufcscraper.scripts.scrape_ufcstats_data module
This script is designed to scrape UFC Stats fighter, events, fight and round data, organizing it into structured CSV files.
Usage:
To run the script, use the following command:
ufcscraper_scrape_ufcstats_data --data-folder /path/to/data --log-level INFO --n-sessions 5 --delay 2
Arguments:
log-level: Set the logging level (e.g., INFO, DEBUG).
data-folder: Specify the folder where scraped data will be stored.
n-sessions: Number of concurrent scraping sessions (default: 1).
delay: Delay in seconds between requests (default: 0).
- ufcscraper.scripts.scrape_ufcstats_data.get_args() Namespace[source]
Parse command-line arguments and return them as an argparse.Namespace object.
This function sets up the command-line argument parser and defines the arguments that can be passed to the script. It returns the parsed arguments as an argparse.Namespace object.
- Returns:
- The parsed command-line arguments, with attributes for each argument.
log_level (str): The logging level (default: “INFO”).
data_folder (Path): The folder where scraped data will be stored.
n_sessions (int): The number of concurrent sessions (default: 1).
delay (int): The delay between requests in seconds (default: 0).
- Return type:
argparse.Namespace
- ufcscraper.scripts.scrape_ufcstats_data.main(args: argparse.Namespace | None = None) None[source]
This function sets up logging, parses command-line arguments (if not provided), initializes a UFCScraper instance, performs scraping of fighters, events, and fights, and removes duplicates from the CSV files.
- Parameters:
args – Command-line arguments. If None, arguments are parsed using get_args.
ufcscraper.scripts.scrape_bestfightodds_data module
This script is designed to scrape BestFightOdds betting odds, organizing the data into structured CSV files.
Usage:
To run the script, use the following command:
ufcscraper_scrape_bestfightodds_data --data-folder /path/to/data --log-level INFO --n-sessions 5 --delay 2 --min-date 2010-01-01
Arguments:
log-level: Set the logging level (e.g., INFO, DEBUG).
data-folder: Specify the folder where scraped data will be stored.
n-sessions: Number of concurrent scraping sessions (default: 1).
delay: Delay in seconds between requests (default: 0).
min-date: Minimum date for data scraping (default: 2007-08-01).
- ufcscraper.scripts.scrape_bestfightodds_data.get_args() Namespace[source]
Parse command-line arguments and return them as an argparse.Namespace object.
This function sets up the command-line argument parser and defines the arguments that can be passed to the script. It returns the parsed arguments as an argparse.Namespace object.
- Returns:
- The parsed command-line arguments, with attributes for each argument.
log_level (str): The logging level (default: “INFO”).
data_folder (Path): The folder where scraped data will be stored.
n_sessions (int): The number of concurrent sessions (default: 1).
delay (int): The delay between requests in seconds (default: 0).
min_date (str): The minimum date for data scraping in “YYYY-MM-DD” format (default: “2007-08-01”).
- Return type:
argparse.Namespace
- ufcscraper.scripts.scrape_bestfightodds_data.main(args: argparse.Namespace | None = None) None[source]
This function sets up logging, parses command-line arguments (if not provided), initializes a BestFightOddsScraper instance, performs scraping of odds, filling the fighter_names table if needed and removes duplicates from the CSV files.
- Parameters:
args (Optional[argparse.Namespace]) – An optional argparse.Namespace object containing command-line arguments. If not provided, get_args() is called to parse the arguments.