Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,13 @@
|
|||
import requests
|
||||
import re
|
||||
|
||||
response = requests.get("http://rosettacode.org/wiki/Category:Programming_Languages").text
|
||||
languages = re.findall('title="Category:(.*?)">',response)[:-3] # strip last 3
|
||||
|
||||
response = requests.get("http://rosettacode.org/mw/index.php?title=Special:Categories&limit=5000").text
|
||||
response = re.sub('(\d+),(\d+)',r'\1'+r'\2',response) # strip ',' from popular languages above 999 members
|
||||
members = re.findall('<li><a[^>]+>([^<]+)</a>[^(]*[(](\\d+) member[s]*[)]</li>',response) # find language and members
|
||||
|
||||
for cnt, (language, members) in enumerate(sorted(members, key=lambda x: -int(x[1]))[:15]): # show only top 15 languages
|
||||
if language in languages:
|
||||
print("{:4d} {:4d} - {}".format(cnt+1, int(members), language))
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
import requests
|
||||
import operator
|
||||
import re
|
||||
|
||||
api_url = 'http://rosettacode.org/mw/api.php'
|
||||
languages = {}
|
||||
|
||||
parameters = {
|
||||
'format': 'json',
|
||||
'action': 'query',
|
||||
'generator': 'categorymembers',
|
||||
'gcmtitle': 'Category:Programming Languages',
|
||||
'gcmlimit': '200',
|
||||
'gcmcontinue': '',
|
||||
'continue': '',
|
||||
'prop': 'categoryinfo'
|
||||
}
|
||||
|
||||
while(True):
|
||||
response = requests.get(api_url, params=parameters).json()
|
||||
for k,v in response['query']['pages'].items():
|
||||
if 'title' in v and 'categoryinfo' in v:
|
||||
languages[v['title']]=v['categoryinfo']['size']
|
||||
if 'continue' in response:
|
||||
gcmcontinue = response['continue']['gcmcontinue']
|
||||
# print(gcmcontinue)
|
||||
parameters.update({'gcmcontinue': gcmcontinue})
|
||||
else:
|
||||
break
|
||||
|
||||
# report top 15 languages
|
||||
for i, (language, size) in enumerate(sorted(languages.items(), key=operator.itemgetter(1), reverse=True)[:15]):
|
||||
print("{:4d} {:4d} - {}".format(i+1, size, re.sub('Category:','',language))) # strip Category: from language
|
||||
Loading…
Add table
Add a link
Reference in a new issue