Beispiel #1
0
        public static List <TableDataTable> TotalArticlePageCrawling(string html)
        {
            List <TableDataTable> list = new List <TableDataTable>( );

            HtmlDocument document = new HtmlDocument( );

            document.LoadHtml(html);

            int count  = 0;
            int iCount = 0;

            foreach (HtmlNode i in document.DocumentNode.SelectNodes("//tr"))
            {
                if (i.GetAttributeValue("align", "NONE") == "center" && i.GetAttributeValue("class", "NONE") != "bg-color" && i.GetAttributeValue("class", "NONE") != "bg-color _noticeArticle")
                {
                    if (count == iCount)
                    {
                        TableDataTable table = new TableDataTable( );

                        int icc        = 0;
                        int parseCount = 0;

                        foreach (HtmlNode i2 in i.SelectNodes("//a"))
                        {
                            if (i2.GetAttributeValue("href", "").StartsWith("/ArticleRead.nhn") && i2.GetAttributeValue("class", "") == "m-tcol-c")
                            {
                                if (count == icc)
                                {
                                    table.url   = "http://cafe.naver.com" + i2.GetAttributeValue("href", "");
                                    table.title = i2.InnerText.Trim( ).Replace(Environment.NewLine, "");
                                }

                                icc++;
                            }
                        }

                        foreach (HtmlNode i2 in i.ChildNodes)
                        {
                            if (i2.Name != "#text")
                            {
                                switch (parseCount)
                                {
                                case 0:
                                    table.number = i2.InnerText.Trim( );
                                    break;

                                case 1:
                                    // null
                                    break;

                                case 2:
                                    string nickData = i2.InnerText.Trim( );

                                    //11 ~ end
                                    int end = nickData.IndexOf("wordBreak($(");

                                    table.author = nickData.Substring(11, end - 11);

                                    break;

                                case 3:
                                    table.time = i2.InnerText.Trim( );

                                    break;

                                case 4:
                                    table.hit = int.Parse(i2.InnerText.Trim( ));

                                    break;

                                case 5:
                                    table.like = int.Parse(i2.InnerText.Trim( ));

                                    break;
                                }

                                parseCount++;
                            }
                        }

                        list.Add(table);
                        count++;
                    }

                    iCount++;
                }
            }

            return(list);
        }
Beispiel #2
0
        public static void Add(TableDataTable table)
        {
            string threadID = table.number;

            NotifyData data = new NotifyData( );

            data.threadTitle = HttpUtility.HtmlDecode(table.title);
            data.threadID    = table.number;
            data.threadURL   = table.url;
            data.threadHit   = table.hit;
            data.focused     = false;

            TopProgressMessage.Set("#" + threadID + " 게시글의 정보를 불러오고 있습니다 ... [2/3]");

            ThreadDetailStruct?detailStruct = NaverRequest.GetSpecificThreadDetail(threadID);

            if (detailStruct.HasValue)
            {
                data.threadAuthor  = detailStruct.Value.threadAuthor;
                data.threadTime    = detailStruct.Value.threadTime;
                data.personaconURL = detailStruct.Value.personaconURL;
                data.articleName   = detailStruct.Value.articleName;
                data.authorRank    = detailStruct.Value.authorRank;
            }
            else
            {
                data.threadAuthor  = "NULL(NULL)";
                data.threadTime    = "00:00";
                data.personaconURL = "";
                data.articleName   = "알 수 없음";
                data.authorRank    = "새싹멤버";
            }

            LISTS.Insert(0, data);

            //await Task.Run( new Action( ( ) => Advice.CheckThread( data ) ) );
            //Advice.CheckThread( data );

            if (Config.Get("CaptureEnable", "1") == "1")
            {
                TopProgressMessage.Set("#" + threadID + " 게시글을 캡처하고 있습니다 ... [3/3]");

                Main mainForm = Utility.GetMainForm( );

                if (mainForm != null)
                {
                    if (mainForm.InvokeRequired)
                    {
                        mainForm.Invoke(new Action(() => BrowserCapture.Capture(threadID)));
                    }
                    else
                    {
                        BrowserCapture.Capture(threadID);
                    }
                }
            }
            else
            {
                TopProgressMessage.Set("#" + threadID + " 게시글을 설정에 의해 캡처하지 않습니다. [3/3]");
            }
        }