/// <summary> /// Do a search for the contents of the specified URL /// </summary> /// <param name="url"></param> /// <returns></returns> public static CandidateResponse SearchFor(string text, int numResults = 2) { WebClient wc = new WebClient(); wc.Headers.Add("user-agent", "GeocodeExample"); wc.Headers.Add("referer", "GeocodeExample"); wc.Encoding = System.Text.Encoding.UTF8; CandidateResponse geocodeResult = null; using (StreamReader sr = new StreamReader(wc.OpenRead(new Geocode.GeocodeURI(text, numResults).Uri), System.Text.Encoding.UTF8, true)) { string response = sr.ReadToEnd(); if (ResponseIsError(response)) { //throw throw new System.ApplicationException(response); } geocodeResult = ObjectSerialization.JsonToObject <CandidateResponse>(response); } return(geocodeResult); }