-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdl_users.py
More file actions
51 lines (36 loc) · 1.13 KB
/
dl_users.py
File metadata and controls
51 lines (36 loc) · 1.13 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
import json
import requests
def run():
url = 'https://forum.vassalengine.org/admin/users/list/new.json'
headers = {
'Api-Key': 'f3692d76322a3f32f31c19400e26e20230d95b144287a7fab4481faa281ec6cb',
'Api-Username': 'system'
}
s = requests.Session()
retries = requests.adapters.Retry(total=5, backoff_factor=1)
s.mount('https://', requests.adapters.HTTPAdapter(max_retries=retries))
with open('data/users.json', 'w') as f:
print('[', file=f)
first = True
page = 1
while True:
params = {
'page': page,
'show_emails': 'true'
}
response = s.get(url, params=params, headers=headers)
response.raise_for_status()
r = response.json()
if not r['users']:
break
for u in r['users']:
if first:
first = False
else:
print(',', file=f)
json.dump(u, f)
print(page)
page += 1
print(']', file=f)
if __name__ == '__main__':
run()