Considering the privacy issue, we decided to divide the blog (Windows Live Space) In a sensitive document (in a specificCategory. This article describes how to useMetaweblog APIAndF #.
Windows Live SpaceOfAPIIs StandardMetaweblog API, SupportedGetpost, newpost, deletepostSuch basic operations generally requirePostid. So we only need to get what we want to delete.ArticleOfPostidYou can process them in batches.
But the problem is API There is no similar Getallposts , Similar to only Getrecentposts And get the most recent 20 . Therefore API We cannot know all the articles in Postid . I got stuck here for a while. But observe the latest 20 Articles Postid It can be found that it conforms to the following pattern:
5e76f306f39ccb3a!5038
5e76f306f39ccb3a!5027
5e76f306f39ccb3a!4936
............
The preceding strings are the same, and only the following numbers are changed. In this way, we provide an idea. We can manually observe the smallest part of the tribe.IDAnd the largestIDWhich generates similar candidates.PostidAnd then useGetpostIs this legal?Postid. The following is an easy task.
SoAlgorithmBasically:
Generate candidatesID
|>The filter is valid.ID
|>Filter to specifiedCategoryOfID
|>Delete!
Exploitation F # Asynchronous operations can concurrently process a large number I/O Request. Here we use Msdn Provided Metaweblogapi Implementation , And Xml-rpc.NET (Because Metaweblog API Is based on XML-RPC Protocol ). In the same way, batch migration can also be implemented, for example:CodeAs follows. Unfortunately, it seems that due to the limit on the number of concurrent connections on the Windows Live space server, the I/O acceleration effect is not very obvious (the acceleration ratio is about twice ).
Open System;
Open System. net;
Open System. IO;
Open Metaweblogapi;
Let Mutable Mw = New Msnspacesmetaweblog ();
Let Username = " Youroldusername " ;
Let Password = " Youroldsecretword " ;
MW. Credentials <- New Networkcredential (username, password );
Let Mutable Mw2 = New Msnspacesmetaweblog ();
Let Username2 = " Yournewusername " ;
Let Password2 = " Yournewsecretword "
Mw2.credentials <- New Networkcredential (username2, password2 );
Let Verifypostid id =
Async {
Try
Let Postid = " 5e76f306f39ccb3a! Or your own prefix " + Id. tostring ();
Let Post = mW. getpost (postid, username, password );
Printf " % S \ t " Post. postid;
Printfn " % S " Post. title;
Return post. postid;
With
| _ -> Return "" ;
}
Let Filterpost id =
Async {
Let Post = mW. getpost (ID, username, password );
If (Not (post. Title = "" ) & Post. Categories | > Array. exists ( Fun X -> X = " Your categary " )) Then
Printf " % S \ t " ID;
Printfn " % S " Post. title;
Return ID;
Else
Return "" ;
}
Let Copypost id =
Async {
Let Mutable Post = mW. getpost (ID, username, password );
Post. datecreated <- Datetime. now; // Or the server will return error that illegal Publish Date.
Mw2.newpost ( " Myblog " , Username2, password2, post, True ) | > Ignore;
Printf " % S \ t " Post. postid;
Printfn " % S " Post. title;
}
Let Deletepost id =
Async {
Let Post = mW. getpost (ID, username, password );
MW. deletepost ( " Myblog " , ID, username, password, True ) | > Ignore;
Printfn " % S " ID;
}
Printfn " Skim post IDs... " ;
Let IDS =
[ 114 .. 5366 ] // That depends on the ID range of your blog
| > List. Map ( Fun X -> Verifypostid X)
| > Async. Parallel
| > Async. runsynchronously
| > Array. Filter ( Fun X -> Not (x = "" ));
File. writealllines ( " Postids.txt " , IDS );
Printfn " Filter posts... " ;
Let Postidstocopy =
File. readalllines ( " Postids.txt " )
| > Array. Map ( Fun X -> Filterpost X)
| > Async. Parallel
| > Async. runsynchronously;
File. writealllines ( " Postidstocopy.txt " , Postidstocopy );
Printfn " Copy posts... " ;
File. readalllines ( " Postidstocopy.txt " )
| > Array. Map ( Fun X -> Copypost X)
| > Async. Parallel
| > Async. runsynchronously
| > Ignore;
Printfn " Deleting old posts... "
File. readalllines ( " Postidstocopy.txt " )
| > Array. Map ( Fun X -> Deletepost X)
| > Async. Parallel
| > Async. runsynchronously
| > Ignore;