Wikipedia:Projekt DotNetWikiBot Framework/Lsjbot/Lsj-standardsortering

Från Wikipedia
//Code for extracting all pages in a category that lacks {{defaultsort}} or {{standardsortering}}
//
//Originally from [[Wikipedia:Projekt DotNetWikiBot Framework/Innocent bot/Ny parameter i Mall Ishockeyspelare]]
//Extensively modified by Lsj

using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using System.Threading;
using System.Web;
using System.Net;
using DotNetWikiBot;

class MyBot : Bot
{
    public static void Main()
        {
        Console.Write("Password: ");
        string password = Console.ReadLine();
        string botkonto = "Lsjbot";
        Site site = new Site("http://sv.wikipedia.org", botkonto, password);
        
        PageList pl = new PageList(site);

        //Select how to get pages. Uncomment as needed.

        //Find articles from a category
        //pl.FillAllFromCategory("Män");
        pl.FillAllFromCategory("Kvinnor");

        //Find articles from all the links to a template, mostly useful on very small wikis
        //        pl.FillFromLinksToPage("Mall:Taxobox");

        //Set specific article:
        //Page pp = new Page(site, "Iloilo City");pl.Add(pp);

        //Skip all namespaces except articles:
        pl.RemoveNamespaces(new int[] {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,100,101});
		int räknare = 0;

        
        Page pwork = new Page(site, "Användare:"+botkonto+"/UtansorteringKvinnor2");
        pwork.Load();
        pwork.text += "\n\n==Ny körning datum==\n";
                
                foreach(Page p in pl)
                {
            try
            {
                p.Load();
            }
            catch (WebException e)
            {
                Console.WriteLine(e.Message);
                continue;
            }
            if (p.text.IndexOf("standardsortering", StringComparison.OrdinalIgnoreCase) < 0)
                if (p.text.IndexOf("defaultsort", StringComparison.OrdinalIgnoreCase) < 0)
				{
                    pwork.text += "\n* [[" + p.title + "]]";
					räknare++;
				}

        }

        bool saved = false;
        while (!saved)
        {
            try
            {
                pwork.Save(pwork.text, räknare.ToString()+" artiklar som saknar standardsortering", false);
                saved = true;
            }
            catch (WebException e)
            {
                Console.WriteLine(e.Message);

            }
        }
        }
}