Пример #1
0
        public bool WriteComment(DCInsideArticle article, string text, CancellationToken ct)
        {
            if (article.CommentUserID.Length == 0)
            {
                // 한번만 더 시도하고, (이전에 로그인을 안했을 수도 있으므로)
                string dummyText;
                if (!GetArticleText(article, ct, out dummyText))
                {
                    return(false);
                }

                // 그래도 commentUserID를 얻지 못했다면
                if (article.CommentUserID.Length == 0)
                {
                    return(false);
                }
            }

            DCViewWebClient webClient = new DCViewWebClient();

            webClient.Headers["Content-Type"] = "application/x-www-form-urlencoded";
            webClient.Headers["Referer"]      = string.Format("http://m.dcinside.com/view.php?id={0}&no={1}", id, article.ID);
            string data = string.Format(
                "id={0}&no={1}&comment_memo={2}&mode=comment&user_no={3}",
                HttpUtility.UrlEncode(id),
                HttpUtility.UrlEncode(article.ID),
                HttpUtility.UrlEncode(text),
                article.CommentUserID
                );

            var result = webClient.UploadStringAsyncTask(new Uri("http://m.dcinside.com/_option_write.php", UriKind.Absolute), "POST", data, ct).GetResult();

            return(true);
        }
Пример #2
0
        private List <DCInsideArticle> GetArticleListFromString(string input)
        {
            List <DCInsideArticle> result = new List <DCInsideArticle>();
            var sr = new StringReader(input);

            string line = null;

            while ((line = sr.ReadLine()) != null)
            {
                if (!line.Contains("\"list_picture_a\""))
                {
                    continue;
                }

                string line2 = sr.ReadLine();

                DCInsideArticle article = new DCInsideArticle(this);

                // Number
                Match matchGetNumber = DCRegexManager.ListArticleNumber.Match(line);
                if (!matchGetNumber.Success)
                {
                    break;
                }
                article.ID = matchGetNumber.Groups[1].Value;

                Match matchArticleData = DCRegexManager.ListArticleData.Match(line2);
                if (!matchArticleData.Success)
                {
                    continue;
                }

                // HasImage
                article.HasImage     = matchArticleData.Groups[3].Length != 0;
                article.Title        = matchArticleData.Groups[4].Value;
                article.CommentCount = matchArticleData.Groups[5].Length == 0 ? 0 : int.Parse(matchArticleData.Groups[6].Value);
                article.Name         = matchArticleData.Groups[7].Value.Trim();
                article.Date         = DateTime.Parse(matchArticleData.Groups[9].Value);

                if (line2.Contains("gallercon.gif"))
                {
                    article.MemberStatus = MemberStatus.Fix;
                }
                else if (line2.Contains("gallercon1.gif"))
                {
                    article.MemberStatus = MemberStatus.Default;
                }
                else
                {
                    article.MemberStatus = MemberStatus.Anonymous;
                }


                result.Add(article);
            }

            return(result);
        }
Пример #3
0
        private List <DCInsideArticle> GetArticleListFromString(string input)
        {
            List <DCInsideArticle> result = new List <DCInsideArticle>();
            var sr = new StringReader(input);

            string line = null;

            while ((line = sr.ReadLine()) != null)
            {
                if (!line.Contains("\"list_picture_a\""))
                {
                    continue;
                }

                string line2 = sr.ReadLine();

                DCInsideArticle article = new DCInsideArticle(board);

                // Number
                Match matchGetNumber = DCRegexManager.SearchListArticleNumber.Match(line);
                if (!matchGetNumber.Success)
                {
                    break;
                }
                article.ID = matchGetNumber.Groups[1].Value;

                Match matchArticleData = DCRegexManager.SearchListArticleData.Match(line2);
                if (!matchArticleData.Success)
                {
                    continue;
                }

                // HasImage
                article.HasImage     = matchArticleData.Groups[3].Length != 0;
                article.Title        = HttpUtility.HtmlDecode(HtmlParser.StripTags(matchArticleData.Groups[4].Value)).Trim();
                article.CommentCount = matchArticleData.Groups[5].Length == 0 ? 0 : int.Parse(matchArticleData.Groups[6].Value);
                article.Name         = HttpUtility.HtmlDecode(HtmlParser.StripTags(matchArticleData.Groups[7].Value)).Trim();
                article.Date         = DateTime.Parse(matchArticleData.Groups[9].Value);

                result.Add(article);
            }

            return(result);
        }
Пример #4
0
        public bool WriteCommentNonmember(DCInsideArticle article, string text, CancellationToken ct)
        {
            DCViewWebClient webClient = new DCViewWebClient();

            webClient.Headers["Content-Type"] = "application/x-www-form-urlencoded";
            webClient.Headers["Referer"]      = string.Format("http://m.dcinside.com/view.php?id={0}&no={1}", id, article.ID);

            string data = string.Format(
                "id={0}&no={1}&comment_nick={2}&comment_pw={3}&comment_memo={4}&mode=comment_nonmember",
                HttpUtility.UrlEncode(id),
                HttpUtility.UrlEncode(article.ID),
                HttpUtility.UrlEncode("testid"),
                HttpUtility.UrlEncode("testpw"),
                HttpUtility.UrlEncode(text)
                );

            webClient.UploadStringAsyncTask(new Uri("http://m.dcinside.com/_option_write.php", UriKind.Absolute), "POST", data, ct).GetResult();
            return(true);
        }
Пример #5
0
        public bool GetArticleText(DCInsideArticle article, CancellationToken ct, out string text)
        {
            DCViewWebClient webClient = new DCViewWebClient();
            string          url       = string.Format("http://m.dcinside.com/view.php?id={0}&no={1}&nocache={2}", id, article.ID, DateTime.Now.Ticks);

            string result = webClient.DownloadStringAsyncTask(new Uri(url, UriKind.Absolute), ct).GetResult();

            List <Picture>         pictures;
            List <DCInsideComment> comments;
            string commentUserID;

            if (!UpdateArticleTextAndComments(result, out pictures, out comments, out commentUserID, out text))
            {
                return(false); // 파싱 에러
            }
            article.Pictures       = pictures;
            article.CachedComments = comments;
            article.CommentUserID  = commentUserID;

            return(true);
        }
Пример #6
0
 // 인터페이스 끝
 public Uri GetArticleUri(DCInsideArticle article)
 {
     return(new Uri(string.Format("http://gall.dcinside.com/list.php?id={0}&no={1}", id, article.ID), UriKind.Absolute));
 }