Esempio n. 1
0
        public string GetContent(string title, int revId = -1)
        {
            // returns the content of the given page
            // if revId not -1, then search by revId, otherwise search by title

            string cond   = revId > -1 ? "&revids=" + revId : "&titles=" + title;
            string result = client.DownloadString(apiQueryLink + cond + contentProperties + format + encoding);

            try
            {
                var revisions = JSONUtils.DeserializeRevisions(result);
                return((string)((Dictionary <string, object>)revisions.GetValue(0))["*"]);
            }
            catch (WikiAPIException exp)
            {
                return("Wrong wikipedia page.");
            }
        }
Esempio n. 2
0
        public int GetDiff(int fromRev, int torev)
        {
            // returns the diff of the page between to revisions

            if (fromRev <= 0)
            {
                // There is no revision yet
                return(int.MaxValue);
            }

            string url    = apiCompareLink + "&fromrev=" + fromRev + "&torev=" + torev + format + encoding;
            string result = client.DownloadString(url);

            try
            {
                LastDiff = JSONUtils.DeserializeCompare(result);
                return(LastDiff.Length);
            }
            catch (WikiAPIException exp)
            {
                return(-1);
            }
        }