forked from bunyk/wikidump
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleanmess.py
More file actions
31 lines (22 loc) · 777 Bytes
/
Copy pathcleanmess.py
File metadata and controls
31 lines (22 loc) · 777 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
import re
from pywikibot import Page, Site, pagegenerators
import mwparserfromhell
from itertools import islice
from remove_spam import update_page
SEARCH_QUERY='insource:/cx-template-editor-source-container/'
def main():
for page in pagegenerators.SearchPageGenerator(SEARCH_QUERY, namespaces=[0]):
edit_page(page)
def edit_page(page):
print(page.title())
code = mwparserfromhell.parse(page.text)
for tag in code.filter(
recursive=True,
forcetype=mwparserfromhell.nodes.tag.Tag
):
if not str(tag).startswith('<div class="cx-template-editor-source-container"'):
continue
code.remove(tag)
update_page(page, str(code), 'Вікіфікація', yes=False)
if __name__ == "__main__":
main()