public async Task <ForumReply> GetReplyCookiesAsync(long threadId = 0, long postId = 0, CancellationToken token = default) { if (threadId == 0 && postId == 0) { throw new FormatException(Awful.Core.Resources.ExceptionMessages.ThreadAndPostIdMissing); } string url; url = threadId > 0 ? string.Format(CultureInfo.InvariantCulture, EndPoints.ReplyBase, threadId) : string.Format(CultureInfo.InvariantCulture, EndPoints.QuoteBase, postId); var result = await this.webManager.GetDataAsync(url, token).ConfigureAwait(false); var document = await this.webManager.Parser.ParseDocumentAsync(result.ResultHtml, token).ConfigureAwait(false); var inputs = document.QuerySelectorAll("input"); var posts = ThreadHandler.ParsePreviousPosts(document); var forumReplyEntity = new ForumReply(); string quote = System.Net.WebUtility.HtmlDecode(document.QuerySelector("textarea").TextContent); forumReplyEntity.MapThreadInformation( inputs["formkey"].GetAttribute("value"), inputs["form_cookie"].GetAttribute("value"), quote, inputs["threadid"].GetAttribute("value")); forumReplyEntity.ForumPosts.AddRange(posts); return(forumReplyEntity); }
public async Task <ForumReply> GetReplyCookiesAsync(long threadId = 0, long postId = 0) { if (threadId == 0 && postId == 0) { return(new ForumReply()); } string url; url = threadId > 0 ? string.Format(EndPoints.ReplyBase, threadId) : string.Format(EndPoints.QuoteBase, postId); var result = await _webManager.GetDataAsync(url); var document = _webManager.Parser.Parse(result.ResultHtml); var inputs = document.QuerySelectorAll("input"); var posts = ThreadHandler.ParsePreviousPosts(document); var forumReplyEntity = new ForumReply(); string quote = System.Net.WebUtility.HtmlDecode(document.QuerySelector("textarea").TextContent); forumReplyEntity.MapThreadInformation( inputs["formkey"].GetAttribute("value"), inputs["form_cookie"].GetAttribute("value"), quote, inputs["threadid"].GetAttribute("value") ); forumReplyEntity.ForumPosts = posts; return(forumReplyEntity); }