A Python application to scrape and manage odds data from OddsPortal website.
Project description
OddsHarvester
OddsHarvester is an application designed to scrape and process sports betting odds and match data from oddsportal.com website.
๐ Table of Contents
- โจ Features
- ๐ ๏ธ Local Installation
- โก Usage
- ๐ค Contributing
- โ Donations
- ๐ License
- ๐ฌ Feedback
- โ Disclaimer
โจ Features
- ๐ Scrape Upcoming Matches: Fetch odds and event details for upcoming sports matches.
- ๐ Scrape Historical Odds: Retrieve historical odds and match results for analytical purposes.
- ๐ Advanced Parsing: Extract structured data, including match dates, team names, scores, and venue details.
- ๐พ Flexible Storage: Store scraped data in JSON or CSV locally, or upload it directly to a remote S3 bucket.
- ๐ณ Docker Compatibility: Designed to work seamlessly inside Docker containers with minimal setup.
- ๐ต๏ธ Proxy Support: Route web requests through SOCKS/HTTP proxies for enhanced anonymity, geolocation bypass, and anti-blocking measures.
๐ Current Support
OddsHarvester supports a growing number of sports and their associated betting markets. All configurations are managed via dedicated enum and mapping files in the codebase.
โ Supported Sports & Markets
| ๐ Sport | ๐ Supported Markets |
|---|---|
| โฝ Football | 1x2, btts, double_chance, draw_no_bet, over/under, european_handicap, asian_handicap |
| ๐พ Tennis | match_winner, total_sets_over/under, total_games_over/under, asian_handicap, exact_score |
| ๐ Basketball | 1x2, moneyline, asian_handicap, over/under |
| ๐ Rugby League | 1x2, home_away, double_chance, draw_no_bet, over/under, handicap |
| ๐ Rugby Union | 1x2, home_away, double_chance, draw_no_bet, over/under, handicap |
| ๐ Ice Hockey | 1x2, home_away, double_chance, draw_no_bet, btts, over/under |
| โพ Baseball | moneyline, over/under |
| ๐ American Football | 1x2, moneyline, over/under, asian_handicap |
โ๏ธ Note: Each sport and its markets are declared in enums inside
sport_market_constants.py.
๐บ๏ธ Leagues & Competitions
Leagues and tournaments are mapped per sport in:
sport_league_constants.py
You'll find support for:
- ๐ Top Football leagues (Premier League, La Liga, Serie A, etc.)
- ๐พ Major Tennis tournaments (ATP, WTA, Grand Slams, etc.)
- ๐ Global Basketball leagues (NBA, EuroLeague, ACB, etc.)
- ๐ Major Rugby League competitions (NRL, Super League, etc.)
- ๐ Major Rugby Union competitions (Six Nations, Rugby Championship, Top 14, etc.)
- ๐ Major Ice Hockey leagues (NHL, KHL, SHL, Liiga, etc.)
- โพ Major Baseball leagues (MLB, NPB, KBO, etc.)
- ๐ American Football leagues (NFL, NCAA, etc.)
๐ ๏ธ Local Installation
-
Clone the repository: Navigate to your desired folder and clone the repository. Then, move into the project directory:
git clone https://github.com/jordantete/OddsHarvester.git cd OddsHarvester
-
Quick Setup with uv:
Use uv, a lightweight package manager, to simplify the setup process. First, install
uvwithpip, then run the setup:pip install uv uv sync
-
Manual Setup (Optional):
If you prefer to set up manually, follow these steps:
-
Create a virtual environment: Use Python's
venvmodule to create an isolated environment (orvirtualenv) for the project. Activate it depending on your operating system:-
python3 -m venv .venv -
On Unix/MacOS:
source .venv/bin/activate -
On Windows:
.venv\Scripts\activate
-
-
Install dependencies with pip: Use pip with the
--use-pep517flag to install directly from thepyproject.tomlfile:pip install . --use-pep517. -
Or install dependencies with poetry: If you prefer poetry for dependency management:
poetry install
-
-
Verify Installation:
Ensure all dependencies are installed and Playwright is set up by running the following command:
oddsharvester --helpOr using the module directly:
python -m oddsharvester --help
By following these steps, you should have OddsHarvester set up and ready to use.
โก Usage
๐ง CLI Commands
OddsHarvester provides a Command-Line Interface (CLI) to scrape sports betting data from oddsportal.com. Use it to retrieve upcoming match odds, analyze historical data, or store results for further processing.
Quick Reference
# Scrape upcoming matches
oddsharvester upcoming -s football -d 20250301 -m 1x2
# Scrape historical data
oddsharvester historic -s football -l england-premier-league --season 2024-2025 -m 1x2
# Show help
oddsharvester --help
oddsharvester upcoming --help
oddsharvester historic --help
1. Scrape Upcoming Matches
Retrieve odds and event details for upcoming sports matches.
oddsharvester upcoming [OPTIONS]
Options:
| Option | Short | Description | Required | Default |
|---|---|---|---|---|
--sport |
-s |
Sport to scrape (e.g., football, tennis, basketball) |
Yes | None |
--date |
-d |
Date for matches in YYYYMMDD format |
Yes (unless --league or --match-link) |
None |
--league |
-l |
Comma-separated leagues (e.g., england-premier-league) |
No | None |
--market |
-m |
Comma-separated betting markets (e.g., 1x2,btts) |
No | None |
--storage |
Storage type: local or remote |
No | local |
|
--format |
-f |
Output format: json or csv |
No | json |
--output |
-o |
Output file path | No | scraped_data |
--headless |
Run browser in headless mode | No | False |
|
--concurrency |
-c |
Number of concurrent scraping tasks | No | 3 |
--proxy-url |
Proxy URL (e.g., http://proxy:8080 or socks5://proxy:1080) |
No | None | |
--proxy-user |
Proxy username | No | None | |
--proxy-pass |
Proxy password | No | None | |
--user-agent |
Custom browser user agent | No | None | |
--locale |
Browser locale (e.g., fr-BE) |
No | None | |
--timezone |
Browser timezone ID (e.g., Europe/Brussels) |
No | None | |
--match-link |
Specific match URL(s) to scrape (can be repeated) | No | None | |
--target-bookmaker |
Filter for a specific bookmaker | No | None | |
--odds-history |
Scrape historical odds movement | No | False |
|
--odds-format |
Odds display format | No | Decimal Odds |
|
--preview-only |
Only scrape visible submarkets (faster, limited data) | No | False |
|
--bookies-filter |
Bookmaker filter: all, classic, or crypto |
No | all |
|
--period |
Match period to scrape (sport-specific) | No | Sport default |
Important Notes:
- If both
--leagueand--dateare provided, the scraper will only consider the leagues, meaning all upcoming matches for those leagues will be scraped. - If
--match-linkis provided, it overrides--sport,--date, and--league. - All match links must belong to the same sport when using
--match-link. - For best results, ensure the proxy's region matches the
--localeand--timezonesettings.
Example Usage:
# Retrieve upcoming football matches for a specific date
oddsharvester upcoming -s football -m 1x2 -d 20250301 --headless
# Scrape English Premier League matches
oddsharvester upcoming -s football -l england-premier-league -m 1x2,btts --headless
# Scrape multiple leagues at once
oddsharvester upcoming -s football -l england-premier-league,spain-laliga -m 1x2 --headless
# Scrape with a proxy
oddsharvester upcoming -s football -d 20250301 -m 1x2 --proxy-url http://proxy:8080 --proxy-user myuser --proxy-pass mypass --headless
# Scrape in preview mode (faster, average odds only)
oddsharvester upcoming -s football -d 20250301 -m over_under --preview-only --headless
# Scrape specific matches using match links
oddsharvester upcoming -s football --match-link "https://www.oddsportal.com/football/..." --match-link "https://www.oddsportal.com/football/..." -m 1x2
2. Scrape Historical Odds
Retrieve historical odds and results for analytical purposes.
oddsharvester historic [OPTIONS]
Options:
| Option | Short | Description | Required | Default |
|---|---|---|---|---|
--sport |
-s |
Sport to scrape (e.g., football, tennis, basketball) |
Yes | None |
--season |
Season: YYYY, YYYY-YYYY, or current |
Yes | None | |
--league |
-l |
Comma-separated leagues (e.g., england-premier-league) |
No | None |
--market |
-m |
Comma-separated betting markets (e.g., 1x2,btts) |
No | None |
--max-pages |
Maximum number of pages to scrape | No | None | |
--storage |
Storage type: local or remote |
No | local |
|
--format |
-f |
Output format: json or csv |
No | json |
--output |
-o |
Output file path | No | scraped_data |
--headless |
Run browser in headless mode | No | False |
|
--concurrency |
-c |
Number of concurrent scraping tasks | No | 3 |
--proxy-url |
Proxy URL (e.g., http://proxy:8080 or socks5://proxy:1080) |
No | None | |
--proxy-user |
Proxy username | No | None | |
--proxy-pass |
Proxy password | No | None | |
--user-agent |
Custom browser user agent | No | None | |
--locale |
Browser locale (e.g., fr-BE) |
No | None | |
--timezone |
Browser timezone ID (e.g., Europe/Brussels) |
No | None | |
--match-link |
Specific match URL(s) to scrape (can be repeated) | No | None | |
--target-bookmaker |
Filter for a specific bookmaker | No | None | |
--odds-history |
Scrape historical odds movement | No | False |
|
--odds-format |
Odds display format | No | Decimal Odds |
|
--preview-only |
Only scrape visible submarkets (faster, limited data) | No | False |
|
--bookies-filter |
Bookmaker filter: all, classic, or crypto |
No | all |
|
--period |
Match period to scrape (sport-specific) | No | Sport default |
Example Usage:
# Retrieve historical odds for the Premier League 2022-2023 season
oddsharvester historic -s football -l england-premier-league --season 2022-2023 -m 1x2 --headless
# Retrieve historical odds for multiple leagues
oddsharvester historic -s football -l england-premier-league,spain-laliga --season 2022-2023 -m 1x2 --headless
# Retrieve historical odds for the current season
oddsharvester historic -s football -l england-premier-league --season current -m 1x2 --headless
# Retrieve historical MLB 2022 season data
oddsharvester historic -s baseball -l usa-mlb --season 2022 -m moneyline --headless
# Scrape only 3 pages of historical data
oddsharvester historic -s football -l england-premier-league --season 2022-2023 -m 1x2 --max-pages 3 --headless
# Save output to CSV format
oddsharvester historic -s football -l england-premier-league --season 2024-2025 -m 1x2 -f csv -o premier_league_odds --headless
Preview Mode
The --preview-only flag enables a faster scraping mode that extracts only average odds from visible submarkets without loading individual bookmaker details. This mode is useful for:
- Quick exploration of available submarkets and their average odds
- Testing data structure and format
- Light monitoring with reduced resource usage
Preview Mode vs Full Mode:
| Aspect | Full Mode | Preview Mode |
|---|---|---|
| Speed | Slower (interactive) | Faster (passive) |
| Data | All submarkets + bookmakers | Visible submarkets + avg odds |
| Bookmakers | Individual bookmaker odds | Average odds only |
| Odds History | Available | Not available |
| Structure | By bookmaker | By submarket (avg odds) |
๐ Environment Variables
All CLI options can also be configured via environment variables. This is useful for Docker deployments or CI/CD pipelines.
| Environment Variable | CLI Option | Description |
|---|---|---|
OH_SPORT |
--sport |
Sport to scrape |
OH_LEAGUES |
--league |
Comma-separated leagues |
OH_MARKETS |
--market |
Comma-separated markets |
OH_STORAGE |
--storage |
Storage type (local/remote) |
OH_FORMAT |
--format |
Output format (json/csv) |
OH_FILE_PATH |
--output |
Output file path |
OH_HEADLESS |
--headless |
Run in headless mode |
OH_CONCURRENCY |
--concurrency |
Number of concurrent tasks |
OH_PROXY_URL |
--proxy-url |
Proxy server URL |
OH_PROXY_USER |
--proxy-user |
Proxy username |
OH_PROXY_PASS |
--proxy-pass |
Proxy password |
OH_USER_AGENT |
--user-agent |
Custom browser user agent |
OH_LOCALE |
--locale |
Browser locale |
OH_TIMEZONE |
--timezone |
Browser timezone ID |
Example:
export OH_SPORT=football
export OH_HEADLESS=true
export OH_PROXY_URL=http://proxy.example.com:8080
oddsharvester upcoming -d 20250301 -m 1x2
๐ณ Running Inside a Docker Container
OddsHarvester is compatible with Docker, allowing you to run the application seamlessly in a containerized environment.
Steps to Run with Docker:
-
Ensure Docker is Installed Make sure Docker is installed and running on your system. Visit Docker's official website for installation instructions specific to your operating system.
-
Build the Docker Image Navigate to the project's root directory, where the
Dockerfileis located. Build the Docker image using the appropriate Docker build command. Assign a name to the image, such asodds-harvester:docker build -t odds-harvester:local --target local-dev . -
Run the Container Start a Docker container based on the built image. Map the necessary ports if required and specify any volumes to persist data. Pass any CLI arguments as part of the Docker run command:
docker run --rm odds-harvester:local python3 -m oddsharvester upcoming -s football -d 20250301 -m 1x2 -o output.json --headless
Or using environment variables:
docker run --rm \ -e OH_SPORT=football \ -e OH_HEADLESS=true \ odds-harvester:local python3 -m oddsharvester upcoming -d 20250301 -m 1x2
-
Interactive Mode for Debugging If you need to debug or run commands interactively:
docker run --rm -it odds-harvester:latest /bin/bash
Tips:
- Volume Mapping: Use volume mapping to store logs or output data on the host machine.
- Container Reusability: Assign a unique container name to avoid conflicts when running multiple instances.
โ๏ธ Cloud Deployment
OddsHarvester can also be deployed on a cloud provider using the Serverless Framework, with a Docker image to ensure compatibility with AWS Lambda (Dockerfile will need to be tweaked if you want to deploy on a different cloud provider).
Why Use a Docker Image?
-
AWS Lambda's Deployment Size Limit: AWS Lambda has a hard limit of 50MB for direct deployment packages, which includes code, dependencies, and assets. Playwright and its browser dependencies far exceed this limit.
-
Playwright's Incompatibility with Lambda Layers: Playwright cannot be installed as an AWS Lambda layer because:
- Its browser dependencies require system libraries that are unavailable in Lambda's standard runtime environment.
- Packaging these libraries within Lambda layers would exceed the layer size limit.
-
Solution: Using a Docker image solves these limitations by bundling the entire runtime environment, including Playwright, its browsers, and all required libraries, into a single package. This ensures a consistent and compatible execution environment.
Serverless Framework Setup:
-
Serverless Configuration: The application includes a
serverless.yamlfile located at the root of the project. This file defines the deployment configuration for a serverless environment. Users can customize the configuration as needed, including:- Provider: Specify the cloud provider (e.g., AWS).
- Region: Set the desired deployment region (e.g.,
eu-west-3). - Resources: Update the S3 bucket details or permissions as required.
-
Docker Integration: The app uses a Docker image (
playwright_python_arm64) to ensure compatibility with the serverless architecture. The Dockerfile is already included in the project and configured inserverless.yaml. You'll need to build the image locally (see section above) and push the Docker image to ECR. -
Permissions: By default, the app is configured with IAM roles to:
- Upload (
PutObject), retrieve (GetObject), and delete (DeleteObject) files from an S3 bucket. Update theResourcefield inserverless.yamlwith the ARN of your S3 bucket.
- Upload (
-
Function Details:
- Function Name:
scanAndStoreOddsPortalDataV2 - Memory Size: 2048 MB
- Timeout: 360 seconds
- Event Trigger: Runs automatically every 2 hours (
rate(2 hours)) via EventBridge.
- Function Name:
Customizing Your Configuration: To tailor the serverless deployment for your needs:
- Open the
serverless.yamlfile in the root directory. - Update the relevant fields:
- S3 bucket ARN in the IAM policy.
- Scheduling rate for the EventBridge trigger.
- Resource limits (e.g., memory size or timeout).
Deploying to your preferred Cloud provider:
- Install the Serverless Framework:
- Follow the installation guide at Serverless Framework.
- Deploy the application:
- Use the
sls deploycommand to deploy the app to your cloud provider.
- Use the
- Verify the deployment:
- Confirm that the function is scheduled correctly and check logs or S3 outputs.
๐ค Contributing
Contributions are welcome! If you have ideas, improvements, or bug fixes, feel free to submit an issue or a pull request. Please ensure that your contributions follow the project's coding standards and include clear descriptions for any changes.
โ Donations
If you find this project useful and would like to support its development, consider buying me a coffee! Your support helps keep this project maintained and improved.
๐ License
This project is licensed under the MIT License - see the LICENSE file for more details.
๐ฌ Feedback
Have any questions or feedback? Feel free to reach out via the issues tab on GitHub. We'd love to hear from you!
โ Disclaimer
This package is intended for educational purposes only and not for any commercial use in any way. The author is not affiliated with or endorsed by the oddsportal.com website. Use this application responsibly and ensure compliance with the terms of service of oddsportal.com and any applicable laws in your jurisdiction.
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
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 oddsharvester-0.1.0.tar.gz.
File metadata
- Download URL: oddsharvester-0.1.0.tar.gz
- Upload date:
- Size: 76.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23acd2ccc43c28bbd14612dc783f1a2f9b920d7f45685f0d583195cc089d43ab
|
|
| MD5 |
e564ce56966d34ea283f03d366580cb4
|
|
| BLAKE2b-256 |
b405a87f99c91c0af75a9aa5e78773d31004c7d1aa049b881e20a5d49ba51b36
|
Provenance
The following attestation bundles were made for oddsharvester-0.1.0.tar.gz:
Publisher:
release.yml on jordantete/OddsHarvester
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
oddsharvester-0.1.0.tar.gz -
Subject digest:
23acd2ccc43c28bbd14612dc783f1a2f9b920d7f45685f0d583195cc089d43ab - Sigstore transparency entry: 908473231
- Sigstore integration time:
-
Permalink:
jordantete/OddsHarvester@acead91f0aeeaa4300399847ecce67717e927f4f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jordantete
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@acead91f0aeeaa4300399847ecce67717e927f4f -
Trigger Event:
push
-
Statement type:
File details
Details for the file oddsharvester-0.1.0-py3-none-any.whl.
File metadata
- Download URL: oddsharvester-0.1.0-py3-none-any.whl
- Upload date:
- Size: 79.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e14268da2d49e5e3cb92ca8095020fb0dfa04036cd2536c8aebf43a1739edea0
|
|
| MD5 |
efdc3b69402d12823cf7d124088836a4
|
|
| BLAKE2b-256 |
e86fdc03b4b97007a0a1373dad2d489cf857cfe43edc36e101faab62140667ab
|
Provenance
The following attestation bundles were made for oddsharvester-0.1.0-py3-none-any.whl:
Publisher:
release.yml on jordantete/OddsHarvester
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
oddsharvester-0.1.0-py3-none-any.whl -
Subject digest:
e14268da2d49e5e3cb92ca8095020fb0dfa04036cd2536c8aebf43a1739edea0 - Sigstore transparency entry: 908473235
- Sigstore integration time:
-
Permalink:
jordantete/OddsHarvester@acead91f0aeeaa4300399847ecce67717e927f4f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jordantete
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@acead91f0aeeaa4300399847ecce67717e927f4f -
Trigger Event:
push
-
Statement type: