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.
Metadata
Release files for mlb-odds-scraper 0.1.20
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mlb_odds_scraper-0.1.20.tar.gz | 13.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mlb_odds_scraper-0.1.20-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.1 kB
Release files / mlb_odds_scraper-0.1.20.tar.gz
| Download URL | mlb_odds_scraper-0.1.20.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
767aae33cdb6d1f5e59181bb6f3bd0be870f221ed6d9abb106abfbcc7bc1527f
|
|
BLAKE2b-256 checksum How to use checksums |
ea5992047815ca3c4593489b1dcd46b4a38afcf38abcd37d0d7b96317bebfcc5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|
Release files / mlb_odds_scraper-0.1.20-py3-none-any.whl
| Download URL | mlb_odds_scraper-0.1.20-py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce5c66c0650fc3029c1cb89960798322b7b4e155329b126b587dd0d1eddff2f8
|
|
BLAKE2b-256 checksum How to use checksums |
ac6f1f0e34a68f210467059f90b15d030f801fa967b9b3b7da7dd0ab7bd4c06c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|