/// <summary> /// 获得列表 /// </summary> /// <returns></returns> public List <OddsLiveMatch> GetScrollMatchList() { List <OddsLiveMatch> liveMatchList = new List <OddsLiveMatch>(); try { HttpHelper h = new HttpHelper(); Cookie lng = new Cookie("lng", "2"); lng.Domain = domain; h.CookieContainer.Add(lng); string zoudi = h.GetHtml("https://" + domain + "/default.aspx" + zoudiUrl); if (!string.IsNullOrEmpty(zoudi)) { #region 分析网页html节点 Lexer lexer = new Lexer(zoudi); Parser parser = new Parser(lexer); NodeList bodyNodes = parser.Parse(new TagNameFilter("HTML"))[0].Children.ExtractAllNodesThatMatch(new TagNameFilter("BODY"))[0].Children; ITag divNode = bodyNodes.ExtractAllNodesThatMatch(new TagNameFilter("FORM"))[0].Children.ExtractAllNodesThatMatch(new TagNameFilter("DIV"))[0] as ITag; if (divNode.Attributes["ID"].Equals("PageBody")) { NodeList dataDivList = divNode.Children.SearchFor(typeof(Winista.Text.HtmlParser.Tags.Div)); if (dataDivList[0].ToPlainTextString() == "走地盤") { if (dataDivList[2].ToPlainTextString() == "全場賽果") { return(liveMatchList); } for (int i = 0; i < dataDivList.Count; i++) { ITag div = dataDivList[i] as ITag; if (div.Attributes["CLASS"] != null && div.Attributes["CLASS"].Equals("menuRow")) { OddsLiveMatch oddsLive = new OddsLiveMatch(); oddsLive.urlparams = (div.FirstChild as ITag).Attributes["HREF"].ToString(); oddsLive.id = oddsLive.urlparams.Split('&')[0].Substring(4); oddsLive.time = DateTime.Now; oddsLive.name = div.ToPlainTextString(); liveMatchList.Add(oddsLive); } } } } #endregion 分析网页html节点 } } catch (Exception) { } return(liveMatchList); }
public void AddLiveMatch(OddsLiveMatch model) { dal.AddMatch(model); }