Ejemplo n.º 1
0
        public Dictionary <int, XRoot> FetchPages(int[] pageids)
        {
            var request = new RestRequest("api.php");

            request.AddParameter("action", "query");
            request.AddParameter("prop", "revisions");
            request.AddParameter("rvprop", "content");
            request.AddParameter("rvgeneratexml", "1");
            request.AddParameter("rvparse", "1");
            request.AddParameter("format", "xml");
            request.AddParameter("pageids", String.Join("|", pageids));

            var response = API.Execute(request);
            var xml      = new XmlDocument();

            xml.LoadXml(response.Content);

            var dict = new Dictionary <int, XRoot>();

            foreach (XmlNode page in xml.SelectNodes("//api/query/pages/page"))
            {
                var pageid  = int.Parse(page.Attributes["pageid"].Value);
                var rootXML = page.SelectSingleNode("revisions/rev/@parsetree").Value;
                dict.Add(pageid, WikiParse.ParseXML(Regex.Replace(rootXML, @"\t|\n|\r", "")));
            }

            return(dict);
        }
Ejemplo n.º 2
0
        public XRoot FetchPage(int pageid)
        {
            var request = new RestRequest("api.php");

            request.AddParameter("action", "query");
            request.AddParameter("prop", "revisions");
            request.AddParameter("rvprop", "content");
            request.AddParameter("rvgeneratexml", "1");
            request.AddParameter("rvparse", "1");
            request.AddParameter("format", "xml");
            request.AddParameter("pageids", pageid);

            var response = API.Execute(request);

            var xml = new XmlDocument();

            xml.LoadXml(response.Content);
            var rootXML = xml.SelectSingleNode("//api/query/pages/page/revisions/rev/@parsetree").Value;

            return(WikiParse.ParseXML(Regex.Replace(rootXML, @"\t|\n|\r", "")));
        }