Exemple #1
0
        public static LogListing GetModerationLog(Session session, string sub)
        {
            var request = new Request
            {
                Url    = "http://www.reddit.com/r/" + sub + "/about/log/",
                Method = "GET",
                Cookie = session.Cookie
            };

            var html = string.Empty;

            if (request.Execute(out html) != System.Net.HttpStatusCode.OK)
            {
                throw new RedditException(html);
            }

            // build JSON?

            return(LogListing.FromHtml(html));
        }
Exemple #2
0
        internal static LogListing FromHtml(string html)
        {
            var list    = new LogListing();
            var client  = NSoup.NSoupClient.Parse(html);
            var entries = client.Select("#siteTable table tr.modactions");

            foreach (var entry in entries)
            {
                // entry.Select(
                list.Add(new Log
                {
                    Timestamp   = Convert.ToDateTime(entry.Select("td.timestamp time").Attr("datetime")),
                    Moderator   = entry.Select("td a").First().Text(),
                    Action      = entry.Select("td.button a").Attr("class").Replace("modactions", string.Empty).Trim(),
                    Description = entry.Select("td.description").Text
                });
            }
            // iden = client.Select("#compose-message input[name=iden]").Val();
            // captcha = client.Select("#compose-message img.capimage").Attr("src");

            return(list);
        }