A package for scraping MLB odds data from OddsPortal
Project description
MLB Odds Scraper
A Python package for scraping MLB odds data from OddsPortal. This package provides tools to easily retrieve and analyze betting odds for MLB games.
Installation
pip install mlb_odds_scraper
Features
- Scrape historical MLB betting odds from OddsPortal
- Support for concurrent page scraping
- Clean and structured data output with team ID mapping
- Timezone handling (converts game times to UTC)
- Filters out All-Star games automatically
- Adaptive selectors to handle website structure changes
- Enhanced stealth mode to avoid detection
Requirements
- Python >= 3.8
- Chrome/Chromium browser installed
Dependencies
- pandas >= 1.0.0
- selenium >= 4.0.0
- stealthenium >= 0.1.0
- MLB-StatsAPI >= 1.0.0
Usage
from mlb_odds_scraper import scrape_oddsportal_mlb, scrape_oddsportal_mlb_years, process_game_data
# Scrape a single year
games = scrape_oddsportal_mlb(2024) # Scrapes all pages for 2024
games = scrape_oddsportal_mlb(2024, max_pages=5) # Scrape first 5 pages only
# Scrape multiple years
df = scrape_oddsportal_mlb_years(2020, 2024) # Scrapes 2020-2023
df = scrape_oddsportal_mlb_years() # Scrapes 2006-2024 (default)
# Process the scraped data
processed_df = process_game_data(df)
# Returns DataFrame with:
# - Parsed dates and times (UTC)
# - Team IDs from MLB-StatsAPI
# - Cleaned odds and scores
# - Removed All-Star games
Changelog
v0.1.2
- Added multiple selectors to handle website structure changes
- Improved error handling and robustness
- Enhanced stealth mode to avoid detection
- Added better date and time parsing
- Fixed issues with future year scraping
v0.1.1
- Initial release
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
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 mlb_odds_scraper-0.1.20.tar.gz.
File metadata
- Download URL: mlb_odds_scraper-0.1.20.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
767aae33cdb6d1f5e59181bb6f3bd0be870f221ed6d9abb106abfbcc7bc1527f
|
|
| MD5 |
1f47eca309f860cd9eb4110df90ce64f
|
|
| BLAKE2b-256 |
ea5992047815ca3c4593489b1dcd46b4a38afcf38abcd37d0d7b96317bebfcc5
|
File details
Details for the file mlb_odds_scraper-0.1.20-py3-none-any.whl.
File metadata
- Download URL: mlb_odds_scraper-0.1.20-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce5c66c0650fc3029c1cb89960798322b7b4e155329b126b587dd0d1eddff2f8
|
|
| MD5 |
436018dd1354e77f76047855362abb55
|
|
| BLAKE2b-256 |
ac6f1f0e34a68f210467059f90b15d030f801fa967b9b3b7da7dd0ab7bd4c06c
|