Beispiel #1
0
        /// <summary>
        /// 买水
        /// </summary>
        /// <param name="ticket">水</param>
        /// <param name="gold">投注额</param>
        /// <param name="homeTeam">是否买主队</param>
        /// <returns>购买结果</returns>
        public bool Buy(TicketEntity ticket, int gold, bool homeTeam = true)
        {
            //确定场次
            ///webroot/restricted/plain/ticket.aspx?id=18468326&odds=0.95&op=h&hdpType=&isor=0&hidRefreshOdds=&hidAuto=&loginname=3681731cf5dfbf7ef56a886d69457ef3

            var param = new Dictionary<string, object>{
                {"id", (homeTeam? ticket.HomeGameNum: ticket.AwayGameNum)},
                {"odds", homeTeam?ticket.HomeOdds: ticket.AwayOdds},
                {"op", homeTeam?"h":"a"},//主队还是客队
                {"isor","0"},
                {"style","1"},
                {"hdpType","1"},
                {"loginname",this.Session["uid"]}
            };

            var response = samwaterClient.Get(this.BaseUrl + "/webroot/restricted/plain/ticket.aspx", param);
            Debug.WriteLine(response);
            Console.WriteLine(response);
            //634924616422406000<script>var d=[1,'英格蘭超級聯賽','昆士柏流浪','利物浦',['上半場亞洲盤',7],'亞洲盤:0.25','昆士柏流浪','h','0.91','',1,25,30000,0,2,,'True','False',0,'','','',0,0,18468326,1,'h',137271,0];parent.leftWindow.showTicket(1,d,2);</script>

            if (response.Contains(ticket.HomeTeam) && response.Contains(ticket.AwayTeam)) {

                //设定金额购买
                ///webroot/restricted/ticket/confirmbet.aspx?stake=50&betcount=0&loginname=3681731cf5dfbf7ef56a886d69457ef3&stakeInAuto=50
                param = new Dictionary<string, object>{
                    {"stake",gold},
                    {"stakeInAuto",gold},
                    {"loginname",this.Session["uid"]},
                    {"betcount",0},
                    {"ostyle",""},
                    {"betpage",""}
                };

                response = samwaterClient.Get(this.BaseUrl + "/webroot/restricted/ticket/confirmbet.aspx", param,
                    referer: this.BaseUrl + "/webroot/restricted/HomeLeft.aspx");
                Debug.WriteLine(response);
                Console.WriteLine(response);

                if (response.Contains("parent.frames['BCIFrame'].resetBC(")) {
                    return true;
                }

                /*POST:/webroot/restricted/plain/menu-frame.aspx
                    action	getEC
                    counter	1
                    */
                /*
                //counter
                param = new Dictionary<string, object>{
                    {"action","getEC"},
                    {"counter",1},
                };

                response = samwaterClient.Post(this.BaseUrl + "/webroot/restricted/plain/menu-frame.aspx", param,
                    referer: this.BaseUrl + "/webroot/restricted/HomeLeft.aspx");

                Debug.WriteLine(response);
                Console.WriteLine(response);
                */
            }

            return false;
        }
Beispiel #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ticket"></param>
        /// <param name="gold"></param>
        /// <param name="homeTeam">是否买主场</param>
        /// <returns></returns>
        public bool Buy(TicketEntity ticket, int gold, bool homeTeam = true)
        {
            var param = new Dictionary<string, object>{
                {"gid", ticket.Id},
                {"gnum",homeTeam? ticket.HomeGameNum: ticket.AwayGameNum},
                {"uid", Session["uid"] },
                {"type",homeTeam?"H": "C"},
                {"odd_f_type","H"},
                {"strong","H"},
                {"langx","zh-cn"}
               };

            var buyUrl = BaseUrl + "/app/member/FT_order/FT_order_r.php";

            //GET 购买页
            var buyHtml = hg3088Client.Get(buyUrl, param);

            //去掉html的注释
            var regexHtmlComment = new Regex("<!--([^-]+)-->", RegexOptions.Multiline);
            buyHtml = regexHtmlComment.Replace(buyHtml, string.Empty);

            //已停止购买
            if (buyHtml.Contains("wager_finish.php")) {
                Debug.WriteLine("已停止购买!");
                return false;
            }

            //解析购买页:把购买页的隐藏元素name、value解析成字典表,用于Post到购买url
            var buyParam = MatchDictionary(RegexHiddenElement, buyHtml);

            if (buyParam.Count < 10) {
                return false;
            }

            //设置金额
            buyParam["gold"] = gold;

            /*
            var param = new Dictionary<string, object>{
                {"gold",gold},
                {"uid", Session["uid"] },
                {"langx","zh-cn"},
                {"active","1"},
                {"strong","H"},//??
                {"line_type","3"},//??
                {"gid", ticket.Id},
                {"gnum",homeTeam? ticket.HomeGameNum: ticket.AwayGameNum},
                {"type","H"},//??
                {"concede_r","1"},
                {"radio_r","50"},//??
                {"ioradio_r_h","0.96"},
                {"gmax_single","20000"},
                {"gmin_single","50"},
                {"singlecredit","100000"},
                {"singleorder","100000"},
                {"restsinglecredit","0"},
                {"wagerstotal","100000"},
                {"restcredit","10000"},
                {"pay_type","0"},
                {"odd_f_type","M"},
            };
            */

            //POST 购买页
            var refererUrl = HttpClient.CombineUrl(buyUrl, param);
            var response = hg3088Client.Post(buyUrl, buyParam, referer: refererUrl);

            //判断是否交易成功
            if (response.Contains("成功提交") || response.Contains("交易成功")) {
                return true;
            }

            var regexFinishUrl = new Regex("window.location.href='([^']+)'", RegexOptions.IgnoreCase | RegexOptions.Multiline);
            var matchFinishUrl = regexFinishUrl.Match(response);
            if (matchFinishUrl.Success) {
                var finishUrl = matchFinishUrl.Groups[1].Value;
                finishUrl = HttpUtility.UrlDecode(finishUrl);
                //response = hg3088Client.Get(finishUrl);
                response = GetBraceText(finishUrl, "msgStr=", "&");
                Debug.WriteLine(response);
                Console.WriteLine(response);
                /*
                if (response.Contains("交易失败,请重新交易")) {
                    return false;
                }
                else {
                    return false;
                }*/
            }

            return false;
        }
