Last active
August 31, 2024 20:26
Get espn auction adp and put in csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.request | |
import json | |
import csv | |
req = urllib.request.Request('https://lm-api-reads.fantasy.espn.com/apis/v3/games/ffl/seasons/2024/segments/0/leaguedefaults/3?view=kona_player_info') | |
req.add_header('x-fantasy-filter','{"players":{"filterSlotIds":{"value":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,23,24]},"limit":150,"offset":0,"sortAverageAuction":{"sortAsc":false,"sortPriority":1},"sortDraftRanks":{"sortPriority":100,"sortAsc":true,"value":"STANDARD"},"filterRanksForScoringPeriodIds":{"value":[1]},"filterRanksForRankTypes":{"value":["PPR"]},"filterRanksForSlotIds":{"value":[0,2,4,6,17,16]},"filterStatsForTopScoringPeriodIds":{"value":2,"additionalValue":["002021","102021","002020","022021"]}}}') | |
with urllib.request.urlopen(req) as url: | |
data = json.loads(url.read().decode()) | |
print(data) | |
with open('adp.txt','w') as outfile: | |
json.dump(data,outfile) | |
with open('adp.txt') as json_file: | |
with open('aucionval.csv', mode='w') as auction_file: | |
auction_file.write("Name,Value") | |
auction_file.write('\n') | |
data = json.load(json_file) | |
for person in data['players']: | |
if person['player']['ownership']['auctionValueAverage'] > 1: | |
auction_file.write(person['player']['fullName']+","+str(person['player']['ownership']['auctionValueAverage'])) | |
auction_file.write('\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment