This commit is contained in:
Xevion
2019-07-25 12:20:24 -05:00
parent 547cbf2e9a
commit e31f1ae5dc
8 changed files with 9191 additions and 0 deletions

32
_fetch.py Normal file
View File

@@ -0,0 +1,32 @@
import requests, json, pprint
class Fetch():
def __init__(self, total=999):
self.total = total
self.retrieve()
def retrieve(self, total=None):
if total==None: total=self.total
url = "https://mee6.xyz/api/plugins/levels/leaderboard/166630061217153024?limit={}&page={}"
dataset = []
pages = total // 999 # Process n amount of pages
print(pages)
last = total % 999 # Then process the last n amount of pages in addition
print(last)
for i in range(pages):
resp = requests.get(url.format(999, i))
dataset.append(resp.json()['players'])
if last > 0:
resp = requests.get(url.format(last, pages+1))
dataset.append(resp.json()['players'])
self.data = dataset
def get(self):
return self.data
pp = pprint.PrettyPrinter()
fetcher = Fetch(1005)
dataset = fetcher.get()
print(len(dataset[]))
# pp.pprint(dataset[0]['players'])