39 lines
1.2 KiB
Plaintext
39 lines
1.2 KiB
Plaintext
use HTTP;
|
|
use XML;
|
|
|
|
class RosettaCount {
|
|
function : Main(args : String[]) ~ Nil {
|
|
taks_xml := HttpGet("http://rosettacode.org/mw/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml");
|
|
parser := XmlParser->New(taks_xml);
|
|
if(parser->Parse()) {
|
|
task_names := parser->FindElements("/api/query/categorymembers/cm");
|
|
if(task_names <> Nil) {
|
|
each(i : task_names) {
|
|
task_name := task_names->Get(i)->As(XmlElement)->GetAttribute("title")->GetValue();
|
|
task_url := "http://rosettacode.org/mw/index.php?title=";
|
|
task_url->Append(task_name);
|
|
task_url->Append("&action=raw");
|
|
|
|
task := HttpGet(task_url);
|
|
counts := task->FindAll("=={{header|");
|
|
if(counts->Size() > 0) {
|
|
IO.Console->Print(UrlUtility->Decode(task_name))->Print(": ")->PrintLine(counts->Size());
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|
|
|
|
function : HttpGet(url : String) ~ String {
|
|
xml := "";
|
|
|
|
client := HttpClient->New();
|
|
lines := client->Get(url);
|
|
each(i : lines) {
|
|
xml->Append(lines->Get(i)->As(String));
|
|
};
|
|
|
|
return xml;
|
|
}
|
|
}
|