DotNetWikiBot

MIT
C#
Windows
2010-02-02
红薯

DotNetWikiBot Framework 是一个全功能的客户端API和一个控制台应用,用来构建抓取基于 MediaWiki 网站的爬虫,采用 .NET 开发。

示例代码:

using DotNetWikiBot;	// Reference DotNetWikiBot namespace for easy access

class MyBot : Bot // Derive your bot class from framework's Bot class
{
public static void Main()
{
// Firstly make Site object, specifying site's URL and your bot account
Site enWiki = new Site("http://en.wikipedia.org", "myBotLogin", "myPassword");
// Then make Page object, specifying site and page title in constructor
Page p = new Page(enWiki, "Art");
// Load actual page text from live wiki
p.Load();
// Add "Visual arts" category link to "Art" page's text
p.AddToCategory("Visual arts");
// Save "Art" article's text back to live wiki with specified comment
p.Save("comment: category link added", true);

// Make empty PageList object, representing collection of pages
PageList pl = new PageList(enWiki);
// Fill it with 100 pages, where "nuclear disintegration" is mentioned
pl.FillFromGoogleSearchResults("nuclear disintegration", 100);
// Load texts and metadata of all found pages from live wiki
pl.LoadEx();
// Now suppose, that we must correct some typical mistake in all our pages
foreach (Page i in pl)
// In each page we will replace one phrase with another
i.text = i.text.Replace("fusion products", "fission products");
// Finally we'll save all changed pages to wiki with 5 seconds interval
pl.SaveSmoothly(5, "comment: mistake autocorrection", true);

// Now clear our PageList so we could re-use it
pl.Clear();
// Fill it with all articles in "Astronomy" category and it's subcategories
pl.FillFromCategoryTree("Astronomy");
// Download and save all PageList's articles to specified local XML file
pl.SaveXMLDumpToFile("Dumps\\ArticlesAboutAstronomy.xml");
}
}
加载中

评论(0)

暂无评论

DotNetWikiBot Framework 3.10 发布

DotNetWikiBot Framework 3.10 发布,此版本更新内容如下: 修复了页面重命名,防御和检测方面的问题 修复了模板的解析和修改功能 先进高级的缓存系统 DotNetWikiBot Framework 是一个全功能...

2014/01/16 08:34

DotNetWikiBot 框架发布 2.9 版本

DotNetWikiBot Framework 是一个全功能的客户端API和一个控制台应用,用来构建抓取基于 MediaWiki 网站的爬虫,采用 .NET 开发。 Changes: 1. Critical updates were made to the Login() fu...

2010/04/10 19:18

没有更多内容

加载失败,请刷新页面

没有更多内容

暂无问答

暂无博客

返回顶部
顶部