Beispiel #3
0
        /// <summary>
        /// 分析
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public TicketEntity[] Parse(string content)
        {
            var ticketList = new List<TicketEntity>();
            content = content.ConvertToGB();

            //数据分组
            var rawDataList = MatchMulti(RegexGroup, content).ToArray();

            if (rawDataList.Length < 3) {
                //冇数据
                Console.WriteLine("无数据!");
                return ticketList.ToArray();
            }

            //匹配联盟
            var teamGroups = MatchDictionary(RegexTeamGroup, rawDataList[0]);

            //匹配球队
            var teams = new Dictionary<string, TeamEntity>();
            var matches = RegexTeam.Matches(rawDataList[1]);

            foreach (Match match in matches) {
                if (!match.Success) {
                    break;
                }

                var matchGroup = new Dictionary<string, object>();

                teams.Add(match.Groups["GAMEID"].Value, new TeamEntity {
                    GameId = match.Groups["GAMEID"].Value,
                    GroupId = match.Groups["GROUPID"].Value,
                    HomeTeam = match.Groups["HOMETEAM"].Value,
                    AwayTeam = match.Groups["AWAYTEAM"].Value,
                    GameTime = match.Groups["GAMETIME"].Value
                });
            }

            //匹配球队与赔率关系表
            var teamOddsReleation = MatchDictionary(RegexTeamOddsReleation, rawDataList[2]);

            //匹配赔率
            matches = RegexOdds.Matches(content);

            foreach (Match match in matches) {
                if (!match.Success) {
                    break;
                }

                var entity = new TicketEntity();
                //"\[\d+,\[(?<key>\d+),(?<pankou>\d+),\S+?\],\[(?<odds>\S+?)\]"
                entity.GameType = match.Groups["pankou"].Value;

                //判断是否全场让球
                if (!entity.GameType.In("1", "")) {
                    continue;
                }
                var key = match.Groups["key"].Value;

                if (!teamOddsReleation.ContainsKey(key)) {
                    continue;
                }
                var teamid = (string)teamOddsReleation[key];

                var team = teams[teamid];

                if (team == null) {
                    throw new Exception("找不到teamid:" + teamid + "!");
                    continue;
                }

                entity.Id = key;
                entity.HomeTeam = team.HomeTeam;
                entity.AwayTeam = team.AwayTeam;
                entity.Group = (string)teamGroups[team.GroupId];

                DateTime dt;
                DateTime.TryParse(team.GameTime, out   dt);
                entity.StartTime = dt;

                var oddsText = match.Groups["odds"].Value;
                var odds = oddsText.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries)
                    .Select(c => c.Contains("'") ? c.Trim('\'') : c)
                    .ToArray();

                entity.HomeOdds = double.Parse(odds[0]);
                entity.AwayOdds = double.Parse(odds[1]);
                entity.HomeGameNum = entity.AwayGameNum = match.Groups["buyid"].Value;
                ticketList.Add(entity);
            }

            return ticketList.ToArray();
        }
Beispiel #4
0
        private TicketEntity DigValue(string content)
        {
            var sp = content.Split(new string[] { "','" }, StringSplitOptions.None);
            var ticket = new TicketEntity();
            ticket.Id = sp[0].Substring(1);
            ticket.HomeGameNum = sp[3];
            ticket.AwayGameNum = sp[4];
            ticket.HomeTeam = sp[5];
            ticket.AwayTeam = sp[6];
            ticket.GameType = sp[8];
            try {
                ticket.HomeOdds = double.Parse(sp[9]);
                ticket.AwayOdds = double.Parse(sp[10]);
                //12-23<br>05:30a<br>
                var dateText = DateTime.Today.Year + "-" + sp[1].Substring(0, 5) + " " + sp[1].Substring(9, 5);
                DateTime date;
                if (DateTime.TryParse(dateText, out date)) {
                    if (sp[1][14] == 'p') {
                        date.AddHours(12);
                    }

                    ticket.StartTime = date;
                }
            }
            catch (Exception ex) {
                Debug.WriteLine(ex);
                return null;
            }

            return ticket;
        }