forked from ONI-Wiki-zh/BotNotIncluded
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot_contributors.py
More file actions
34 lines (29 loc) · 928 Bytes
/
bot_contributors.py
File metadata and controls
34 lines (29 loc) · 928 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
import pywikibot
import collections
def bot_contributors(site: pywikibot.Site):
counter = collections.Counter()
errors = []
for i, ns in enumerate(site.namespaces):
if ns < 0:
continue
print(f"ns = {site.namespace(ns)}")
if i % 100 == 0:
print(f"{i} pages scanned")
ps = list(site.allpages(namespace=ns, content=True))
for i, p in enumerate(ps):
if i % 10 == 0:
print(f"{i}/{len(ps)}")
try:
counter += p.contributors()
except:
errors.append(p)
print("???")
for e in errors:
print(e)
for editor, edit_num in counter.most_common():
print(f"{editor} -- {edit_num}")
return counter
if __name__ == '__main__':
oni_zh = pywikibot.Site("zh", "oni")
boni = pywikibot.Site("zh", "boni")
# c = bot_contributors(boni)