/// <summary> /// /// </summary> /// <param name="action"></param> /// <param name="topic"></param> /// <param name="convertor"></param> /// <returns></returns> public mediawiki QueryServerArticle(string action, string topic) { String endpoint = String.Format("http://en.wikipedia.org/w/api.php?action={0}&titles={1}&export&exportnowrap", action, topic); mediawiki mediaWiki = ProcessArticleQuery(endpoint); return(mediaWiki); }
/// <summary> /// /// </summary> /// <param name="endpoint"></param> /// <returns></returns> private mediawiki ProcessArticleQuery(string endpoint) { HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(endpoint); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); XmlSerializer serializer = new XmlSerializer(typeof(mediawiki)); mediawiki mediaWiki = (mediawiki)serializer.Deserialize(response.GetResponseStream()); return(mediaWiki); }
/// <summary> /// /// </summary> /// <param name="topic"></param> /// <returns></returns> public ArticleInfo GetArticle(String topic, Boolean getHtml) { if (this.IsArticleAvailable(topic)) { ArticleInfo articleInfo = new ArticleInfo(); mediawiki mediaWiki = queryEngine.QueryServerArticle("query", topic); String[] articleParts = xsd.XSDConvert.Instance.Convert(mediaWiki); articleInfo.Title = articleParts[0]; articleInfo.Url = articleParts[1]; articleInfo.ArticleTextRaw = articleParts[2]; articleInfo.Introduction = articleParts[3]; if (getHtml) { String htmlStr = queryEngine.QueryServerArticleHtml(articleInfo.Url); articleInfo.ArticleHtml = xsd.XSDConvert.Instance.ConvertToHtml(htmlStr); } return(articleInfo); } return(null); }