Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,38 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue