Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F37460453
Simple python script to migrate spam blacklist (frwiki)
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Authored By
LD
Aug 13 2023, 8:43 PM
2023-08-13 20:43:29 (UTC+0)
Size
836 B
Referenced Files
None
Subscribers
None
Simple python script to migrate spam blacklist (frwiki)
View Options
import re
import json
import requests
domain = 'https://fr.wikipedia.org'
page_url = '/w/index.php?title=MediaWiki:Spam-blacklist&action=raw'
response = requests.get(domain + page_url)
spam_text = response.text
spam_entries = re.findall(r'(.*?)\s+#(.*)', spam_text)
spam_list = []
for entry in spam_entries:
domain, notes = entry
if domain:
if notes:
domain = domain.replace('\\b', '').replace('\\.', '.').replace('\\-', '-')
special_chars = '()[]{}*\\'
special_chars_in_domain = [char for char in special_chars if char in domain]
if not special_chars_in_domain:
spam_list.append({
"domain": domain.strip(),
"notes": notes.strip()
})
print(json.dumps(spam_list, ensure_ascii=False, indent='\t'))
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
11196353
Default Alt Text
Simple python script to migrate spam blacklist (frwiki) (836 B)
Attached To
Mode
P50570 Simple python script to migrate spam blacklist (frwiki)
Attached
Detach File
Event Timeline
Log In to Comment