Skip to main content

No project description provided

Project description

FanGraphs-Export

FanGraphs logo

Last Commit: master Last Commit: development

Milestone 1 Latest Release License: MIT Read the Docs

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.

  • BeautifulSoup4
  • lxml
  • playwright
  • pytest
  • requests

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:

from FanGraphs import leaders
mll = leaders.MajorLeague()
splits = leaders.Splits()
ssg = leaders.SeasonStatGrid()
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/test_module_name. For example,

pytest FanGraphs/test_leaders

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fangraphs-1.0.0.tar.gz (18.3 kB view hashes)

Uploaded Source

Built Distribution

fangraphs-1.0.0-py3-none-any.whl (17.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page