Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/enter-a-new-username3/bet365-scraper-demo/llms.txt

Use this file to discover all available pages before exploring further.

This quickstart guide will walk you through setting up the Bet365 Scraper SDK and running your first successful data extraction in under 5 minutes.

Prerequisites

  • Python 3.8 or higher installed
  • API key for the X-Net header generation service
  • Basic terminal/command line knowledge
If you don’t have an API key yet, contact the developer via Discord to request access.

Getting Started

1

Install Dependencies

First, install the required Python packages:
pip3 install -r requirements.txt
This installs three core dependencies:
  • curl_cffi: Low-level HTTP client with TLS fingerprinting support
  • tls_client: Additional TLS client for API communication
  • prettytable: Table formatting for displaying scraped data
2

Configure API Credentials

Create or edit the config.json file in your project root:
{
  "api_url": "https://vercel-android-server-three.vercel.app/get_x_net_android",
  "api_key": "your_api_key_here",
  "proxy": "",
  "email": "",
  "password": ""
}
Required Configuration:
  • api_url: The endpoint for X-Net header generation (provided by the service)
  • api_key: Your authentication key for the API service
Optional Configuration:
  • proxy: Add a proxy URL (format: http://user:pass@host:port) for enhanced reliability
  • email and password: Reserved for future authentication features
3

Initialize the Session

Create a new Python file or use the provided main.py:
import json
from bet365 import Bet365AndroidSession

# Load configuration
with open("config.json", encoding="utf8") as fp:
    config = json.load(fp)

# Initialize the session
session = Bet365AndroidSession(
    config["api_url"],
    config["api_key"],
    proxy=config["proxy"] or None,
    verify=False,
    host="www.bet365.com",
)
The Bet365AndroidSession handles:
  • TLS fingerprinting to match Android devices
  • Cookie management and device ID generation
  • Anti-bot protection headers
4

Navigate to Homepage

Establish a session by visiting the Bet365 homepage:
print("Going to homepage...")
session.go_homepage()
This critical step:
  • Establishes cookies and session tokens
  • Extracts the SST (Session State Token) for subsequent requests
  • Initializes device fingerprinting
The homepage navigation may take longer than expected due to curl_cffi initialization. This is normal behavior.
5

Extract Available Sports

Retrieve the list of all available sports from Bet365:
sports = session.extract_available_sports()

# Display available sports
for sport in sports:
    print(f"Sport: {sport.name}, PD: {sport.PD}")
Each Sport object contains:
  • name: Human-readable sport name (e.g., “Soccer”, “Tennis”)
  • PD: Bet365’s internal page descriptor identifier
6

Scrape Sport Homepage Data

Extract odds and match data from a specific sport:
# Find Soccer sport
soccer = next(filter(lambda m: m.name == "Soccer", sports))

# Get Soccer homepage with matches and odds
session.get_sport_homepage(soccer)
This method:
  • Fetches splash pods containing match data
  • Parses tables with odds, teams, and market information
  • Pretty-prints the data to console
  • Saves raw response to response.txt for debugging
7

Run the Complete Example

Execute the complete script:
python3 main.py
Expected output:
Fetching soccer page using android api
Going to homepage started taking longer than it should because of curl_cffi.
False  # ZAP connection availability
Sport: Soccer, PD: #AS#B1#...
Sport: Tennis, PD: #AS#B2#...
# ... (match tables with odds data)
The scraper will:
  1. Navigate to Bet365 homepage
  2. List all available sports
  3. Extract Soccer matches and odds
  4. Display formatted tables in the console

Complete Working Example

Here’s the full main.py implementation:
import json
from bet365 import Bet365AndroidSession

with open("config.json", encoding="utf8") as fp:
    config = json.load(fp)

print("Fetching soccer page using android api")

session = Bet365AndroidSession(
    config["api_url"],
    config["api_key"],
    proxy=config["proxy"] or None,
    verify=False,
    host="www.bet365.com",
)

print("Going to homepage started taking longer than it should because of curl_cffi.")
session.go_homepage()

sports = session.extract_available_sports()
soccer = next(filter(lambda m: m.name == "Soccer", sports))
session.get_sport_homepage(soccer)

if session.zap_thread is not None:
    session.zap_thread.join()

Understanding the Output

The SDK will display:
  • Pretty-printed tables: Match data formatted using prettytable
  • Raw response file: response.txt contains the full API response for debugging
  • Console logs: Progress indicators and error messages

Troubleshooting

403 Forbidden Error: If you receive a 403 status code, this typically means:
  • Your IP address is blocked by Cloudflare
  • Headers need updating (contact support)
  • Proxy configuration required
500 Internal Error: Usually indicates:
  • Bad IP address or proxy
  • Configuration endpoint is unavailable
  • Rate limiting triggered

Common Issues

API Key Invalid
An error occured while generating token: Invalid API key
→ Verify your api_key in config.json is correct Assertion Error During Homepage
AssertionError: Blocked by Cloudflare...
→ Try using a residential proxy or contact support for header updates Import Error
ModuleNotFoundError: No module named 'curl_cffi'
→ Run pip3 install -r requirements.txt to install dependencies

Next Steps

Now that you have a working scraper:

API Reference

Explore all available methods and parameters

Core Concepts

Learn about anti-bot protection and TLS fingerprinting

Message Parsing

Understand Bet365’s message format and parsing

Error Handling

Best practices for handling errors and edge cases