Installation
Requirements
- Python 3.10 or higher
- Internet connection for accessing swimrankings.net
- Chrome or Chromium installed locally: swimrankings.net is protected by a Cloudflare challenge that the library solves with a real browser
- On headless Linux, the system
xvfbpackage (a virtual display is started automatically when noDISPLAYis available)
Install from PyPI
pip install swimrankingsInstall from Source
If you want to install the latest development version:
# Clone the repository
git clone https://github.com/MauroDruwel/Swimrankings.git
cd Swimrankings
# Install in development mode
pip install -e .Development Installation
For development work, install with development dependencies:
# Clone the repository
git clone https://github.com/MauroDruwel/Swimrankings.git
cd Swimrankings
# Install development dependencies
pip install -r requirements-dev.txt
# Install in development mode
pip install -e .Verify Installation
To verify that the installation was successful, try importing the library:
from swimrankings import Athletes
# Test with a simple search
try:
athletes = Athletes(name="Test")
print("✅ SwimRankings library installed successfully!")
except Exception as e:
print(f"❌ Installation issue: {e}")Dependencies
The library requires the following packages (installed automatically):
- curl-cffi: HTTP requests with a Chrome TLS fingerprint
- beautifulsoup4: HTML parsing
- lxml: Fast XML/HTML parser
- nodriver: Drives a local Chrome/Chromium browser to solve the Cloudflare challenge
- pyvirtualdisplay: Starts a virtual display on headless Linux
No third-party services or API keys are used; the browser runs locally.
Optional Environment Variables
SWIMRANKINGS_BROWSER_PATH— path to a specific Chrome/Chromium binary.SWIMRANKINGS_CACHE_DIR— Cloudflare clearance cache directory (~/.cache/swimrankings/by default).DISPLAY— X display used by the browser; on headless Linux a virtual display is started automatically when this is unset.SWIMRANKINGS_USERNAME/SWIMRANKINGS_PASSWORD— Swimrankings Member credentials.SWIMRANKINGS_EMAILis accepted as an alias forSWIMRANKINGS_USERNAME.
Troubleshooting
Import Errors
If you get import errors, make sure you've installed the library correctly:
pip show swimrankingsNetwork Issues
The library requires internet access to fetch data from swimrankings.net and uses
curl_cffi (not requests); it does not expose a proxy option. A restrictive proxy
may also prevent the local browser from solving the Cloudflare challenge. If the
challenge fails, check that Chrome/Chromium is installed and reachable, or set
SWIMRANKINGS_BROWSER_PATH to its binary.
Python Version Issues
Make sure you're using Python 3.10 or higher:
python --versionIf you have multiple Python versions installed, you might need to use python3 or pip3 instead.