-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelementary.py
More file actions
29 lines (26 loc) · 1.1 KB
/
elementary.py
File metadata and controls
29 lines (26 loc) · 1.1 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
from mwclient import Site
he = Site("www.hamichlol.org.il")
yi = Site("yi.hamichlol.org.il")
category = yi.categories["עלעמענטארע ארטיקלען צו פארברייטערן"]
with open("elementary.csv", "w", encoding="utf-8") as f:
f.write("ארטיקל|גרויס|ערך|גודל\n")
for page in category:
result = yi.api("query", prop="info", titles=page.name)
for p in result["query"]["pages"].values():
if "length" in p:
size = p["length"]
for link in page.langlinks():
if link[0] == "he":
result = he.api("query", redirects=True, prop="info", titles=link[1])
for p in result["query"]["pages"].values():
if "length" in p:
f.write(
page.name
+ "|"
+ str(size)
+ "|"
+ p["title"]
+ "|"
+ str(p["length"])
+ "\n"
)