-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetchdata.py
More file actions
67 lines (53 loc) · 1.95 KB
/
Copy pathfetchdata.py
File metadata and controls
67 lines (53 loc) · 1.95 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import requests
import json
def fetchquests():
qinit = requests.get("https://xivapi.com/Quest").json()
total = qinit["Pagination"]["ResultsTotal"]
first = 65536
for i in range(total):
try:
url = "https://garlandtools.org/api/get.php"
params = dict(
id=str(first + i),
type='quest',
lang='en',
version='2'
)
resp = requests.get(url=url, params=params)
filename = "./quests/q" + str(first + i) + ".json"
if(resp.json()):
with open(filename, 'w', encoding='utf-8') as f:
json.dump(resp.json(), f, ensure_ascii=False, indent=4)
else:
print(filename + " blank")
#print(resp.json())
except:
print("Failed at " + filename)
def fetchinstances():
qinit = requests.get("https://xivapi.com/InstanceContent").json()
Pages = qinit["Pagination"]["PageTotal"]
insts = []
for page in range(Pages):
thispage = requests.get("https://xivapi.com/InstanceContent?page=" + str(page+1)).json()
for inst in thispage["Results"]:
insts.append(str(inst["ID"]))
print(insts)
for i in range(len(insts)):
try:
url = "https://garlandtools.org/api/get.php"
params = dict(
id=str(insts[i]),
type='instance',
lang='en',
version='2'
)
resp = requests.get(url=url, params=params)
filename = "./instances/i" + str(insts[i]) + ".json"
if(resp.json()):
with open(filename, 'w', encoding='utf-8') as f:
json.dump(resp.json(), f, ensure_ascii=False, indent=4)
else:
print(filename + " blank")
#print(resp.json())
except:
print("Failed at " + filename)