-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete_ns.py
39 lines (32 loc) · 1.11 KB
/
delete_ns.py
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
import time
from mwcleric.errors import RetriedLoginAndStillFailed
from mwcleric.wikigg_client import WikiggClient
from mwcleric.auth_credentials import AuthCredentials
from mwclient import APIError
credentials = AuthCredentials(user_file="bot")
wikis = ['gg']
for wiki in wikis:
limit = -1
startat_page = None
# startat_page = 'Zuchtzentrum'
site = WikiggClient(wiki, credentials=credentials) # Set wiki
# this_template = site.client.pages['Template:Infobox Player'] # Set template
# pages = this_template.embeddedin()
# pages = site.client.categories['Pages with script errors']
pages = site.client.allpages(namespace=3)
passed_startat = False if startat_page else True
lmt = 0
for page in pages:
if lmt == limit:
break
if startat_page and page.name == startat_page:
passed_startat = True
if not passed_startat:
continue
print('Deleting page %s...' % page.name)
try:
site.delete(page)
except APIError:
continue
except RetriedLoginAndStillFailed:
continue