WikiCrawler/MediaWiki/Api.cs
/// <summary>
/// Searches for entities with the specified title.
/// </summary>
Searches for entities with the specified title.
Searches for entities with the specified title .
public string[] SearchEntities(string search, string language = "en")
		{
			string baseQuery = "format=json"
				+ "&action=wbsearchentities"
				+ "&type=item"
				+ "&search=" + UrlEncode(search);
			if (!string.IsNullOrEmpty(language))
			{
				baseQuery += "&language=" + UrlEncode(language);
			}
			HttpWebRequest request = CreateApiRequest(baseQuery);
			string json;
			using (StreamReader read = new StreamReader(EasyWeb.GetResponseStream(request)))
			{
				json = read.ReadToEnd();
			}
			Dictionary<string, object> deser = (Dictionary<string, object>)new JavaScriptSerializer().DeserializeObject(json);
			object[] searchJson = (object[])deser["search"];
			string[] results = new string[searchJson.Length];
			for (int c = 0; c < searchJson.Length; c++)
			{
				results[c] = (string)((Dictionary<string, object>)searchJson[c])["id"];
			}
			return results;
		}
public string [ ] SearchEntities ( string search , string language = " " ) { string baseQuery = " " + " " + " " + " " + UrlEncode ( search ) ; if ( ! string . IsNullOrEmpty ( language ) ) { baseQuery += " " + UrlEncode ( language ) ; } HttpWebRequest request = CreateApiRequest ( baseQuery ) ; string json ; using ( StreamReader read = new StreamReader ( EasyWeb . GetResponseStream ( request ) ) ) { json = read . ReadToEnd ( ) ; } Dictionary < string , object > deser = ( Dictionary < string , object > ) new JavaScriptSerializer ( ) . DeserializeObject ( json ) ; object [ ] searchJson = ( object [ ] ) deser [ " " ] ; string [ ] results = new string [ searchJson . Length ] ; for ( int c = 0 ; c < searchJson . Length ; c ++ ) { results [ c ] = ( string ) ( ( Dictionary < string , object > ) searchJson [ c ] ) [ " " ] ; } return results ; }
Searches for entities with the specified title.
Searches for entities with the specified title .
//Parse and read
search
string
language
string