-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyimichl.py
More file actions
57 lines (53 loc) · 1.68 KB
/
Copy pathyimichl.py
File metadata and controls
57 lines (53 loc) · 1.68 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
import requests
import time
def query(request):
request["action"] = "query"
request["format"] = "json"
lastContinue = {}
while True:
# Clone original request
req = request.copy()
# Modify with the values returned in the 'continue' section of the last result.
req.update(lastContinue)
# Call API
time.sleep(1)
result = requests.get(
"https://yi.hamichlol.org.il/w/api.php", params=req
).json()
if "error" in result:
raise Error(result["error"])
if "warnings" in result:
print(result["warnings"])
if "query" in result:
yield result["query"]
if "continue" not in result:
break
lastContinue = result["continue"]
for result in query(
{
"generator": "categorymembers",
"gcmtitle": "קאטעגאריע:המכלול ארטיקלען",
"prop": "info",
}
):
for page in result["pages"]:
title = result["pages"][page]["title"]
size = result["pages"][page]["length"]
# print(title)
time.sleep(0.1)
revision = requests.get(
"https://yi.hamichlol.org.il/w/api.php",
{
"format": "json",
"action": "query",
"titles": title,
"prop": "revisions",
"rvlimit": 1,
"rvprop": "timestamp",
"rvdir": "newer",
},
).json()
# print(hebRes)
for p in revision["query"]["pages"]:
timestamp = revision["query"]["pages"][p]["revisions"][0]["timestamp"]
print(title + "|" + str(size) + "|" + timestamp)