Created
October 3, 2017 20:43
-
-
Save andregaldino/23874532cf19aafa2e7914e8d67e6fa0 to your computer and use it in GitHub Desktop.
get data of FIFA 18 from easports
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 json, requests, time | |
#GERA JSON COM OS DADOS DO FIFA 18 | |
def fetch(num): | |
url = "https://www.easports.com/fifa/ultimate-team/api/fut/item?'page':" | |
data = requests.get(url + str(num)) | |
return json.loads(data.content) | |
def create_file(data, num): | |
if num == 1: | |
with open('file.json', 'a') as myfile: | |
myfile.write("[") | |
for item in data["items"]: | |
with open('file.json', 'a') as myfile: | |
myfile.write(json.dumps(item)+",") | |
i=1 | |
data = fetch(i) | |
create_file(data,i) | |
while i < data["totalPages"]: | |
i = i+1 | |
create_file(fetch(i), i) | |
with open('file.json', 'r+b') as myfile: | |
myfile.seek(-1, 2) | |
myfile.write("]") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment