Anonymous user
Rosetta Code/Count examples: Difference between revisions
m
bugfix
(added c#) |
m (bugfix) |
||
Line 44:
class Program {
static List<string> GetTitlesFromCategory(string category, WebClient wc) {
string content =
String.Format("http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:{0}&cmlimit=500&format=json", category)
);
return new Regex("\"title\":\"(.+?)\"").Matches(content).Cast<Match>().Select(x => x.Groups[1].Value.Replace("\\/", "/")).ToList();
}
static string GetSourceCodeFromPage(string page, WebClient wc) {
return
String.Format("http://www.rosettacode.org/w/index.php?title={0}&action=raw", page)
);
Line 59:
static void Main(string[] args) {
WebClient wc = new WebClient();
List<Task> tasks = new List<Task>();
List<string> tasknames = GetTitlesFromCategory("Programming_Tasks", wc);
foreach (string task in tasknames) {
string content = GetSourceCodeFromPage(task, wc);
int count = new Regex("=={{header", RegexOptions.IgnoreCase).Matches(content).Count;
Task t = new Task(task, count);
|