- 리스트에 종목명 추가
- 공시 요청 여부 추가 - 공시 특허권취득 추가
This commit is contained in:
91
Crawler.cs
91
Crawler.cs
@@ -44,6 +44,7 @@ namespace NewsCrawler
|
||||
ReadRevenue(false, "제일기획", "http://m.dart.fss.or.kr/viewer/main.st?rcpNo=20170126800508");
|
||||
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");
|
||||
}
|
||||
|
||||
void ResponseAsiaE(IAsyncResult result)
|
||||
@@ -417,9 +418,6 @@ namespace NewsCrawler
|
||||
|
||||
private void ReadSupplyContract(bool bInitial, string strCodeName, string strURL)
|
||||
{
|
||||
if(m_iDartAPIRetry <= 0)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
HttpWebRequest HttpReq = WebRequest.Create(strURL) as HttpWebRequest;
|
||||
@@ -497,9 +495,6 @@ namespace NewsCrawler
|
||||
|
||||
private void ReadRevenue(bool bInitial, string strCodeName, string strURL)
|
||||
{
|
||||
if (m_iDartAPIRetry <= 0)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
HttpWebRequest HttpReq = WebRequest.Create(strURL) as HttpWebRequest;
|
||||
@@ -572,9 +567,6 @@ namespace NewsCrawler
|
||||
|
||||
private void ReadRightsIssue(bool bInitial, string strCodeName, string strURL)
|
||||
{
|
||||
if (m_iDartAPIRetry <= 0)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
HttpWebRequest HttpReq = WebRequest.Create(strURL) as HttpWebRequest;
|
||||
@@ -595,6 +587,79 @@ namespace NewsCrawler
|
||||
}
|
||||
}
|
||||
|
||||
void ResponsePatent(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<cols.Count-1; i++)
|
||||
{
|
||||
if(cols[i].InnerText.Contains("기타 투자판단에 참고할 사항") &&
|
||||
Config.GetPatentSearchString().IsMatch(cols[i+1].InnerText))
|
||||
{
|
||||
m_Listener.OnReceivedPatent(State.m_strCodeName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HttpReq.EndGetResponse(result);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadPatent(bool bInitial, string strCodeName, string strURL)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpWebRequest HttpReq = WebRequest.Create(strURL) as HttpWebRequest;
|
||||
HttpReq.Credentials = CredentialCache.DefaultCredentials;
|
||||
HttpReq.Timeout = 2000;
|
||||
|
||||
REQUEST_STATUS State = new REQUEST_STATUS();
|
||||
State.m_HTTPReq = HttpReq;
|
||||
State.m_bInitial = bInitial;
|
||||
State.m_Timer.Start();
|
||||
State.m_strCodeName = strCodeName;
|
||||
|
||||
HttpReq.BeginGetResponse(new AsyncCallback(ResponsePatent), State);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
void ResponseDartAPI(IAsyncResult result)
|
||||
{
|
||||
REQUEST_STATUS State = (REQUEST_STATUS)result.AsyncState;
|
||||
@@ -635,12 +700,14 @@ namespace NewsCrawler
|
||||
string strURL = "http://m.dart.fss.or.kr/html_mdart/MD1007.html?rcpNo=" + data["rcp_no"];
|
||||
string strViewURL = "http://m.dart.fss.or.kr/viewer/main.st?rcpNo=" + data["rcp_no"];
|
||||
|
||||
if (strCodeName != "" && strTitle.Contains("공급계약체결") && m_Listener.IsDuplicatedURL(strURL) == false)
|
||||
if (Config.CheckSupplyContract() && strCodeName != "" && strTitle.Contains("공급계약체결") && m_Listener.IsDuplicatedURL(strURL) == false)
|
||||
ReadSupplyContract(bInitial, strCodeName, strViewURL);
|
||||
else if(strCodeName != "" && strTitle.Contains("영업(잠정)실적(공정공시)") && m_Listener.IsDuplicatedURL(strURL) == false)
|
||||
else if(Config.CheckRevenue() && strCodeName != "" && strTitle.Contains("영업(잠정)실적(공정공시)") && m_Listener.IsDuplicatedURL(strURL) == false)
|
||||
ReadRevenue(bInitial, strCodeName, strViewURL);
|
||||
else if(strCodeName != "" && strTitle.Contains("유상증자결정") && m_Listener.IsDuplicatedURL(strURL) == false)
|
||||
else if(Config.CheckRightsIssue() && strCodeName != "" && strTitle.Contains("유상증자결정") && m_Listener.IsDuplicatedURL(strURL) == false)
|
||||
ReadRightsIssue(bInitial, strCodeName, strViewURL);
|
||||
else if(Config.CheckPatent() && strCodeName != "" && strTitle.Contains("특허권취득") && m_Listener.IsDuplicatedURL(strURL) == false)
|
||||
ReadPatent(bInitial, strCodeName, strViewURL);
|
||||
|
||||
m_Listener.InsertItem(strTitle, strCodeName, "",
|
||||
DateTime.ParseExact(strTime, "HH:mm", CultureInfo.CurrentCulture),
|
||||
|
||||
Reference in New Issue
Block a user