Exemplo n.º 1
0
        /// <summary>
        /// 获得列表
        /// </summary>
        /// <returns></returns>
        public List<OddsLiveMatch> GetMatchScrollOdds(string matchid,string urlparams)
        {
            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" + urlparams);
                string zoudi = h.GetHtml(urlparams);
                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() == "全場賽果")
                            {
                                OddsLiveHistory liveHistory = new OddsLiveHistory();
                                liveHistory.matchid = matchid;
                                liveHistory.home = float.Parse(dataDivList[3].ToPlainTextString().Split(' ')[0]);
                                liveHistory.draw = float.Parse(dataDivList[5].ToPlainTextString().Split(' ')[0]);
                                liveHistory.away = float.Parse(dataDivList[7].ToPlainTextString().Split(' ')[0]);
                                liveHistory.time = DateTime.Now;
                                dal.AddHistory(liveHistory);
                            }
                        }
                    }
                    #endregion 分析网页html节点
                }
            }
            catch (Exception)
            {

            }
            return liveMatchList;
        }
Exemplo n.º 2
0
        /// <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;
        }
Exemplo n.º 3
0
        public string GetBetLiveData()
        {
            HttpHelper target = new HttpHelper(); // TODO: 初始化为适当的值
            string url = string.Empty; // TODO: 初始化为适当的值
            string expected = string.Empty; // TODO: 初始化为适当的值
            string actual;
            actual = target.GetHtml("http://live.bet007.com/VbsXml/bfdata.js?" + DateTime.Now);

            string[] sArray = Regex.Split(actual, "\r\n", RegexOptions.IgnoreCase);

            int matchcount = 0;
            int sclasscount = 0;
            string matchdate = "";
            List<string> matchs = new List<string>();
            List<string> sclasss = new List<string>();
            foreach (string i in sArray)
            {
                if (i.StartsWith("A[") && i.EndsWith("\".split('^');"))
                {
                    matchs.Add(i.Split('"')[1]);
                }
                else if (i.StartsWith("B[") && i.EndsWith("\".split('^');"))
                {
                    sclasss.Add(i.Split('"')[1]);
                }
                else if (i.StartsWith("var matchcount="))
                {
                    matchcount = int.Parse(StringPlus.DelLastChar(i.Replace("var matchcount=", ""),";"));
                }
                else if (i.StartsWith("var sclasscount="))
                {
                    matchcount = int.Parse(StringPlus.DelLastChar(i.Replace("var sclasscount=", ""),";"));
                }
                else if (i.StartsWith("var matchdate=\""))
                {
                    matchdate = StringPlus.DelLastChar(i.Replace("var matchdate=\"", ""),"\"");
                }
            }

            LiveDataJSONHelper json = new LiveDataJSONHelper();

            if (matchs.Count == matchcount)
            {
                foreach (string paramStr in matchs)
                {
                    string[] paramArr = paramStr.Split('^');
                    json.success = true;
                    for (int i = 1; i <= paramArr.Length; i++)
                    {
                        json.AddMatch("match_"+i, paramArr[i]);
                        json.MatchOk();
                    }
                }
                json.mtotlalCount = matchcount;
            }
            if (sclasss.Count == sclasscount)
            {
                foreach (string paramStr in sclasss)
                {
                    string[] paramArr = paramStr.Split('^');
                    json.success = true;
                    for (int i = 1; i <= paramArr.Length; i++)
                    {
                        json.AddClass("class_"+i, paramArr[i]);
                        json.ClassOk();
                    }
                }
                json.ctotlalCount = sclasscount;
            }
            json.singleInfo = matchdate;
            return json.ToString();
        }