-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathget_games.py
More file actions
54 lines (45 loc) · 1.88 KB
/
get_games.py
File metadata and controls
54 lines (45 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import requests
import json
lst = [];
def replays(userID, ran):
url = "https://halite.io/api/web/game"
prev = ""
rurl = "https://s3.amazonaws.com/halitereplaybucket/"
for i in range(5):
try:
open(userID + str(i*100000) + str(43434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343) + '.txt', 'r')
print i, "lol"
continue
except IOError:
print i, "next"
if (i == 0):
querystring = {"userID":userID,"limit":"10000"}
else:
querystring = {"userID":userID,"limit":"10","startingID":prev}
headers = {
'userid': "1017",
'limit': "10",
'startingid': "st",
'cache-control': "no-cache",
'postman-token': "d519fb4b-2b8a-3773-bd10-b8d3a48c2494"
}
response = requests.request("GET", url, headers=headers, params=querystring)
global lst
res = json.loads(response.text)
print len(res)
for j, r in enumerate(res):
try:
#print r["replayName"]
lst.append(r)
prev = r["gameID"]
c = rurl + r["replayName"]
print c
replay = requests.request("GET", c, headers=headers)
f = open(r["replayName"] + '.hlt', 'w')
f.write(replay.text)
except requests.exceptions.ConnectionError:
pass
print replays("2609", 6400)
#print replays("2557", 2290)
#print replays("1017", 1101)
#print replays("3157",5325)