Data update

This commit is contained in:
Ingy döt Net 2025-02-27 18:35:13 -05:00
parent 8e4e15fa56
commit 72eb4943cb
1853 changed files with 35514 additions and 9441 deletions

View file

@ -2,17 +2,20 @@ from urllib.request import urlopen, Request
import xml.dom.minidom
r = Request(
'https://www.rosettacode.org/mw/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml',
headers={'User-Agent': 'Mozilla/5.0'})
"https://rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml",
headers={"User-Agent": "Mozilla/5.0"},
)
x = urlopen(r)
tasks = []
for i in xml.dom.minidom.parseString(x.read()).getElementsByTagName('cm'):
t = i.getAttribute('title').replace(' ', '_')
r = Request(f'https://www.rosettacode.org/mw/index.php?title={t}&action=raw',
headers={'User-Agent': 'Mozilla/5.0'})
for i in xml.dom.minidom.parseString(x.read()).getElementsByTagName("cm"):
t = i.getAttribute("title").replace(" ", "_").replace("+", "%2B")
r = Request(
f"https://rosettacode.org/w/index.php?title={t}&action=raw",
headers={"User-Agent": "Mozilla/5.0"},
)
y = urlopen(r)
tasks.append( y.read().lower().count(b'{{header|') )
print(t.replace('_', ' ') + f': {tasks[-1]} examples.')
tasks.append(y.read().lower().count(b"{{header|"))
print(t.replace("_", " ") + f": {tasks[-1]} examples.")
print(f'\nTotal: {sum(tasks)} examples.')
print(f"\nTotal: {sum(tasks)} examples.")