A package to scrape swimmer time data from USA Swimming
Project description
Swimmer Time
A Python package to scrape swimmer time data from USA Swimming.
Installation
From PyPI
pip install swimmer-time
From Source
git clone https://github.com/kevinwang/swimmer-time.git
cd swimmer-time
poetry install
Configuration
Edit config/config.yaml to set:
- ChromeDriver path
- Wait time for page loads
- Output file path and validation settings
file: Path to save the CSV outputsave_invalid_data: Set to true to save data even if validation fails
- Swimmer details (name, club, year)
Features
- Automatic retry mechanism for web operations with exponential backoff
- Data validation and cleaning
- Validates expected columns are present
- Converts dates to proper datetime format
- Cleans time strings
- Removes empty rows
- Configurable invalid data handling
Usage
As a Library
from swimmer_time import SwimmerDataScraper
# Initialize scraper with ChromeDriver path
scraper = SwimmerDataScraper("/path/to/chromedriver")
# Setup and use
scraper.setup_driver()
scraper.search_swimmer("First", "Last")
scraper.select_swimmer_profile("Club Name")
scraper.select_competition_year()
# Get data
df = scraper.extract_table_data()
df.to_csv("output.csv", index=False)
# Clean up
scraper.close()
Command Line Interface
# Using poetry
poetry run swimmer-time
# Or directly with Python
python -m swimmer_time.cli
Make sure to configure the settings in config/config.yaml before running.
Error Handling
The scraper includes several error handling features:
-
Automatic Retries
- Web operations automatically retry on failure
- Uses exponential backoff between attempts
- Configurable max retries and initial delay
-
Data Validation
- Validates data structure and content
- Reports validation errors and warnings
- Optional saving of invalid data (controlled by config)
-
Logging
- Detailed logging of operations
- Error and warning messages
- Validation status reporting
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 swimmer_time-0.1.0.tar.gz.
File metadata
- Download URL: swimmer_time-0.1.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.11.9 Darwin/24.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
854a3455623da9f571b663bbaf12a3a49f0913edb54d5d07bc7128fd1edf99a8
|
|
| MD5 |
9330056cc2c4629cab07691b19e633a6
|
|
| BLAKE2b-256 |
a0961288952b2c79ca61e51c8926365c8b1787d17345c1723446e2f441f21226
|
File details
Details for the file swimmer_time-0.1.0-py3-none-any.whl.
File metadata
- Download URL: swimmer_time-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.11.9 Darwin/24.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7622a4d13c940dd43af696728c9edd72b8ed422c25feb1fd4cb9b52066e5e7e
|
|
| MD5 |
0fec6191a0884b759fdc22ec619d3c2a
|
|
| BLAKE2b-256 |
78152be7424c850f93b5473bace5c46dfc8f42c88153e7b0c72455ca419eb622
|