static async Task HelloRecentChanges() { // Create a MediaWiki API client. var wikiClient = new WikiClient(); // Create a MediaWiki Site instance. var site = new WikiSite(wikiClient, "https://en.wikipedia.org/w/api.php"); await site.Initialization; var rcg = new RecentChangesGenerator(site) { TypeFilters = RecentChangesFilterTypes.Create, PaginationSize = 50, // We already know we're not going to fetch results as many as 500 or 5000 // so this will help. }; // List the 10 latest new pages var pages = await rcg.EnumPagesAsync().Take(10).ToList(); Console.WriteLine("New pages"); foreach (var p in pages) { Console.WriteLine("{0, -30} {1, 8}B {2}", p, p.ContentLength, p.LastTouched); } // List the 10 latest recent changes rcg.TypeFilters = RecentChangesFilterTypes.All; var rcs = await rcg.EnumItemsAsync().Take(10).ToList(); Console.WriteLine(); Console.WriteLine("Recent changes"); foreach (var rc in rcs) { Console.WriteLine(rc); } }
public async Task WpTest2RecentChangesGeneratorTest1() { var site = await WpTest2SiteAsync; var generator = new RecentChangesGenerator(site) { LastRevisionsOnly = true, PaginationSize = 20 }; var pages = await generator.EnumPagesAsync().Take(1000).ToList(); TracePages(pages); AssertTitlesDistinct(pages); }
public async Task WikiaRecentChangesGeneratorTest1() { var site = await WikiaTestSiteAsync; var generator = new RecentChangesGenerator(site) { LastRevisionsOnly = true, TypeFilters = RecentChangesFilterTypes.Edit, PaginationSize = 500 }; var pages = await generator.EnumPagesAsync().Take(2000).ToList(); TracePages(pages); // Sometimes the assertion fails for wikia. AssertTitlesDistinct(pages); }
public async Task WpLzhRecentChangesGeneratorTest1() { var site = await WpLzhSiteAsync; var generator = new RecentChangesGenerator(site) { LastRevisionsOnly = true, // BotFilter = PropertyFilterOption.WithProperty, MinorFilter = PropertyFilterOption.WithProperty, AnonymousFilter = PropertyFilterOption.WithoutProperty, TypeFilters = RecentChangesFilterTypes.Create | RecentChangesFilterTypes.Edit, }; var pages = await generator.EnumPagesAsync(PageQueryOptions.FetchContent).Take(100).ToList(); TracePages(pages); AssertTitlesDistinct(pages); foreach (var p in pages) { var flags = p.LastRevision.Flags; Assert.True(flags != RevisionFlags.None); Assert.False(flags.HasFlag(RevisionFlags.Anonymous)); Assert.True(flags.HasFlag(RevisionFlags.Minor)); } }