30 lines
1.1 KiB
Text
30 lines
1.1 KiB
Text
-include "url.sno"
|
|
http.recl = "K,32767" ;* Read next 32767 characters
|
|
;* of very long lines.
|
|
|
|
rclangs = "http://rosettacode.org/mw/api.php?"
|
|
+ "format=xml&action=query&generator=categorymembers&"
|
|
+ "gcmtitle=Category:Programming%20Languages&"
|
|
+ "gcmlimit=500&prop=categoryinfo"
|
|
|
|
languagepat = arb "<page" arb 'title="Category:'
|
|
+ break('"') . lang arb 'pages="' break('"') . count
|
|
|
|
langtable = table(500, 20)
|
|
|
|
url.open(.fin, rclangs, http.recl) :s(read)
|
|
output = "Cannot open rosettacode site." :(end)
|
|
|
|
read line = line fin :f(done)
|
|
get line languagepat = :f(read)
|
|
langtable<syntaxhighlight lang="text"> = langtable<syntaxhighlight lang="text"> + count :(get)
|
|
|
|
done langarray = rsort(langtable,2) :s(write)
|
|
output = "No languages found." :(end)
|
|
|
|
write n = n + 1
|
|
output = lpad(n ". ", 5) lpad(langarray<n, 2>, 4)
|
|
+ " - " langarray<n,1> :s(write)
|
|
|
|
url.close(.fin)
|
|
end
|