A Python library for scraping and interacting with SofaScore APIs
Project description
Sofascrape
A Python library for scraping and interacting with SofaScore APIs to access football statistics, events, and other sports data.
Installation
pip install sofascrape
Features
- Easy access to SofaScore API endpoints
- Built-in data formatting and export capabilities (JSON, CSV)
- Context manager support for resource management
- Comprehensive coverage of SofaScore API endpoints
Usage
Basic Usage
from sofascrape import SofascrapeClient
# Use context manager for automatic resource management
with SofascrapeClient() as client:
# Get football categories
categories = client.get_sport_categories()
print(categories.data) # Access raw data
# Save as JSON file
categories.json("football_categories.json")
# Save as CSV file
categories.csv("football_categories.csv")
Advanced Usage
from sofascrape import SofascrapeClient
# Initialize client with custom options
client = SofascrapeClient(headless=True, timeout=60000)
try:
client.start() # Manually start the client
# Get live football events
live_events = client.get_live_events()
# Access data directly
for event in live_events:
print(event)
# Get specific tournament standings
standings = client.get_tournament_standings(tournament_id=123, season_id=456)
standings.json("standings.json")
finally:
client.close() # Manually close the client
Available Methods
The library provides access to various SofaScore API endpoints:
get_sport_categories()- Get all available football categoriesget_live_events()- Get all live football eventsget_event_data(event_id)- Get core data for a specific eventget_event_lineups(event_id)- Get lineups for a specific eventget_tournament_standings(tournament_id, season_id)- Get standings for a tournamentget_team_info(team_id)- Get information about a specific team- And many more endpoints...
For a complete list of available methods, check the client.py file.
Response Objects
API responses are wrapped in ApiResponse objects that provide:
- Direct access to data via
.data - JSON export via
.json([filename]) - CSV export via
.csv([filename]) - Dictionary-like access via
[] - Iteration support via
iter() - Length via
len()
License
MIT License. See the LICENSE file for more details.
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 sofascrape-0.1.2.tar.gz.
File metadata
- Download URL: sofascrape-0.1.2.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35309bf6bf3d4a8ce4472959d96880c6e85c00270d6b20d67e5a3f3f1206652b
|
|
| MD5 |
069d9a8d986dc1e7671783c48b6d6bc3
|
|
| BLAKE2b-256 |
ca6f97b6bd2bad37ed0d6358b8add3270aae65916e0810067e018fca372e468a
|
File details
Details for the file sofascrape-0.1.2-py3-none-any.whl.
File metadata
- Download URL: sofascrape-0.1.2-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85a7383556563a6475e396282e675d104af8faf0082f30f25978cbd8f067661d
|
|
| MD5 |
4501a16b101421b1f1127a85de9d9e03
|
|
| BLAKE2b-256 |
5fa41dc025101922d6b1b1ea0ab4ced1c908e8ff4690d5337196bbbe5845a708
|