diff --git a/Form1.Designer.cs b/Form1.Designer.cs index 0b56315..9b8bccc 100644 --- a/Form1.Designer.cs +++ b/Form1.Designer.cs @@ -28,160 +28,161 @@ /// private void InitializeComponent() { - this.lvList = new System.Windows.Forms.ListView(); - this.chTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chTitle = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chCodeName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chCode = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chReference = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chLink = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.wbView = new System.Windows.Forms.WebBrowser(); - this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.chAutoReload = new System.Windows.Forms.CheckBox(); - this.chAutoSelect = new System.Windows.Forms.CheckBox(); - this.tbInterval = new System.Windows.Forms.TextBox(); - this.label1 = new System.Windows.Forms.Label(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); - this.splitContainer1.Panel1.SuspendLayout(); - this.splitContainer1.Panel2.SuspendLayout(); - this.splitContainer1.SuspendLayout(); - this.SuspendLayout(); - // - // lvList - // - this.lvList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.lvList = new System.Windows.Forms.ListView(); + this.chTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chTitle = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chCodeName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chCode = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chReference = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chLink = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.wbView = new System.Windows.Forms.WebBrowser(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.chAutoReload = new System.Windows.Forms.CheckBox(); + this.chAutoSelect = new System.Windows.Forms.CheckBox(); + this.tbInterval = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.SuspendLayout(); + // + // lvList + // + this.lvList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.chTime, this.chTitle, this.chCodeName, this.chCode, this.chReference, this.chLink}); - this.lvList.Dock = System.Windows.Forms.DockStyle.Fill; - this.lvList.FullRowSelect = true; - this.lvList.GridLines = true; - this.lvList.Location = new System.Drawing.Point(0, 0); - this.lvList.MultiSelect = false; - this.lvList.Name = "lvList"; - this.lvList.Size = new System.Drawing.Size(864, 157); - this.lvList.TabIndex = 0; - this.lvList.UseCompatibleStateImageBehavior = false; - this.lvList.View = System.Windows.Forms.View.Details; - this.lvList.SelectedIndexChanged += new System.EventHandler(this.lvList_SelectedIndexChanged); - // - // chTime - // - this.chTime.Text = "시간"; - // - // chTitle - // - this.chTitle.Text = "제목"; - this.chTitle.Width = 366; - // - // chCodeName - // - this.chCodeName.Text = "종목명"; - // - // chCode - // - this.chCode.Text = "종목코드"; - // - // chReference - // - this.chReference.Text = "출처"; - this.chReference.Width = 72; - // - // chLink - // - this.chLink.Text = "링크"; - this.chLink.Width = 241; - // - // wbView - // - this.wbView.Dock = System.Windows.Forms.DockStyle.Fill; - this.wbView.Location = new System.Drawing.Point(0, 0); - this.wbView.MinimumSize = new System.Drawing.Size(20, 20); - this.wbView.Name = "wbView"; - this.wbView.Size = new System.Drawing.Size(864, 644); - this.wbView.TabIndex = 1; - // - // splitContainer1 - // - this.splitContainer1.Location = new System.Drawing.Point(0, 25); - this.splitContainer1.Name = "splitContainer1"; - this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; - // - // splitContainer1.Panel1 - // - this.splitContainer1.Panel1.Controls.Add(this.lvList); - // - // splitContainer1.Panel2 - // - this.splitContainer1.Panel2.Controls.Add(this.wbView); - this.splitContainer1.Size = new System.Drawing.Size(864, 805); - this.splitContainer1.SplitterDistance = 157; - this.splitContainer1.TabIndex = 2; - // - // chAutoReload - // - this.chAutoReload.AutoSize = true; - this.chAutoReload.Checked = true; - this.chAutoReload.CheckState = System.Windows.Forms.CheckState.Checked; - this.chAutoReload.Location = new System.Drawing.Point(3, 4); - this.chAutoReload.Name = "chAutoReload"; - this.chAutoReload.Size = new System.Drawing.Size(76, 16); - this.chAutoReload.TabIndex = 3; - this.chAutoReload.Text = "자동 갱신"; - this.chAutoReload.UseVisualStyleBackColor = true; - // - // chAutoSelect - // - this.chAutoSelect.AutoSize = true; - this.chAutoSelect.Checked = true; - this.chAutoSelect.CheckState = System.Windows.Forms.CheckState.Checked; - this.chAutoSelect.Location = new System.Drawing.Point(85, 4); - this.chAutoSelect.Name = "chAutoSelect"; - this.chAutoSelect.Size = new System.Drawing.Size(76, 16); - this.chAutoSelect.TabIndex = 4; - this.chAutoSelect.Text = "자동 선택"; - this.chAutoSelect.UseVisualStyleBackColor = true; - // - // tbInterval - // - this.tbInterval.Location = new System.Drawing.Point(226, 2); - this.tbInterval.Name = "tbInterval"; - this.tbInterval.Size = new System.Drawing.Size(42, 21); - this.tbInterval.TabIndex = 5; - this.tbInterval.Text = "0.5초"; - this.tbInterval.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - this.tbInterval.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbInterval_KeyPress); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(167, 5); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(53, 12); - this.label1.TabIndex = 6; - this.label1.Text = "갱신주기"; - // - // Form1 - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(864, 829); - this.Controls.Add(this.label1); - this.Controls.Add(this.tbInterval); - this.Controls.Add(this.chAutoSelect); - this.Controls.Add(this.chAutoReload); - this.Controls.Add(this.splitContainer1); - this.Name = "Form1"; - this.Text = "News Crawler"; - this.splitContainer1.Panel1.ResumeLayout(false); - this.splitContainer1.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); - this.splitContainer1.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); + this.lvList.Dock = System.Windows.Forms.DockStyle.Fill; + this.lvList.FullRowSelect = true; + this.lvList.GridLines = true; + this.lvList.HideSelection = false; + this.lvList.Location = new System.Drawing.Point(0, 0); + this.lvList.MultiSelect = false; + this.lvList.Name = "lvList"; + this.lvList.Size = new System.Drawing.Size(864, 157); + this.lvList.TabIndex = 0; + this.lvList.UseCompatibleStateImageBehavior = false; + this.lvList.View = System.Windows.Forms.View.Details; + this.lvList.SelectedIndexChanged += new System.EventHandler(this.lvList_SelectedIndexChanged); + // + // chTime + // + this.chTime.Text = "시간"; + // + // chTitle + // + this.chTitle.Text = "제목"; + this.chTitle.Width = 366; + // + // chCodeName + // + this.chCodeName.Text = "종목명"; + // + // chCode + // + this.chCode.Text = "종목코드"; + // + // chReference + // + this.chReference.Text = "출처"; + this.chReference.Width = 72; + // + // chLink + // + this.chLink.Text = "링크"; + this.chLink.Width = 241; + // + // wbView + // + this.wbView.Dock = System.Windows.Forms.DockStyle.Fill; + this.wbView.Location = new System.Drawing.Point(0, 0); + this.wbView.MinimumSize = new System.Drawing.Size(20, 20); + this.wbView.Name = "wbView"; + this.wbView.Size = new System.Drawing.Size(864, 644); + this.wbView.TabIndex = 1; + // + // splitContainer1 + // + this.splitContainer1.Location = new System.Drawing.Point(0, 25); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.lvList); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.wbView); + this.splitContainer1.Size = new System.Drawing.Size(864, 805); + this.splitContainer1.SplitterDistance = 157; + this.splitContainer1.TabIndex = 2; + // + // chAutoReload + // + this.chAutoReload.AutoSize = true; + this.chAutoReload.Checked = true; + this.chAutoReload.CheckState = System.Windows.Forms.CheckState.Checked; + this.chAutoReload.Location = new System.Drawing.Point(3, 4); + this.chAutoReload.Name = "chAutoReload"; + this.chAutoReload.Size = new System.Drawing.Size(76, 16); + this.chAutoReload.TabIndex = 3; + this.chAutoReload.Text = "자동 갱신"; + this.chAutoReload.UseVisualStyleBackColor = true; + // + // chAutoSelect + // + this.chAutoSelect.AutoSize = true; + this.chAutoSelect.Checked = true; + this.chAutoSelect.CheckState = System.Windows.Forms.CheckState.Checked; + this.chAutoSelect.Location = new System.Drawing.Point(85, 4); + this.chAutoSelect.Name = "chAutoSelect"; + this.chAutoSelect.Size = new System.Drawing.Size(76, 16); + this.chAutoSelect.TabIndex = 4; + this.chAutoSelect.Text = "자동 선택"; + this.chAutoSelect.UseVisualStyleBackColor = true; + // + // tbInterval + // + this.tbInterval.Location = new System.Drawing.Point(226, 2); + this.tbInterval.Name = "tbInterval"; + this.tbInterval.Size = new System.Drawing.Size(42, 21); + this.tbInterval.TabIndex = 5; + this.tbInterval.Text = "0.5초"; + this.tbInterval.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.tbInterval.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbInterval_KeyPress); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(167, 5); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(53, 12); + this.label1.TabIndex = 6; + this.label1.Text = "갱신주기"; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(864, 829); + this.Controls.Add(this.label1); + this.Controls.Add(this.tbInterval); + this.Controls.Add(this.chAutoSelect); + this.Controls.Add(this.chAutoReload); + this.Controls.Add(this.splitContainer1); + this.Name = "Form1"; + this.Text = "News Crawler"; + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); } diff --git a/Form1.cs b/Form1.cs index d46603c..bab798b 100644 --- a/Form1.cs +++ b/Form1.cs @@ -72,7 +72,15 @@ namespace NewsCrawler string strTime = item.SelectSingleNode(".//span").InnerText; string strURL = strServerURL+item.SelectSingleNode(".//a").GetAttributeValue("href", ""); - if(m_ItemList.Any(c => c.m_strURL==strURL)==false) + + if (Regex.IsMatch(strTime, @"\d+/\d+") == true) + { + //Console.WriteLine("어제 기사 : " + item.InnerHtml); + continue; + } + + + if (m_ItemList.Any(c => c.m_strURL==strURL)==false) { NEWS_ITEM news = new NEWS_ITEM(); news.m_strTitle=strTitle; @@ -119,7 +127,13 @@ namespace NewsCrawler string strURL = item.SelectSingleNode(".//a").GetAttributeValue("href", ""); strURL = "http://www.etoday.co.kr/news/section/newsview.php?idxno="+Regex.Replace(strURL, @"\D", ""); - if(m_ItemList.Any(c => c.m_strURL==strURL)==false) + if (Regex.IsMatch(strTime, @"\d+/\d+") == true) + { + //Console.WriteLine("어제 기사 : " + item.InnerHtml); + continue; + } + + if (m_ItemList.Any(c => c.m_strURL==strURL)==false) { NEWS_ITEM news = new NEWS_ITEM(); news.m_strTitle=strTitle;