Exemplo n.º 1
0
        public async Task<HtmlDocument> GetThread(ForumThreadEntity forumThread, string url)
        {
            WebManager.Result result = await _webManager.GetData(url);
            HtmlDocument doc = result.Document;
            try
            {
                forumThread.ParseFromThread(doc);
            }
            catch (Exception)
            {
                return null;
            }
            string responseUri = result.AbsoluteUri;
            string[] test = responseUri.Split('#');
            if (test.Length > 1 && test[1].Contains("pti"))
            {
                forumThread.ScrollToPost = Int32.Parse(Regex.Match(responseUri.Split('#')[1], @"\d+").Value) - 1;
                forumThread.ScrollToPostString = string.Concat("#", responseUri.Split('#')[1]);
            }

            var query = Extensions.ParseQueryString(url);

            if (!query.ContainsKey("postid")) return doc;

            // If we are going to a post, it won't use #pti but instead uses the post id.

            forumThread.ScrollToPost = Convert.ToInt32(query["postid"]);
            forumThread.ScrollToPostString = "#postId" + query["postid"];
            return doc;

        }
Exemplo n.º 2
0
        public async Task<ForumThreadEntity> GetThread(string url)
        {
            var forumThread = new ForumThreadEntity();
            WebManager.Result result = await _webManager.GetData(url);
            HtmlDocument doc = result.Document;
            try
            {
                forumThread.ParseFromThread(doc);
            }
            catch (Exception)
            {
                return null;
            }
            var query = Extensions.ParseQueryString(url);
            if (!query.ContainsKey("postid")) return forumThread;

            // If we are going to a post, it won't use #pti but instead uses the post id.

            forumThread.ScrollToPost = Convert.ToInt32(query["postid"]);
            forumThread.ScrollToPostString = "#post" + query["postid"];
            return forumThread;

        }