Skip to main content

A Python scraper for MaxPreps high school sports data

Project description

MaxPreps Web Scraper

This Python module scrapes high school sports data from MaxPreps.com, enabling efficient extraction of team rankings and game results across states and sports.

Features

  • Retrieve team rankings with strength of schedule, rating, and team links.
  • Scrape team schedules, game outcomes, rankings
  • Includes address/location data for each team.
  • Multi-threaded scraping for speed and efficiency.
  • Cleans and structures game metadata (venue, game type, outcome, etc.).

File Structure

  • scraper.py: Contains the MaxPrepsScraper class

️ Installation

pip install requests beautifulsoup4 pandas tqdm

Functions

get_rankings(state: str, sport: str, year: str, boys: bool = True)

Retrieves state rankings for a given sport and academic year. Parameters:

  • state (str): Two-letter state abbreviation (e.g., 'tx' for Texas)
  • sport (str): Sport name (e.g., 'basketball')
  • year (str): Academic year of the season (e.g., '21-22')
  • boys (bool, optional): Set to True for boys' sports and False for girls'. Defaults to True.

Returns:
pandas.DataFrame containing:

  • School Name
  • State Rank
  • Strength of Schedule (SOS)
  • Team Rating
  • Team URL

get_contests(state: str, sport: str, year: str, boys: bool = True, cities: list = None)

Scrapes all contests (games) for selected schools by state, sport, and year. Parameters:

  • state (str): Two-letter state abbreviation (e.g., 'tx')
  • sport (str): Sport name (e.g., 'basketball')
  • year (str): Academic year of the season (e.g., '21-22')
  • boys (bool, optional): Set to True for boys' sports and False for girls'. Defaults to True.
  • cities (list, optional): A list of cities to filter for, e.g., ['austin', 'el paso'] (if omitted, full state will be scraped)

Returns:
pandas.DataFrame containing game-level contest data, including:

  • Date, opponent, venue, scores
  • Team location details (address, city, state, zipcode)
  • URLs to the MaxPreps pages of both teams

Usage and Example Output

from scraper import MaxPrepsScraper
scraper = MaxPrepsScraper()

# Get Team Rankings
rankings_df = scraper.get_rankings(state = 'de', sport = 'football', year = '23-24')

# Get Contest Data
contests_df = scraper.get_contests(state='tx', sport='basketball', year='21-22', boys=False, cities = ['san antonio'])

#output datframes
rankings_df.head(10)
contests_df.head(10)

Get Rankings Get Contests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

maxpreps_scraper-0.1.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

maxpreps_scraper-0.1.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file maxpreps_scraper-0.1.1.tar.gz.

File metadata

  • Download URL: maxpreps_scraper-0.1.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for maxpreps_scraper-0.1.1.tar.gz
Algorithm Hash digest
SHA256 33d5833858312d15d937da8242d4eb4e50f7451986cbc1994ed99fa07c6a3510
MD5 204e7e75a6e29cf2f303a172ba6a4764
BLAKE2b-256 e78595babb3b9abff62f9dd34df9d10bbf82bb36cb7f08338cebfefcfe44fcff

See more details on using hashes here.

File details

Details for the file maxpreps_scraper-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for maxpreps_scraper-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 973ff13e635cf61a97f231d58a63a7a0a234f4eb69bddc81586e48ba09b78642
MD5 d74d7c47d33139fbfc43044b641c0fc3
BLAKE2b-256 33ca427e0d549f0d6db78ceca65147a5e5fb7a8571a4c3f3a6f7b684abbca93a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page