private IEnumerable <ETFinsertTaskTemplate> GrabDataFromSiteFive() { List <ETFinsertTaskTemplate> partOne = new List <ETFinsertTaskTemplate>(); HtmlDocument root = WebClientUtil.GetHtmlDocument("https://www.kgifund.com.tw/50_05.asp", 6000); HtmlNodeCollection trs = root.DocumentNode.SelectNodes("/html[1]/body[1]/table[1]/tr[1]/td[2]/table[1]/tr[3]/td[2]/table[1]/tr[2]/td[1]/table[1]/tr[2]/td[2]/div[1]/table[1]/tr[3]/td[1]/table[1]/tr[2]/td[1]/table[1]/tr"); HtmlNode codeNode = root.DocumentNode.SelectSingleNode("/html[1]/body[1]/table[1]/tr[1]/td[2]/table[1]/tr[3]/td[2]/table[1]/tr[2]/td[1]/table[1]/tr[2]/td[2]/div[1]/table[1]/tr[3]/td[1]/table[1]/tr[1]/td[1]/table[1]/tr"); ETFinsertTaskTemplate oneRes = new ETFinsertTaskTemplate(); Regex regex = new Regex("\\d{1,}"); Match match = regex.Match(codeNode.InnerText.TrimStart().TrimEnd()); oneRes.Code = match.Value; foreach (var tr in trs) { if (tr.InnerText.Contains("昨日收盤淨值(台幣)")) { regex = new Regex("\\d{1,}.\\d{1,}"); match = regex.Match(tr.InnerText.TrimStart().TrimEnd()); oneRes.ReferenceValue = match.Value; } if (tr.InnerText.Contains("盤中預估淨值(台幣)")) { regex = new Regex("\\d{1,}.\\d{1,}"); match = regex.Match(tr.InnerText.TrimStart().TrimEnd()); oneRes.EstimatedValue = match.Value; } } partOne.Add(oneRes); return(partOne); }
private IEnumerable <ETFinsertTaskTemplate> GrabDataFromSiteFour() { List <ETFinsertTaskTemplate> partOne = new List <ETFinsertTaskTemplate>(); HtmlDocument root = WebClientUtil.GetHtmlDocument("http://sitc.sinopac.com/web/etf/Ajax/GetTradeinfo_nav.aspx", 6000, "fundcode=37"); HtmlNodeCollection trs = root.DocumentNode.SelectNodes("//table/tbody/tr"); foreach (var tr in trs) { HtmlNodeCollection tds = tr.SelectNodes("./td"); if (tds == null || tds.Count < 4) { continue; } Regex regex = new Regex("\\d{1,}.\\d{1,}"); Match match = regex.Match(tds[2].InnerText.TrimStart().TrimEnd()); if (!match.Success) { continue; } ETFinsertTaskTemplate oneRes = new ETFinsertTaskTemplate { ReferenceValue = match.Value.TrimStart().TrimEnd() }; match = regex.Match(tds[0].InnerText.TrimStart().TrimEnd()); oneRes.Code = match.Value.TrimStart().TrimEnd(); match = regex.Match(tds[3].InnerText.TrimStart().TrimEnd()); oneRes.EstimatedValue = match.Value.TrimStart().TrimEnd(); partOne.Add(oneRes); } return(partOne); }
private IEnumerable <ETFinsertTaskTemplate> GrabDataFromSiteSix() { List <ETFinsertTaskTemplate> partOne = new List <ETFinsertTaskTemplate>(); HtmlDocument root = WebClientUtil.GetHtmlDocument("http://www.fhtrust.com.tw/funds/fund_ETF_RTnav.asp", 6000, "QueryFund=ETF01&AgreeFlag=Y"); HtmlNodeCollection trs = root.DocumentNode.SelectNodes("//table[@class=\"tb_2\"][2]/tr"); HtmlNodeCollection tds = trs[2].SelectNodes("./td"); Regex regex = new Regex("\\d{1,}.\\d{1,}"); Match match = regex.Match(tds[1].InnerText.TrimStart().TrimEnd()); ETFinsertTaskTemplate oneRes = new ETFinsertTaskTemplate { ReferenceValue = match.Value.TrimStart().TrimEnd() }; match = regex.Match(tds[0].InnerText.TrimStart().TrimEnd()); oneRes.Code = match.Value.TrimStart().TrimEnd(); match = regex.Match(tds[2].InnerText.TrimStart().TrimEnd()); oneRes.EstimatedValue = match.Value.TrimStart().TrimEnd(); partOne.Add(oneRes); return(partOne); }