WikiCrawler/MediaWiki/Formats/Article.cs
/// <summary>
/// Returns an enumerator over all pages that link to this one.
/// </summary>
Returns an enumerator over all pages that link to this one.
Returns an enumerator over all pages that link to this one .
public IEnumerable<Article> GetLinksHere(Api api)
		{
			string basedata = "format=json" +
				"&action=query" +
				"&titles=" + Api.UrlEncode(title) +
				"&prop=linkshere" +
				"&lhlimit=5000";
			string data = basedata + "&continue=";
			bool lhcontinue = false;
			do
			{
				HttpWebRequest request = api.CreateApiRequest();
				string json;
				using (StreamReader read = new StreamReader(EasyWeb.Post(request, data)))
				{
					json = read.ReadToEnd();
				}
				Dictionary<string, object> deser = (Dictionary<string, object>)new JavaScriptSerializer().DeserializeObject(json);
				Dictionary<string, object> query = (Dictionary<string, object>)deser["query"];
				Dictionary<string, object> pages = (Dictionary<string, object>)query["pages"];
				foreach (KeyValuePair<string, object> page in pages)
				{
					Dictionary<string, object> jsonData = (Dictionary<string, object>)page.Value;
					if (jsonData.ContainsKey("invalid"))
					{
						continue;
					}
					foreach (Dictionary<string, object> linkhere in (object[])jsonData["linkshere"])
					{
						yield return new Article(linkhere);
					}
				}
				lhcontinue = deser.ContainsKey("continue");
				if (lhcontinue)
				{
					Dictionary<string, object> continueData = (Dictionary<string, object>)deser["continue"];
					data = basedata;
					foreach (KeyValuePair<string, object> kv in continueData)
					{
						data += "&" + kv.Key + "=" + (string)kv.Value;
					}
				}
			}
			while (lhcontinue);
		}
public IEnumerable < Article > GetLinksHere ( Api api ) { string basedata = " " + " " + " " + Api . UrlEncode ( title ) + " " + " " ; string data = basedata + " " ; bool lhcontinue = false ; do { HttpWebRequest request = api . CreateApiRequest ( ) ; string json ; using ( StreamReader read = new StreamReader ( EasyWeb . Post ( request , data ) ) ) { json = read . ReadToEnd ( ) ; } Dictionary < string , object > deser = ( Dictionary < string , object > ) new JavaScriptSerializer ( ) . DeserializeObject ( json ) ; Dictionary < string , object > query = ( Dictionary < string , object > ) deser [ " " ] ; Dictionary < string , object > pages = ( Dictionary < string , object > ) query [ " " ] ; foreach ( KeyValuePair < string , object > page in pages ) { Dictionary < string , object > jsonData = ( Dictionary < string , object > ) page . Value ; if ( jsonData . ContainsKey ( " " ) ) { continue ; } foreach ( Dictionary < string , object > linkhere in ( object [ ] ) jsonData [ " " ] ) { yield return new Article ( linkhere ) ; } } lhcontinue = deser . ContainsKey ( " " ) ; if ( lhcontinue ) { Dictionary < string , object > continueData = ( Dictionary < string , object > ) deser [ " " ] ; data = basedata ; foreach ( KeyValuePair < string , object > kv in continueData ) { data += " " + kv . Key + " " + ( string ) kv . Value ; } } } while ( lhcontinue ) ; }
Returns an enumerator over all pages that link to this one.
Returns an enumerator over all pages that link to this one .
//Download stream //Read response
api
Api