Metadata-Version: 2.4
Name: sofascrape
Version: 0.1.2
Summary: A Python library for scraping and interacting with SofaScore APIs
Author-email: Chumari <dchumari@gmail.com>
License: MIT License
Project-URL: Homepage, https://github.com/dchumari/sofascrape
Project-URL: Repository, https://github.com/dchumari/sofascrape.git
Project-URL: Bug Reports, https://github.com/dchumari/sofascrape/issues
Keywords: sofascore,scraping,sports,football,api
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: playwright>=1.30.0
Requires-Dist: beautifulsoup4>=4.11.0
Requires-Dist: requests>=2.28.0
Provides-Extra: dev
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Dynamic: license-file

# Sofascrape

A Python library for scraping and interacting with SofaScore APIs to access football statistics, events, and other sports data.

## Installation

```bash
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

```python
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

```python
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 categories
- `get_live_events()` - Get all live football events
- `get_event_data(event_id)` - Get core data for a specific event
- `get_event_lineups(event_id)` - Get lineups for a specific event
- `get_tournament_standings(tournament_id, season_id)` - Get standings for a tournament
- `get_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](LICENSE) file for more details.
