用户:Cheng chai fung/program/C++/copy template convert.cpp
外观
#include <stdio.h>
#using "DotNetWikiBot.dll"
using namespace System;
using namespace DotNetWikiBot;
ref class BotScript : Bot
{
public:
Site ^WikiSite_copy;
Site ^WikiSite_paste;
PageList ^pl;
void active(int pageNum)
{
Page ^p = gcnew Page(WikiSite_paste, pl[pageNum]->title);
p->Load();
if(p->IsEmpty())
{
pl[pageNum]->Load();
pl[pageNum]->ShowText();
p->Save(pl[pageNum]->text);
Wait(10);
}
}
};
void main()
{
BotScript bot;
char *URL1 = "http://en.wikipedia.org/", *Botname = new char[256], *Password = new char[256];
printf("\tBotname: ");
scanf_s("%s", Botname, 256);
printf("\tPassword: ");
scanf_s("%s", Password, 256);
bot.WikiSite_copy = gcnew Site(%String(URL1), %String(Botname), %String(Password));
char *URL2 = "http://wikicn.playgoteam.workers.dev/";
bot.WikiSite_paste = gcnew Site(%String(URL2), %String(Botname), %String(Password));
bot.pl = gcnew PageList(bot.WikiSite_copy);
bot.pl->FillFromCategory("Subtemplates of Template Convert");
int totalPageNum = bot.pl->Count();
for(int i = 0; i < totalPageNum; i++)
{
printf("\tBot action...\n");
bot.active(i);
}
delete bot.pl;
delete bot.WikiSite_copy;
delete bot.WikiSite_paste;
delete [] Botname;
delete [] Password;
}