コード例 #1
0
        public Lottery fetchLottery(int id)
        {
            HtmlWeb htmlWeb = new HtmlWeb();

            htmlWeb.OverrideEncoding = Encoding.GetEncoding("GB2312");

            HtmlDocument doc = htmlWeb.Load("http://www.17500.cn/ssq/details.php?issue=" + id);

            HtmlNode idNode = doc.DocumentNode.SelectSingleNode("//td[not(@valign) and @align='right']");

            if (idNode == null)
            {
                return null;
            }

            Lottery lottery = new Lottery();

            lottery.ID = id;

            lottery.DATE = DateTime.Parse(idNode.InnerText.Replace("开奖", "").Trim());

            HtmlNodeCollection nodes = doc.DocumentNode.SelectNodes("//td/font[@color='red']");

            if (nodes.Count == 6)
            {
                lottery.RED1 = int.Parse(nodes[0].InnerText.Trim());
                lottery.RED2 = int.Parse(nodes[1].InnerText.Trim());
                lottery.RED3 = int.Parse(nodes[2].InnerText.Trim());
                lottery.RED4 = int.Parse(nodes[3].InnerText.Trim());
                lottery.RED5 = int.Parse(nodes[4].InnerText.Trim());
                lottery.RED6 = int.Parse(nodes[5].InnerText.Trim());
            }

            lottery.BLUE = int.Parse(doc.DocumentNode.SelectSingleNode("//font[@color='blue']").InnerText);

            LotteryUtils.GetInstance().CalcLotteryTrait(lottery);

            return lottery;
        }
コード例 #2
0
        /// <summary>
        /// 配置Lottery特征
        /// </summary>
        /// <param name="lottery"></param>
        public void CalcLotteryTrait(Lottery lottery)
        {
            lottery.RTOTAL = lottery.RED1 + lottery.RED2 + lottery.RED3 + lottery.RED4 + lottery.RED5 + lottery.RED6;
            lottery.RAVERAGE = lottery.RTOTAL / 6;
            lottery.TOTAL = lottery.RED1 + lottery.RED2 + lottery.RED3 + lottery.RED4 + lottery.RED5 + lottery.RED6 + lottery.BLUE;
            lottery.AVERAGE = lottery.TOTAL / 7;
            lottery.ODD = 0;
            lottery.EVEN = 0;

            if (lottery.RED1 % 2 > 0)
            {
                lottery.ODD++;
            }
            else
            {
                lottery.EVEN++;
            }

            if (lottery.RED2 % 2 > 0)
            {
                lottery.ODD++;
            }
            else
            {
                lottery.EVEN++;
            }

            if (lottery.RED3 % 2 > 0)
            {
                lottery.ODD++;
            }
            else
            {
                lottery.EVEN++;
            }

            if (lottery.RED4 % 2 > 0)
            {
                lottery.ODD++;
            }
            else
            {
                lottery.EVEN++;
            }

            if (lottery.RED5 % 2 > 0)
            {
                lottery.ODD++;
            }
            else
            {
                lottery.EVEN++;
            }

            if (lottery.RED6 % 2 > 0)
            {
                lottery.ODD++;
            }
            else
            {
                lottery.EVEN++;
            }

            if (lottery.BLUE % 2 > 0)
            {
                lottery.ODD++;
            }
            else
            {
                lottery.EVEN++;
            }

            lottery.RKEY = lottery.RED1 + "," + lottery.RED2 + "," + lottery.RED3 + "," + lottery.RED4 + "," + lottery.RED5 + "," + lottery.RED6;
            lottery.WKEY = lottery.RED1 + "," + lottery.RED2 + "," + lottery.RED3 + "," + lottery.RED4 + "," + lottery.RED5 + "," + lottery.RED6 + "," + lottery.BLUE;
        }
コード例 #3
0
 /// <summary>
 /// 匹配蓝号
 /// </summary>
 /// <param name="lottery"></param>
 /// <param name="num"></param>
 /// <returns></returns>
 public bool BlueContainGivenNum(Lottery lottery, int num)
 {
     return false;
 }
コード例 #4
0
 /// <summary>
 /// 匹配红号
 /// </summary>
 /// <param name="lottery"></param>
 /// <param name="num"></param>
 /// <returns></returns>
 public bool RedContainsGivenNum(Lottery lottery, int num)
 {
     return false;
 }
コード例 #5
0
 /// <summary>
 /// 匹配全部
 /// </summary>
 /// <param name="lottery"></param>
 /// <param name="num"></param>
 /// <returns></returns>
 public bool ContainGivenNum(Lottery lottery, int num)
 {
     return RedContainsGivenNum(lottery, num) | BlueContainGivenNum(lottery, num);
 }