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 theMaxPrepsScraperclass
️ Installation
pip install maxpreps_scraper
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 toTruefor boys' sports andFalsefor girls'. Defaults toTrue.
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 toTruefor boys' sports andFalsefor girls'. Defaults toTrue.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
Supported Sports and Limitations
These functions only support the following sports: ['basketball', 'football', 'baseball', 'soccer', 'volleyball', 'lacrosse', 'softball']
⚠️ Note: Soccer data is only available for the following states: ['tx', 'la', 'ms', 'hi', 'ca', 'fl', 'az']
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file maxpreps_scraper-0.1.2.tar.gz.
File metadata
- Download URL: maxpreps_scraper-0.1.2.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cea5674ffa4e877bf2c36f1ab56fceeab2c3dba292f64dc4dff3e98ae0e7e028
|
|
| MD5 |
5a03486c2395ac4fae8b3f9788906288
|
|
| BLAKE2b-256 |
64472538e6dba0a00d16c7e3dbf3f30c23f99ecce36ff6cc86851b76975f0e39
|
File details
Details for the file maxpreps_scraper-0.1.2-py3-none-any.whl.
File metadata
- Download URL: maxpreps_scraper-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9997e5566d1642f408c585f503153275ceec8704b771169fe560e041b3013cf0
|
|
| MD5 |
3136a10029d5382efc2420fe6408fb88
|
|
| BLAKE2b-256 |
0b58cc5c17c88c6524876f0b7191801abe8fa75c9aacc8ddbe2f8f3f5835d496
|