Giter Club home page Giter Club logo

fangraphs-export's Introduction

FanGraphs-Export

This package is planned to be integrated into the SABRmetrics package.

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.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

fangraphs-export's People

Contributors

jacoblee23 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

reubenwalker

fangraphs-export's Issues

Incompatibility with JuPyter Notebook (Playwright ASync API)

Hey guys,

I apologize if this is annoying. I'm having issues understanding how to actually run the code in a jupyter notebook to scrape the table from the URL at the bottom of this post. When I try and run the code from the example I keep getting an error that reads "It looks like you are using Playwright Sync API inside the asyncio loop. Please use the Async API instead.". Would someone be willing to show me the code I would need to run to get that table? Any help would be greatly appreciated.

https://www.fangraphs.com/leaders/splits-leaderboards?splitArr=42&splitArrPitch=&position=P&autoPt=false&splitTeams=false&statType=player&statgroup=1&startDate=2021-03-01&endDate=2021-11-01&players=&filter=&groupBy=game&sort=-1,1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.