WikiCrawler/MediaWiki/Api.cs
/// <summary>
/// Returns contributions for the specified user.
/// </summary>
/// <param name="ucuser">The name of the user (exclude 'User:')</param>
Returns contributions for the specified user.
Returns contributions for the specified user .
public IEnumerable<Contribution> GetContributions(string ucuser, string ucstart, string ucend, int uclimit = Limit.Max)
		{
			ucuser = UrlEncode(ucuser);
			string baseQuery = "format=json" +
				"&action=query" +
				"&list=usercontribs" +
				"&ucuser=" + UrlEncode(ucuser) +
				"&ucstart=" + UrlEncode(ucstart) +
				"&ucend=" + UrlEncode(ucend);
			if (uclimit != Limit.Unspecified)
			{
				baseQuery += "&uclimit=" + GetLimitParameter(uclimit);
			}
			string query = baseQuery + "&continue=";
			bool doContinue = false;
			do
			{
				HttpWebRequest request = CreateApiRequest();
				string json;
				using (StreamReader read = new StreamReader(EasyWeb.Post(request, query)))
				{
					json = read.ReadToEnd();
				}
				Dictionary<string, object> deser = (Dictionary<string, object>)new JavaScriptSerializer().DeserializeObject(json);
				foreach (Dictionary<string, object> page in (object[])((Dictionary<string, object>)deser["query"])["usercontribs"])
				{
					yield return new Contribution(page);
				}
				doContinue = deser.ContainsKey("continue");
				if (doContinue)
				{
					Dictionary<string, object> continueData = (Dictionary<string, object>)deser["continue"];
					query = baseQuery;
					foreach (KeyValuePair<string, object> kv in continueData)
					{
						query += "&" + kv.Key + "=" + (string)kv.Value;
					}
				}
			}
			while (doContinue);
		}
public IEnumerable < Contribution > GetContributions ( string ucuser , string ucstart , string ucend , int uclimit = Limit . Max ) { ucuser = UrlEncode ( ucuser ) ; string baseQuery = " " + " " + " " + " " + UrlEncode ( ucuser ) + " " + UrlEncode ( ucstart ) + " " + UrlEncode ( ucend ) ; if ( uclimit != Limit . Unspecified ) { baseQuery += " " + GetLimitParameter ( uclimit ) ; } string query = baseQuery + " " ; bool doContinue = false ; do { HttpWebRequest request = CreateApiRequest ( ) ; string json ; using ( StreamReader read = new StreamReader ( EasyWeb . Post ( request , query ) ) ) { json = read . ReadToEnd ( ) ; } Dictionary < string , object > deser = ( Dictionary < string , object > ) new JavaScriptSerializer ( ) . DeserializeObject ( json ) ; foreach ( Dictionary < string , object > page in ( object [ ] ) ( ( Dictionary < string , object > ) deser [ " " ] ) [ " " ] ) { yield return new Contribution ( page ) ; } doContinue = deser . ContainsKey ( " " ) ; if ( doContinue ) { Dictionary < string , object > continueData = ( Dictionary < string , object > ) deser [ " " ] ; query = baseQuery ; foreach ( KeyValuePair < string , object > kv in continueData ) { query += " " + kv . Key + " " + ( string ) kv . Value ; } } } while ( doContinue ) ; }
Returns contributions for the specified user.
Returns contributions for the specified user .
//Encode page names //Read response
ucuser
string
The name of the user (exclude 'User:')
The name of the user ( exclude ' User : ' )
ucstart
string
ucend
string
uclimit
int