Ejemplo n.º 1
0
        /// <summary>
        /// 北京单场
        /// </summary>
        private void GetBjdc()
        {
            try
            {
                var Past_IssueNo = _SportService.GetNowIssuNo("zqdc");
                var anode        = CommonHelper.GetBJDCExpect("http://zx.500.com/zqdc/kaijiang.php");
                var NowIssueNo   = anode.Select(x => Convert.ToInt32(x.Attributes["value"].Value)).Where(x => x >= Convert.ToInt32(Past_IssueNo)).ToList();
                foreach (var code in NowIssueNo)
                {
                    try
                    {
                        List <jczq> jczqs     = new List <jczq>();
                        var         tableNode = CommonHelper.LoadGziphtml("http://zx.500.com/zqdc/kaijiang.php?&expect=" + code, CollectionUrlEnum.url_500zx).DocumentNode.SelectSingleNode("//table[@class='ld_table']");
                        if (tableNode == null)
                        {
                            Console.WriteLine($"奖期{code}北京单场获取根节点失败");
                            continue;
                        }
                        //获取平均欧赔
                        var trNodes = CommonHelper.LoadGziphtml("http://zx.500.com/zqdc/kaijiang.php?playid=1&expect=" + code, CollectionUrlEnum.url_500zx).DocumentNode.SelectSingleNode("//table[@class='ld_table']").SelectNodes("tr").Skip(1);
                        if (trNodes == null)
                        {
                            Console.WriteLine($"奖期{code}北京单场获取平均欧赔节点失败");
                            continue;
                        }
                        var trNode = tableNode.SelectNodes("tr").Skip(1);

                        int  OpIndex = 1;
                        jczq jczq;
                        //赛果开奖情况
                        foreach (var item in trNode)
                        {
                            OpIndex++;
                            jczq    = new jczq();
                            jczq.id = code.ToString();
                            int tdIndex   = 1;
                            var game      = new GameType();
                            var GameTypes = new List <GameType>();
                            foreach (var item2 in item.SelectNodes("td"))
                            {
                                string strText = Regex.Replace(item2.InnerHtml, "<[^>]+>", "");//不包含>的任意字符,字符个数不限,但至少一个字符
                                if (strText == "&nbsp;")
                                {
                                    continue;
                                }
                                switch (tdIndex)
                                {
                                case 1:
                                    jczq.TournamentNumber = strText;
                                    break;

                                case 2:
                                    jczq.League_Color   = item2.SelectSingleNode("a").Attributes["style"].Value.Replace("background-color:", "");
                                    jczq.TournamentType = strText;
                                    break;

                                case 3:
                                    jczq.MatchTime = strText;
                                    break;

                                case 4:
                                    jczq.HomeTeam = strText;
                                    break;

                                case 5:
                                    jczq.LetBall = strText;
                                    break;

                                case 6:
                                    jczq.VisitingTeam = strText;
                                    break;

                                case 7:
                                    jczq.Score = strText;
                                    break;

                                case 8:
                                    game.game       = Game.让球胜平负;
                                    game.FruitColor = strText;
                                    break;

                                case 9:
                                    game.Bonus = strText;
                                    GameTypes.Add(game);
                                    break;

                                case 10:
                                    game            = new GameType();
                                    game.game       = Game.总进球数;
                                    game.FruitColor = strText;
                                    break;

                                case 11:
                                    game.Bonus = strText;
                                    GameTypes.Add(game);
                                    break;

                                case 12:
                                    game            = new GameType();
                                    game.game       = Game.比分;
                                    game.FruitColor = strText;
                                    break;

                                case 13:
                                    game.Bonus = strText;
                                    GameTypes.Add(game);
                                    break;

                                case 14:
                                    game            = new GameType();
                                    game.game       = Game.单双;
                                    game.FruitColor = strText;
                                    break;

                                case 15:
                                    game.Bonus = strText;
                                    GameTypes.Add(game);
                                    break;

                                case 16:
                                    game            = new GameType();
                                    game.game       = Game.半全场;
                                    game.FruitColor = strText;
                                    break;

                                case 17:
                                    game.Bonus = strText;
                                    GameTypes.Add(game);
                                    jczq.gameTypes.AddRange(GameTypes);
                                    break;
                                }
                                tdIndex = tdIndex + 1;
                            }
                            int indexop = 1;
                            foreach (var item3 in trNodes)
                            {
                                indexop++;
                                if (indexop != OpIndex)
                                {
                                    continue;
                                }
                                for (int i = 0; i < item3.SelectNodes("td").Count(); i++)
                                {
                                    if (i > 10 && i < 14)
                                    {
                                        jczq.AvgOuCompensation += item3.SelectNodes("td")[i].InnerHtml + ",";
                                    }
                                    if (i >= 14)
                                    {
                                        break;
                                    }
                                }
                                break;
                            }
                            jczq.AvgOuCompensation = jczq.AvgOuCompensation.Substring(0, jczq.AvgOuCompensation.Length - 1);
                            jczqs.Add(jczq);
                        }
                        _SportService.Add_BJDC(jczqs);
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 北京单场开奖SP
        /// </summary>
        /// <returns></returns>
        public List <jczq> GetBjdc(string Expect)
        {
            List <jczq> jczqs = new List <jczq>();

            if (Expect == "181203")
            {
                var tableNode = CommonHelper.LoadGziphtml("http://zx.500.com/zqdc/kaijiang.php?&expect=" + Expect).DocumentNode.SelectSingleNode("//table[@class='ld_table']");
                //获取平均欧赔
                var trNodes = CommonHelper.LoadGziphtml("http://zx.500.com/zqdc/kaijiang.php?playid=1&expect=" + Expect).DocumentNode.SelectSingleNode("//table[@class='ld_table']").SelectNodes("tr").Skip(1);

                var trNode = tableNode.SelectNodes("tr").Skip(1);

                int OpIndex = 1;



                jczq jczq;

                //赛果开奖情况
                foreach (var item in trNode)
                {
                    OpIndex++;
                    jczq = new jczq();
                    int tdIndex   = 1;
                    var game      = new GameType();
                    var GameTypes = new List <GameType>();
                    foreach (var item2 in item.SelectNodes("td"))
                    {
                        string strText = Regex.Replace(item2.InnerHtml, "<[^>]+>", "");//不包含>的任意字符,字符个数不限,但至少一个字符
                        if (strText == "&nbsp;")
                        {
                            continue;
                        }
                        switch (tdIndex)
                        {
                        case 1:
                            jczq.TournamentNumber = strText;
                            break;

                        case 2:
                            jczq.League_Color   = item2.SelectSingleNode("a").Attributes["style"].Value.Replace("background-color:", "");
                            jczq.TournamentType = strText;
                            break;

                        case 3:
                            jczq.MatchTime = strText;
                            break;

                        case 4:
                            jczq.HomeTeam = strText;
                            break;

                        case 5:
                            jczq.LetBall = strText;
                            break;

                        case 6:
                            jczq.VisitingTeam = strText;
                            break;

                        case 7:
                            jczq.Score = strText;
                            break;

                        case 8:
                            game.game       = Game.让球胜平负;
                            game.FruitColor = strText;
                            break;

                        case 9:
                            game.Bonus = strText;
                            GameTypes.Add(game);
                            break;

                        case 10:
                            game            = new GameType();
                            game.game       = Game.总进球数;
                            game.FruitColor = strText;
                            break;

                        case 11:
                            game.Bonus = strText;
                            GameTypes.Add(game);
                            break;

                        case 12:
                            game            = new GameType();
                            game.game       = Game.比分;
                            game.FruitColor = strText;
                            break;

                        case 13:
                            game.Bonus = strText;
                            GameTypes.Add(game);
                            break;

                        case 14:
                            game            = new GameType();
                            game.game       = Game.单双;
                            game.FruitColor = strText;
                            break;

                        case 15:
                            game.Bonus = strText;
                            GameTypes.Add(game);
                            break;

                        case 16:
                            game            = new GameType();
                            game.game       = Game.半全场;
                            game.FruitColor = strText;
                            break;

                        case 17:
                            game.Bonus = strText;
                            GameTypes.Add(game);
                            jczq.gameTypes.AddRange(GameTypes);
                            break;
                        }



                        tdIndex = tdIndex + 1;
                    }

                    int indexop = 1;
                    foreach (var item3 in trNodes)
                    {
                        indexop++;
                        if (indexop != OpIndex)
                        {
                            continue;
                        }
                        for (int i = 0; i < trNodes.Count(); i++)
                        {
                            if (i > 10 && i < 14)
                            {
                                jczq.AvgOuCompensation += item3.SelectNodes("td")[i].InnerHtml + ",";
                            }
                            if (i >= 14)
                            {
                                break;
                            }
                        }
                        break;
                    }
                    jczq.AvgOuCompensation = jczq.AvgOuCompensation.Substring(0, jczq.AvgOuCompensation.Length - 1);
                    jczqs.Add(jczq);
                }
            }
            return(jczqs);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 竞彩足球
        /// </summary>
        private void GetJCZQ()
        {
            try
            {
                var      JCDate  = _SportService.GetJCZQ_JCDate();
                DateTime olddate = Convert.ToDateTime(JCDate) == null || String.IsNullOrEmpty(JCDate) == true?DateTime.Now.AddMonths(-1) : Convert.ToDateTime(JCDate);

                string date = DateTime.Now.ToString("yyyy-MM-dd");
                var    span = Convert.ToInt32(Math.Ceiling((Convert.ToDateTime(date) - olddate).TotalDays));
                for (int h = 0; h <= span; h++)
                {
                    try
                    {
                        var tableNode = CommonHelper.LoadGziphtml("http://zx.500.com/jczq/kaijiang.php?d=" + olddate.AddDays(h).ToString("yyyy-MM-dd"), CollectionUrlEnum.url_500zx).DocumentNode.SelectSingleNode("//table[@class='ld_table']");
                        if (tableNode == null)
                        {
                            Console.WriteLine($"奖期{olddate.AddDays(h).ToString("yyyy-MM-dd")}竞猜足球获取根节点失败");
                            continue;
                        }
                        //获取平均欧赔
                        var trNodess = CommonHelper.LoadGziphtml("http://zx.500.com/jczq/kaijiang.php?playid=4&d=" + olddate.AddDays(h).ToString("yyyy-MM-dd"), CollectionUrlEnum.url_500zx).DocumentNode.SelectSingleNode("//table[@class='ld_table']");
                        if (trNodess == null)
                        {
                            Console.WriteLine($"奖期{olddate.AddDays(h).ToString("yyyy-MM-dd")}竞猜足球获取平均欧赔失败");
                            continue;
                        }
                        var         trNodes = trNodess.SelectNodes("tr").Skip(1);
                        var         trNode  = tableNode.SelectNodes("tr").Skip(1);
                        int         OpIndex = 1;
                        List <jczq> jczqs   = new List <jczq>();
                        jczq        jczq;
                        var         game      = new GameType();
                        var         GameTypes = new List <GameType>();
                        //赛果开奖情况
                        foreach (var item in trNode)
                        {
                            OpIndex++;
                            jczq    = new jczq();
                            jczq.id = olddate.AddDays(h).ToString("yyyy-MM-dd");
                            int tdIndex = 1;
                            foreach (var item2 in item.SelectNodes("td"))
                            {
                                string strText = Regex.Replace(item2.InnerHtml, "<[^>]+>", "");//不包含>的任意字符,字符个数不限,但至少一个字符
                                if (strText == "&nbsp;")
                                {
                                    continue;
                                }
                                switch (tdIndex)
                                {
                                case 1:
                                    jczq.TournamentNumber = strText;
                                    break;

                                case 2:
                                    jczq.League_Color   = item2.SelectSingleNode("a").Attributes["style"].Value.Replace("background-color:", "");
                                    jczq.TournamentType = strText;
                                    break;

                                case 3:
                                    jczq.MatchTime = strText;
                                    break;

                                case 4:
                                    jczq.HomeTeam = strText;
                                    break;

                                case 5:
                                    jczq.LetBall = strText;
                                    break;

                                case 6:
                                    jczq.VisitingTeam = strText;
                                    break;

                                case 7:
                                    jczq.Score = strText;
                                    break;

                                case 8:
                                    GameTypes.Clear();
                                    game            = new GameType();
                                    game.game       = Game.让球胜平负;
                                    game.FruitColor = strText;

                                    break;

                                case 9:
                                    game.Bonus = strText;
                                    GameTypes.Add(game);
                                    break;

                                case 10:
                                    game            = new GameType();
                                    game.game       = Game.胜平负;
                                    game.FruitColor = strText;
                                    break;

                                case 11:
                                    game.Bonus = strText;
                                    GameTypes.Add(game);
                                    break;

                                case 12:
                                    game            = new GameType();
                                    game.game       = Game.总进球数;
                                    game.FruitColor = strText;
                                    break;

                                case 13:
                                    game.Bonus = strText;
                                    GameTypes.Add(game);
                                    break;

                                case 14:
                                    game            = new GameType();
                                    game.game       = Game.半全场;
                                    game.FruitColor = strText;
                                    break;

                                case 15:
                                    game.Bonus = strText;
                                    GameTypes.Add(game);
                                    break;
                                }
                                tdIndex = tdIndex + 1;
                            }
                            int indexop = 1;
                            foreach (var item3 in trNodes)
                            {
                                indexop++;
                                if (indexop != OpIndex)
                                {
                                    continue;
                                }
                                for (int i = 0; i < item3.SelectNodes("td").Count(); i++)
                                {
                                    if (i == 7)
                                    {
                                        game            = new GameType();
                                        game.game       = Game.比分;
                                        game.FruitColor = item3.SelectNodes("td")[i].InnerHtml;
                                    }
                                    if (i == 9)
                                    {
                                        game.Bonus = item3.SelectNodes("td")[i].InnerHtml;
                                        GameTypes.Add(game);
                                        jczq.gameTypes.AddRange(GameTypes);
                                    }

                                    if (i > 10 && i < 14)
                                    {
                                        jczq.AvgOuCompensation += item3.SelectNodes("td")[i].InnerHtml + ",";
                                    }
                                    //if (i >= 14)
                                    //{
                                    //}
                                }
                            }
                            jczq.AvgOuCompensation = jczq.AvgOuCompensation.Substring(0, jczq.AvgOuCompensation.Length - 1);
                            jczqs.Add(jczq);
                        }
                        _SportService.Add_JCZQ(jczqs);
                        Console.WriteLine("采集足球" + olddate.AddDays(h).ToString("yyyy-MM-dd") + "采集完成,共" + jczqs.Count + "条");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("采集足球出错:" + ex.Message);
                        log.Error("采集足球出错:" + ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("采集足球出错:" + ex.Message);
                log.Error(ex.Message);
            }
        }