private bool getIsSameGame(NaverGameModel model, string gameTitle) { const char DIV = ':'; string[] arrTitle = gameTitle.Split(DIV); //16-17 NBA LA 클리퍼스:골든스테이트 string[] teamTemp = arrTitle[0].Split(' '); string team1 = teamTemp[teamTemp.Length - 1]; teamTemp = arrTitle[1].Split(' '); string team2 = teamTemp[0]; //Debug.WriteLine( team1 + "/" + team2 + "::::" + model.Values ); if (model.Values.IndexOf(team1, StringComparison.Ordinal) != -1) { return(true); } if (model.Values.IndexOf(team2, StringComparison.Ordinal) != -1) { return(true); } return(false); }
public NaverGameModelDailyList MakeNaverData(string strXML) { NaverGameModelDailyList dailyList = new NaverGameModelDailyList(); int startIdx = strXML.IndexOf("<html", System.StringComparison.Ordinal); if (startIdx > 0) { strXML = strXML.Substring(startIdx); } HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(strXML); System.IO.StringWriter sw = new System.IO.StringWriter(); XmlWriter xw = XmlWriter.Create(sw); doc.Save(xw); string result = sw.ToString(); XDocument xd = XDocument.Parse(result); NaverGameModel model; foreach (XElement element in xd.Descendants("li")) { if (!element.Parent.HasAttributes) { continue; } if (element.Parent.Attribute("class") == null) { continue; } string strParentValue = element.Parent.Attribute("class").Value; if (strParentValue.IndexOf("sch_lst", StringComparison.Ordinal) == -1) { continue; } model = new NaverGameModel(); foreach (XElement element2 in element.Descendants("a")) { ///basketball/gamecenter/nba/index.nhn?tab=record&gameId=2017022319 model.Link = element2.Attribute("href").Value; model.Values = StringUtil.Trim(element2.Value); dailyList.Add(model); } } return(dailyList); }