internal LotteryDTO(lottery item) : base(new sportEvent { id = item == null ? "wns:lottery:1" : item.id, name = item.name, scheduledSpecified = false, scheduled = DateTime.MinValue, tournament = item.sport == null ? null : new tournament { sport = item.sport } }) { Guard.Argument(item, nameof(item)).NotNull(); if (item.sport != null) { Sport = new SportDTO(item.sport.id, item.sport.name, (IEnumerable <tournamentExtended>)null); } if (item.category != null) { Category = new CategorySummaryDTO(item.category); } if (item.bonus_info != null) { BonusInfo = new BonusInfoDTO(item.bonus_info); } if (item.draw_info != null) { DrawInfo = new DrawInfoDTO(item.draw_info); } }
public OpenResult GetOpenResult() { var response = HttpRequestFactory.Get("https://kaijiang.500.com/static/info/kaijiang/xml/index.xml"); Byte[] b = response.Result.Content.ReadAsByteArrayAsync().Result; var streamReceive = new GZipStream(response.Result.Content.ReadAsStreamAsync().Result, CompressionMode.Decompress); XmlDocument dom = new XmlDocument(); dom.Load(streamReceive);//这个地方需要注意 XmlNodeList xmlNodeList = dom.SelectNodes("//lottery"); XmlNode xmlNode = null; foreach (XmlNode el in xmlNodeList) { if (el.InnerXml.Contains("qxc") && el.InnerXml.Contains("7星彩")) { xmlNode = el; } } lottery l = null; if (xmlNode != null) { l = XMLSerilizable.XMLToObject <lottery>(xmlNode.OuterXml, Encoding.UTF8); } return(l); }
public void GetsTest1() { var response = HttpRequestFactory.Get("https://kaijiang.500.com/static/info/kaijiang/xml/index.xml"); Byte[] b = response.Result.Content.ReadAsByteArrayAsync().Result; var streamReceive = new GZipStream(response.Result.Content.ReadAsStreamAsync().Result, CompressionMode.Decompress); XmlDocument dom = new XmlDocument(); dom.Load(streamReceive);//这个地方需要注意 XmlNodeList xmlNodeList = dom.SelectNodes("//lottery"); XmlNode xmlNode = null; foreach (XmlNode el in xmlNodeList) { if (el.InnerXml.Contains("qxc") && el.InnerXml.Contains("7星彩")) { xmlNode = el; } } //XmlNode xmlNode1 = dom.SelectSingleNode("//lottery"); //XmlNode xmlNode = dom.SelectSingleNode("//open"); //StringBuilder output = new StringBuilder(); //XmlWriter xmlWriter = XmlWriter.Create(output); //xmlNode.WriteTo(xmlWriter); //Console.WriteLine(output.ToString()); if (xmlNode != null) { lottery l = XMLSerilizable.XMLToObject <lottery>(xmlNode.OuterXml, Encoding.UTF8); } //open or = XMLSerilizable.XMLToObject<open>(xmlNode.OuterXml, Encoding.UTF8); string Flag = ""; //string Flag = System.Text.Encoding.UTF8.GetString(b, 0, b.Length); //string Flag = System.Text.Encoding.Unicode.GetString(b, 0, b.Length); //string andy = System.Text.Encoding.GetEncoding("GB2312").GetString(b).Trim(); using (System.IO.StreamReader sr = new System.IO.StreamReader(streamReceive, Encoding.UTF8)) { Flag = sr.ReadToEnd(); } Console.WriteLine(Flag); }