Package: power-ranker
Power RankerA tool for scraping fantasy football stats from ESPN leagues, creating power rankings, collecting previous season standings, and publishing to a website.Update 2019-11-06: version 2.1.0 now has playoff Monte Carlo simulations reimplementedUpdate 2019-09-12: version 2.0.1 is now working with the newest v3 of ESPN apiCheck out packagepip3installpower_rankerORgitclonehttps://github.com/rynecarbone/power_rankercdpower_ranker
python3setup.pyinstallGenerate a Configuration FileDownload a local copy of the default configuration file. Once you have the file, fill in your league name, league id, year, and week (that you want to make rankings for). You can also adjust any of the settings that control the algorithms in the power rankings, or use the default values. For detailed instructions, see theConfiguration File DocumentationTo download a local copy of the configuration file, use the -dc (--download-config) option. If you are in a private league, use the -p (--private-league) option to log into your ESPN account and retreive cookie information:power_ranker-dcCreatingcopyof:/Path/To/power_ranker/docs/default_config.cfg
Tolocaldestination:/Path/To/Current/Dir/MY_LOCAL_CONFIG.cfgorpower_ranker-dc-p
Creatingcopyof:/Path/To/power_ranker/docs/default_config.cfg
Tolocaldestination:/Path/To/Current/Dir/MY_LOCAL_CONFIG.cfg
Username:<EnterESPNLogin>
Password:<EnterESPNPassword>Use your favorite editor to open the local "MY_LOCAL_CONFIG.cfg" file and edit it.Command lineAfter you have added your league information, pass the configuration file as an argument with the -c (--config-file) option. If you haven't already, you can add the -p (--private-league) option to log into your ESPN account and retreive cookie information.power_ranker-cMY_LOCAL_CONFIG.cfgUsingMY_LOCAL_CONFIG.cfgtogeneratepowerrankings

Week3PowerRankings
...Alternatively, pass the league id, year, and week as command line arguments (-l --leagueid, -y --year, -w --week) and all other default power ranking settings will be used. Pass the -p option if in a private league.power_ranker-l123456-y2019-w1Usinguserinput:
LeagueID:123456Year:2019Week:1Creatingcopyof:/Path/To/power_ranker/docs/default_config.cfg
Tolocaldestination:/Path/To/Current/Dir/MY_LOCAL_CONFIG.cfg

Week1PowerRankings...After you run the rankings, a template website will be generated in a directory titled "output/". Follow the instructions on how toPublish Power Rankings to a Websiteif you want to share the output with your league. To add your own summary to the week's power rankings, edit the file "output/2017/power.html". Find the commented out section:<!--- <p>FIXME! FIXME!Add your own commentary here! New write-up here!Or just leave the rankings</p> -->Remove the<!--and-->comment delimeters, and edit the text inside the paragraph markers (<p>,</p>).Playoff OddsSeeConfiguration File Documentationfor detailed instructins on how to alter the configuration file to run simulated playoff odds. You can control the number of simulations to run, where each simulation uses this season's scores to predict the outcomes of the remaining games. The fraction of simulations in which a team makes the playoffs determines that team's estimated odds of making the playoffs.League HistoryThe first time you run power_ranker, make sure 'do_Setup' option is set to True. It will search for and scrape stats for
all previous seasons. A League history page will be created displaying the standings and stats from each of these past seasons.Example OutputAfter successfully running the code, the generated website files should appear like the examples below:Power rankingswelcome pagePower rankingstablewith metric breakdownAbout page, explaining briefly the algorithmsTeam summary pagesshowing stats for each team, with a game logHistory pageshowing the final season standings for all previous seasonsCreditThe code to extract league info from hidden ESPN API, including retreiving league settings and accessing private league data, is largely thanks to
Rich Barton's espnff package:https://github.com/rbarton65/espnff.