diff --git a/CodeList.cs b/CodeList.cs index d2c3bc8..bf875f1 100644 --- a/CodeList.cs +++ b/CodeList.cs @@ -57,6 +57,8 @@ namespace NewsCrawler Console.WriteLine("Code Search Test"); + Console.WriteLine(SearchCode("[fnRASSI]씨트리(047920) 전일대비 6.77% 상승")); + Console.WriteLine(SearchCode("[클릭 e종목]로엔, 본격적으로 시작되는 카카오 시너")); Console.WriteLine(SearchCode("[클릭 e종목]\"SK텔레콤, 투자심리 개선 가능성 주목해")); Console.WriteLine(SearchCode("[클릭 e종목]SK하이닉스, 추가 상승 낙관적")); @@ -260,7 +262,9 @@ namespace NewsCrawler { try { - string strReplace = Regex.Replace(strText, @"(\(|\[|\<).*(\)|\]|\>)", ""); + string strReplace = Regex.Replace(strText, @"(\[).*(\])", ""); + strReplace = Regex.Replace(strReplace, @"(\().*(\))", ""); + strReplace = Regex.Replace(strReplace, @"(\<).*(\>)", ""); string[] words = strReplace.Trim().Split(' '); string strCodeWord = words[0]; diff --git a/Config.cs b/Config.cs index d1b7fdf..f06969b 100644 --- a/Config.cs +++ b/Config.cs @@ -29,6 +29,8 @@ namespace NewsCrawler m_Data.Add("ann-rights-issue", true); m_Data.Add("ann-patent", true); m_Data.Add("ann-patent-search-string", new Regex("(미국|중국)")); + m_Data.Add("ann-profit-change", true); + m_Data.Add("ann-profit-change-rate", 50.0f); Load(); Migration(); @@ -174,8 +176,11 @@ namespace NewsCrawler } public static void SetAnnouncement(bool bDartAPI, - bool bSupply, bool bRevenue, bool bRightsIssue, bool bPatent, - float fSupplyContractRate, float fRevenueRate, string strPatent) + bool bSupply, float fSupplyContractRate, + bool bRevenue, float fRevenueRate, + bool bRightsIssue, + bool bPatent, string strPatent, + bool bProfitChange, float fProfitChangeRate) { m_Data["ann-dart-api"] = bDartAPI; @@ -190,6 +195,9 @@ namespace NewsCrawler m_Data["ann-patent"] = bPatent; m_Data["ann-patent-search-string"] = strPatent; + m_Data["ann-profit-change"] = bProfitChange; + m_Data["ann-profit-change-rate"] = fProfitChangeRate; + Save(); } @@ -233,6 +241,16 @@ namespace NewsCrawler { return (Regex)m_Data["ann-patent-search-string"]; } + + public static bool CheckProfitChange() + { + return (bool)m_Data["ann-profit-change"]; + } + + public static float GetProfitChangeRate() + { + return (float)m_Data["ann-profit-change-rate"]; + } #endregion } } diff --git a/ConfigForm.Designer.cs b/ConfigForm.Designer.cs index e5b7c50..f32c582 100644 --- a/ConfigForm.Designer.cs +++ b/ConfigForm.Designer.cs @@ -65,6 +65,7 @@ this.groupBox12 = new System.Windows.Forms.GroupBox(); this.btAnApply = new System.Windows.Forms.Button(); this.tbAnPatent = new System.Windows.Forms.TextBox(); + this.chAnProfitChange = new System.Windows.Forms.CheckBox(); this.chAnPatent = new System.Windows.Forms.CheckBox(); this.chAnRightsIssue = new System.Windows.Forms.CheckBox(); this.chAnRevenue = new System.Windows.Forms.CheckBox(); @@ -75,6 +76,8 @@ this.label6 = new System.Windows.Forms.Label(); this.tbAnSupplyContractRate = new System.Windows.Forms.TextBox(); this.label9 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.tbAnProfitChange = new System.Windows.Forms.TextBox(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox6.SuspendLayout(); @@ -442,8 +445,11 @@ // // groupBox12 // + this.groupBox12.Controls.Add(this.label5); + this.groupBox12.Controls.Add(this.tbAnProfitChange); this.groupBox12.Controls.Add(this.btAnApply); this.groupBox12.Controls.Add(this.tbAnPatent); + this.groupBox12.Controls.Add(this.chAnProfitChange); this.groupBox12.Controls.Add(this.chAnPatent); this.groupBox12.Controls.Add(this.chAnRightsIssue); this.groupBox12.Controls.Add(this.chAnRevenue); @@ -455,14 +461,14 @@ this.groupBox12.Controls.Add(this.tbAnSupplyContractRate); this.groupBox12.Location = new System.Drawing.Point(280, 316); this.groupBox12.Name = "groupBox12"; - this.groupBox12.Size = new System.Drawing.Size(262, 209); + this.groupBox12.Size = new System.Drawing.Size(262, 270); this.groupBox12.TabIndex = 19; this.groupBox12.TabStop = false; this.groupBox12.Text = "공시"; // // btAnApply // - this.btAnApply.Location = new System.Drawing.Point(93, 163); + this.btAnApply.Location = new System.Drawing.Point(91, 211); this.btAnApply.Name = "btAnApply"; this.btAnApply.Size = new System.Drawing.Size(72, 39); this.btAnApply.TabIndex = 5; @@ -478,6 +484,18 @@ this.tbAnPatent.TabIndex = 8; this.tbAnPatent.Text = "(미국|중국)"; // + // chAnProfitChange + // + this.chAnProfitChange.AutoSize = true; + this.chAnProfitChange.Checked = true; + this.chAnProfitChange.CheckState = System.Windows.Forms.CheckState.Checked; + this.chAnProfitChange.Location = new System.Drawing.Point(16, 169); + this.chAnProfitChange.Name = "chAnProfitChange"; + this.chAnProfitChange.Size = new System.Drawing.Size(96, 16); + this.chAnProfitChange.TabIndex = 7; + this.chAnProfitChange.Text = "손익구조변동"; + this.chAnProfitChange.UseVisualStyleBackColor = true; + // // chAnPatent // this.chAnPatent.AutoSize = true; @@ -580,17 +598,36 @@ // this.label9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(12, 516); + this.label9.Location = new System.Drawing.Point(12, 577); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(132, 12); this.label9.TabIndex = 20; - this.label9.Text = "Version : 2017.02.05.17"; + this.label9.Text = "Version : 2017.02.07.09"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(215, 170); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(15, 12); + this.label5.TabIndex = 10; + this.label5.Text = "%"; + // + // tbAnProfitChange + // + this.tbAnProfitChange.Location = new System.Drawing.Point(136, 167); + this.tbAnProfitChange.Name = "tbAnProfitChange"; + this.tbAnProfitChange.Size = new System.Drawing.Size(73, 21); + this.tbAnProfitChange.TabIndex = 9; + this.tbAnProfitChange.Text = "5.0"; + this.tbAnProfitChange.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.tbAnProfitChange.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbAnProfitChange_KeyPress); // // ConfigForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(548, 537); + this.ClientSize = new System.Drawing.Size(548, 598); this.Controls.Add(this.label9); this.Controls.Add(this.groupBox12); this.Controls.Add(this.groupBox11); @@ -673,5 +710,8 @@ private System.Windows.Forms.CheckBox chAnPatent; private System.Windows.Forms.Button btAnApply; private System.Windows.Forms.CheckBox chAnDartAPI; + private System.Windows.Forms.CheckBox chAnProfitChange; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.TextBox tbAnProfitChange; } } \ No newline at end of file diff --git a/ConfigForm.cs b/ConfigForm.cs index 2df5b5a..7552826 100644 --- a/ConfigForm.cs +++ b/ConfigForm.cs @@ -153,7 +153,13 @@ namespace NewsCrawler private void tbRevenueRate_KeyPress(object sender, KeyPressEventArgs e) { - if (char.IsDigit(e.KeyChar) == false && e.KeyChar != '.') + if(char.IsDigit(e.KeyChar) == false && e.KeyChar != '.') + e.Handled = true; + } + + private void tbAnProfitChange_KeyPress(object sender, KeyPressEventArgs e) + { + if(char.IsDigit(e.KeyChar) == false && e.KeyChar != '.') e.Handled = true; } @@ -165,9 +171,15 @@ namespace NewsCrawler float fRevenueRate; float.TryParse(tbAnRevenueRate.Text, out fRevenueRate); + float fProfitChange; + float.TryParse(tbAnProfitChange.Text, out fProfitChange); + Config.SetAnnouncement(chAnDartAPI.Checked, - chAnSupply.Checked, chAnRevenue.Checked, chAnRightsIssue.Checked, chAnPatent.Checked, - fSupplyContractRate, fRevenueRate, tbAnPatent.Text); + chAnSupply.Checked, fSupplyContractRate, + chAnRevenue.Checked, fRevenueRate, + chAnRightsIssue.Checked, + chAnPatent.Checked, tbAnPatent.Text, + chAnProfitChange.Checked, fProfitChange); } } } diff --git a/Crawler.cs b/Crawler.cs index 2deadb2..ec88d6c 100644 --- a/Crawler.cs +++ b/Crawler.cs @@ -16,6 +16,7 @@ namespace NewsCrawler NewsForm m_Listener = null; DateTime m_Today = DateTime.Now; int m_iDartAPIRetry = 5; + Regex m_ProfitChange = new Regex("30%.*이상.*(변경|변동)"); public Crawler(NewsForm Listener) { @@ -45,6 +46,10 @@ namespace NewsCrawler ReadRevenue(false, "LS산전", "http://m.dart.fss.or.kr/viewer/main.st?rcpNo=20170126800581"); ReadRightsIssue(false, "옴니텔", "http://m.dart.fss.or.kr/viewer/main.st?rcpNo=20170126000525"); ReadPatent(false, "인트론바이오", "http://m.dart.fss.or.kr/viewer/main.st?rcpNo=20170125900080"); + ReadProfitChange(false, "세하", "http://m.dart.fss.or.kr/viewer/main.st?rcpNo=20170206800276"); + ReadProfitChange(false, "아세아", "http://m.dart.fss.or.kr/viewer/main.st?rcpNo=20170206800894"); + + //ReadDartAPITest(false, "http://dart.fss.or.kr/api/search.json?end_dt=20170206&sort=date&series=desc&page_set=100"); } void ResponseAsiaE(IAsyncResult result) @@ -660,6 +665,90 @@ namespace NewsCrawler } } + void ResponseProfitChange(IAsyncResult result) + { + REQUEST_STATUS State = (REQUEST_STATUS)result.AsyncState; + HttpWebRequest HttpReq = State.m_HTTPReq; + bool bInitial = State.m_bInitial; + State.m_Timer.Stop(); + + try + { + using(HttpWebResponse response = (HttpWebResponse)HttpReq.GetResponse()) + { + using(Stream dataStream = response.GetResponseStream()) + { + using(StreamReader reader = new StreamReader(dataStream, Encoding.GetEncoding("utf-8"))) + { + string responseFromServer = WebUtility.HtmlDecode(reader.ReadToEnd()); + + dynamic jObj = Newtonsoft.Json.JsonConvert.DeserializeObject(responseFromServer); + string strBody = jObj["reportBody"]; + strBody = strBody.Replace("\\\"", "\""); + strBody = strBody.Replace("\r\n", ""); + HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); + doc.LoadHtml(strBody); + + string strXPath = "//tr"; + var lists = doc.DocumentNode.SelectNodes(strXPath); + foreach(var item in lists) + { + var cols = item.SelectNodes(".//td"); + for(int i = 0; i