FanGraphs-Export
The FanGraphs website, well-known among baseball fans, provides a variety of baseball statistics. The statistics available are extremely expansive, as the website brags stats for every player in MLB history.
The fangraphs package allows for simple, intuitive parsing of the many webpages available.
While not every page is "scrape-able" (i.e. the pages are most composed of graphics),
there are plans for covering as many pages as possible, including the most popular ones.
This package contains modules for scraping and exporting data from each of the covered webpages.
Dependencies
The fangraphs library requires Python version 3.6 or higher.
The following libraries along are required for the fangraphs library.
BeautifulSoup4lxmlplaywrightpytestrequests
Note: The dependencies of each package listed above are also required.
To install all the necessary packages, run:
pip install -r requirements.txt
Note: The browser binaries of playwright are needed for proper usage.
To install the browser binaries, run playwright install.
See the Playwright documentation for more information.
Documentation
The Read the Docs documentation can be found here.
Basic Usage
Each group of FanGraphs pages (e.g. Leaders, Projections, etc.) which is covered has an individual module. Each webpage in each group of webpages has an individual class covering the page.
Covered FanGraphs webpage groups:
Leaders
FanGraphs Leaders pages:
- Major League Leaderboards
- Splits Leaderboards
- Season Stat Grid
- 60-Game Span Leaderboards
- KBO Leaderboards
- WAR Leaderboards
from fangraphs.leaders import leaders
mll = leaders.MajorLeague()
splits = leaders.Splits()
ssg = leaders.SeasonStat()
gsl = leaders.GameSpan()
intl = leaders.International()
war = leaders.WAR()
Tests
To run all tests, run pytest FanGraphs
To run the tests for a specific module, run pytest fangraphs/tests/test_module_name.py.
For example,
pytest fangraphs/tests/test_leaders.py
To run the tests for a specific class, run pytest -k "TestClassName".
For example,
pytest -k "TestMajorLeagueLeaderboards"
License
The code in this repository is licensed under an MIT License.
Copyright (c) 2021 Jacob Lee
Metadata
Release files for fangraphs 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fangraphs-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Release files / fangraphs-1.1.0-py3-none-any.whl
| Download URL | fangraphs-1.1.0-py3-none-any.whl |
|---|---|
| Size | 24.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d429dbfbead51bed341ef09827e9226161ac5c471e725add3a606cfe670371d
|
|
BLAKE2b-256 checksum How to use checksums |
103f0ab27fb2ee96cb5e3dc5c17323791dad844c743cace3ee2a85e9cf5c2616
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.9.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
|
Security for fangraphs 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.