forked from wikimedia/mediawiki-api-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_users.py
More file actions
35 lines (24 loc) · 727 Bytes
/
get_users.py
File metadata and controls
35 lines (24 loc) · 727 Bytes
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
#This file is auto-generated. See modules.json and autogenerator.py for details
#!/usr/bin/python3
"""
get_users.py
MediaWiki API Demos
Demo of `Users` module: Get information about several users:
[[1.2.3.4]], [[Catrope]], [[Vandal01]], and [[Bob]]
MIT License
"""
import requests
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php"
PARAMS = {
"action": "query",
"format": "json",
"list": "users",
"ususers": "Catrope|Bob",
"usprop": "blockinfo|groups|editcount|registration|emailable|gender"
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
USERS = DATA["query"]["users"]
for u in USERS:
print(str(u["name"]) + " has " + str(u["editcount"]) + " edits.")