def getGames(self, gameID, season): responseStr = '' url = 'http://ios.win007.com/phone/CupSaiCheng.aspx?ID=' + str( self.leagueModel.leagueID ) + '&lang=0&Season=' + season + '&GroupId=' + str(gameID) print url responseStr = get_resultstr_with_url(url) if responseStr != '': if '$$$$' in responseStr: # 非小组赛 array = responseStr.split('$$$$') subGameStr = array[1] if len(subGameStr) > 0: games = creatCupGameModelWithComplexStr( subGameStr, self.leagueModel.breifLeagueName) self.allGames.extend(games) elif '$$' in responseStr: # 小组赛 array = responseStr.split('$$') subGameStr = array[2] if len(subGameStr) > 0: games = creatCupGameModelWithComplexStr( subGameStr, self.leagueModel.breifLeagueName) self.allGames.extend(games) else: pass
def GetRound(leaguename, leagueID, leagueSubID, gameRound, reason): resultStr = '' try: if gameRound == 0: url = "http://ios.win007.com/phone/SaiCheng2.aspx?sclassid=" + str( leagueID).encode('utf-8') + "&season=" + reason + "&subid=" + str( leagueSubID).encode('utf-8') + "&apiversion=1&from=2" else: url = "http://ios.win007.com/phone/SaiCheng2.aspx?sclassid=" + str( leagueID).encode('utf-8') + "&season=" + reason + "&subid=" + str( leagueSubID).encode('utf-8') + "&round=" + str(gameRound).encode('utf-8') + "&apiversion=1&from=2" print url except BaseException as e: print e pass resultStr = get_resultstr_with_url(url) games = [] if resultStr != '': games = creatGameModelWithComplexStr(resultStr, leaguename) return games
def getOneGameODD(host,game): resultStr = '' url = '' try: # url = 'http://xxx:8072/phone/1x2.aspx?ID=' + str(game.soccerID) + '&an=iosQiuTan&av=5.9&from=2&lang=0&subversion=1' url = '%s/phone/1x2.aspx?ID=%s&an=iosQiuTan&av=5.9&from=2&lang=0&subversion=1' % (host, str(game.soccerID)) except BaseException as e: print e pass if url != '': resultStr = get_resultstr_with_url(url) if resultStr != '': array = resultStr.split('!') companys = [] for unit in array: # print unit.decode('utf-8') company = BetCompany() company.league = game.leauge company.result = game.soccer company.homeSoccer = game.allHome company.friendSoccer = game.allFriend company.soccerGameId = game.soccerID unitArray = unit.split('^') try: company.companyTitle = unitArray[0].encode('utf-8') company.orignal_winOdd = float(unitArray[2]) company.orignal_drawOdd = float(unitArray[3]) company.orignal_loseOdd = float(unitArray[4]) company.winOdd = float(unitArray[5]) company.drawOdd = float(unitArray[6]) company.loseOdd = float(unitArray[7]) except IndexError as e: print e print unitArray companys.append(company) if company.companyTitle == '澳门': game.orignal_aomenOdd = (company.orignal_winOdd, company.orignal_drawOdd, company.orignal_loseOdd) game.now_aomenOdd = (company.winOdd, company.drawOdd, company.loseOdd) return companys else: return []
def getCupDetails(self, season): resultStr = '' self.orignalCupURL = 'http://ios.win007.com/phone/CupSaiCheng.aspx?ID=' + str( self.leagueModel.leagueID).encode( 'utf-8') + '&lang=0&Season=' + season print self.orignalCupURL resultStr = get_resultstr_with_url(self.orignalCupURL) # 1.非顶级联赛;正在进行的赛季 if resultStr != '': if '$$$$' in resultStr: # 非小组赛 array = resultStr.split('$$$$') subGameStr = array[0] if len(subGameStr) > 0: for subStr in subGameStr.split('!'): if len(subStr) > 0: gameIDArray = subStr.split('^') newDic = {} if len(gameIDArray) > 2: newDic['id'] = gameIDArray[0] newDic['dec'] = gameIDArray[1] newDic['bool'] = gameIDArray[2] if len(newDic) > 0: self.GamesArray.append(newDic) elif '$$' in resultStr: # 小组赛 array = resultStr.split('$$') subGameStr = array[0] if len(subGameStr) > 0: for subStr in subGameStr.split('!'): if len(subStr) > 0: gameIDArray = subStr.split('^') newDic = {} if len(gameIDArray) > 2: newDic['id'] = gameIDArray[0] newDic['dec'] = gameIDArray[1] newDic['bool'] = gameIDArray[2] if len(newDic) > 0: self.GamesArray.append(newDic) else: pass
def GetLeagueDetails(self): self.orignalLeagueURL = 'http://ios.win007.com/phone/SaiCheng2.aspx?sclassid=' \ + str(self.leagueModel.leagueID).encode( 'utf-8') + '&season=' + self.currentSeason + '&subid=0&apiversion=1&from=2' resultStr = get_resultstr_with_url(self.orignalLeagueURL) if resultStr != '': print resultStr array = resultStr.split('$$') if '!' in array[0]: leagueStr = array[0] subLeagueArray = leagueStr.split('!') for subLeagueStr in subLeagueArray: if len(subLeagueStr) > 0: gameIDArray = subLeagueStr.split('^') newDic = {} if len(gameIDArray) > 2: newDic['id'] = gameIDArray[0] newDic['dec'] = gameIDArray[1] newDic['subdec'] = gameIDArray[2] newDic['flag'] = gameIDArray[3] newDic['count'] = gameIDArray[4] newDic['round'] = gameIDArray[5] if len(newDic) > 0: self.allSubLeagues.append(newDic) else: print '不包含附加赛' + 'header' + array[0] gameIDArray = array[0].split('^') newDic = {} if len(gameIDArray) > 3: newDic['id'] = gameIDArray[0] newDic['dec'] = gameIDArray[1] newDic['subdec'] = gameIDArray[2] newDic['flag'] = gameIDArray[3] newDic['count'] = gameIDArray[4] newDic['round'] = gameIDArray[5] else: newDic['count'] = gameIDArray[0] newDic['round'] = gameIDArray[1] if len(newDic) > 0: self.allSubLeagues.append(newDic)
def GetLeagueJiFen(self, pointskind='0', season='2017-2018'): resultStr = '' self.jifenURL = 'http://%s:8072/phone/Jifen2.aspx?an=iosQiuTan&av=6.5&from=2&pointsKind=%s&r=1532144326&sclassid=%s&season=%s&subVersion=2&subid=0' % ( self.httpHost, pointskind, str( self.leagueModel.leagueID).encode('utf-8'), self.currentSeason) print '获取联赛: %s 赛季: %s 积分数据 url %s' % (str( self.leagueModel.leagueID).encode('utf-8'), season, self.jifenURL) resultStr = get_resultstr_with_url(self.jifenURL) if resultStr != '': print resultStr array = resultStr.split('$$') if len(array) > 2: jifenDataStr = array[2] teamDataArr = jifenDataStr.split('!') for teamDataStr in teamDataArr: if len(teamDataStr) > 0: temp_TeamPoints = TeamPoints() self.teamPointsArr.append(temp_TeamPoints) teamPointArr = teamDataStr.split('^') try: # 1^24^切尔西^車路士^38^30^3^5^85^33^93^0^0^^^0 temp_TeamPoints.season = season temp_TeamPoints.league = self.leagueModel.breifLeagueName temp_TeamPoints.ranking = int(teamPointArr[0]) temp_TeamPoints.teamID = int(teamPointArr[1]) temp_TeamPoints.teamName = teamPointArr[2] temp_TeamPoints.seasonRound = int(teamPointArr[4]) temp_TeamPoints.winCount = int(teamPointArr[5]) temp_TeamPoints.drawCount = int(teamPointArr[6]) temp_TeamPoints.loseCount = int(teamPointArr[7]) temp_TeamPoints.getScore = int(teamPointArr[8]) temp_TeamPoints.loseScore = int(teamPointArr[9]) temp_TeamPoints.points = int(teamPointArr[10]) except BaseException, e: print '解析比赛积分出错' print e
def GetLeaguePanlu(self, season='2017-2018'): resultStr = '' self.panLuURL = 'http://ios.win007.com/phone/Panlu.aspx?id=%s&season=%s&apiversion=1&from=2' % ( str(self.leagueModel.leagueID).encode('utf-8'), season) print '获取联赛: %s 赛季: %s 盘路数据 url %s' % (str( self.leagueModel.leagueID).encode('utf-8'), season, self.panLuURL) resultStr = get_resultstr_with_url(self.panLuURL) if resultStr != '': print resultStr array = resultStr.split('!') for teamDataStr in array: if len(teamDataStr) > 0: temp_TeamPanLu = TeamPanLu() self.teamPanLuArr.append(temp_TeamPanLu) teamPointArr = teamDataStr.split('^') try: # 1^46^伯恩利^般尼^38^8^7^23^21^4^13^8 temp_TeamPanLu.rankIng = int(teamPointArr[0]) temp_TeamPanLu.teamID = int(teamPointArr[1]) temp_TeamPanLu.jifenRanking = self.GetJifenRanking( temp_TeamPanLu.teamID) temp_TeamPanLu.teamName = teamPointArr[2] temp_TeamPanLu.rounds = int(teamPointArr[4]) temp_TeamPanLu.halfWinPan = int(teamPointArr[5]) temp_TeamPanLu.halfDrawPan = int(teamPointArr[6]) temp_TeamPanLu.halfLosePan = int(teamPointArr[7]) temp_TeamPanLu.winPan = int(teamPointArr[8]) temp_TeamPanLu.drawPan = int(teamPointArr[9]) temp_TeamPanLu.losePan = int(teamPointArr[10]) temp_TeamPanLu.netEarningCounts = int(teamPointArr[11]) temp_TeamPanLu.belongLeagueName = self.leagueModel.breifLeagueName temp_TeamPanLu.season = season except BaseException, e: print '解析联赛盘路出错' print e
def GetLeagueDaXiao(self, season='2017-2018'): resultStr = '' self.DaXiaoURL = 'http://ios.win007.com/phone/Daxiao.aspx?id=%s&season=%s&apiversion=1&from=2' % ( str(self.leagueModel.leagueID).encode('utf-8'), season) print '获取联赛: %s 赛季: %s 大小球数据 url %s' % (str( self.leagueModel.leagueID).encode('utf-8'), season, self.DaXiaoURL) resultStr = get_resultstr_with_url(self.DaXiaoURL) if resultStr != '': print resultStr array = resultStr.split('!') for teamDataStr in array: if len(teamDataStr) > 0: temp_TeamPanLu = TeamPanLu() self.teamDaXiaoArr.append(temp_TeamPanLu) teamPointArr = teamDataStr.split('^') try: # 1^39^上海绿地申花^上海绿地申花^30^19^1^10^63.3%^3.3%^33.3% temp_TeamPanLu.rankIng = int(teamPointArr[0]) temp_TeamPanLu.teamID = int(teamPointArr[1]) temp_TeamPanLu.jifenRanking = self.GetJifenRanking( temp_TeamPanLu.teamID) temp_TeamPanLu.teamName = teamPointArr[2] temp_TeamPanLu.rounds = int(teamPointArr[4]) temp_TeamPanLu.winPan = int(teamPointArr[5]) temp_TeamPanLu.drawPan = int(teamPointArr[6]) temp_TeamPanLu.losePan = int(teamPointArr[7]) temp_TeamPanLu.winRate = teamPointArr[8] temp_TeamPanLu.drawRate = teamPointArr[9] temp_TeamPanLu.loseRate = teamPointArr[10] temp_TeamPanLu.belongLeagueName = self.leagueModel.breifLeagueName temp_TeamPanLu.season = season except BaseException, e: print '解析联赛盘路出错' print e
def GetLeagueDetailFromDB(leagueid=-1, getDataType=0, isCup=False): if leagueid < 0: print '联赛id 非法' return leagueArray = GET_LEAGUE_DETAIL_FROM_DB(leagueid) leagueModel = League() if leagueArray is not None: leagueModel.leagueID = leagueArray[0] leagueModel.leagueName = leagueArray[1].encode('utf-8') leagueModel.breifLeagueName = leagueArray[2].encode('utf-8') leagueModel.aviableSeasonStr = leagueArray[5].encode('utf-8') print leagueModel.aviableSeasonList if '2018-2019' in leagueModel.aviableSeasonList: leagueModel.aviableSeasonList.remove('2018-2019') elif '2018' in leagueModel.aviableSeasonList: leagueModel.aviableSeasonList.remove('2018') httpHomeStr = get_resultstr_with_url( 'http://119.29.29.29/d?ttl=1&dn=txt.city007.net') httpHomeList = httpHomeStr.split(';') host = httpHomeList[0] # 杯赛去请求杯赛接口,逻辑 print isCup if isCup == 0: print '请求杯赛接口' cup = GetCup(leagueModel) cup.cupName = leagueModel.breifLeagueName cup.getOfficialLeague() # 否则全部视为联赛 else: print '请求联赛接口' league = GetLeague(leagueModel) league.httpHost = host if getDataType == 0: league.getOfficialLeague() elif getDataType == 1: league.Get_basic_league_data() elif getDataType == 2: header = leagueModel.aviableSeasonList league.GetLeaguePanlu('2018-2019') currentSeason = '2018-2019' if not len(league.teamPanLuArr) > 0: league.GetLeaguePanlu('2018') currentSeason = '2018' team_panlu_list = [] header.insert(0, currentSeason) header.insert(0, '联赛') header.insert(0, '球队') # header = ['球队', '联赛', # '2018-2019', '2017-2018', '2016-2017', '2015-2016', '2014-2015', '2013-2014', # '2012-2013', '2011-2012', '2010-2011', '2009-2010', '2008-2009', '2007-2008', # '2006-2007', # '2005-2006', '2004-2005', '2003-2004'] for teamPanlu in league.teamPanLuArr: if isinstance(teamPanlu, TeamPanLu): # 插入当前赛季 one_team_data = [ teamPanlu.teamName.decode('utf-8'), leagueModel.breifLeagueName.decode('utf-8'), str(teamPanlu.winPan * 100 / teamPanlu.rounds), '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ] gamelist = get_team_history_panlu_fromdb_with_teamid( teamPanlu.teamID, leagueModel.breifLeagueName) for tempGameTuple in gamelist: if tempGameTuple[0] in header: index = header.index(tempGameTuple[0]) winCount = tempGameTuple[3] rounds = tempGameTuple[2] if rounds == 0: continue rate = str(winCount * 100 / rounds) one_team_data.insert(index, rate) team_panlu_list.append(one_team_data) write_excel(team_panlu_list)
def getTodaySoccer(gameType): # type == 3 竞彩 # type == 1 精简 # type == 2 十四场 # http://119.29.29.29/d?ttl=1&dn=txt.city007.net httpHomeStr = get_resultstr_with_url( 'http://119.29.29.29/d?ttl=1&dn=txt.city007.net') httpHomeList = httpHomeStr.split(';') host = httpHomeList[0] gameType = int(gameType) url = '' resultStr = '' try: # url = "http://%s:8071/phone/schedule_0_%s.txt?an=iosQiuTan&av=6.2&from=2&r=%s" % (host,str(gameType),str(int(time.time()))) # http://61.143.224.156:8071/phone/schedule_0_0.txt?an=iosQiuTan&av=7.1&from=24&r=1535452669 url = "http://61.143.224.156:8071/phone/schedule_0_" + str( gameType) + ".txt?an=iosQiuTan&av=7.1&from=24&r=" + str( int(time.time())) print url except Exception as e: print '请求接口出错' + url print e if url != '': resultStr = get_resultstr_with_url(url) global AllGames global AllBeginTimes if resultStr != '': # print resultStr allArray = resultStr.split('$$') if gameType == 1: leagueStr = allArray[0] else: leagueStr = allArray[1] allLeague = leagueStr.split('!') dic = {} for league in allLeague: oneLeague = league.split('^') dic[oneLeague[1]] = oneLeague[0].encode('utf-8') if gameType == 1: gameStr = allArray[1] else: gameStr = allArray[2] games = gameStr.split('!') # 获取当前时间戳 nowTimestamp = time.time() contentStr = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><title>初盘预测</title></head><body>" for game in games: onegame = FootballGame() oneGameArray = game.split('^') oneGameArray.remove('') onegame.soccerID = int(oneGameArray[0]) onegame.leauge = dic.get(oneGameArray[1]) beginTime = oneGameArray[3].encode('utf-8') onegame.beginTime = beginTime[0:4] + '-' + beginTime[ 4:6] + '-' + beginTime[6:8] + ' ' + beginTime[ 8:10] + ':' + beginTime[10:12] + ':' + beginTime[12:14] beginTime_datetime = datetime.datetime.strptime( onegame.beginTime, '%Y-%m-%d %H:%M:%S') beginTime_timestamp = time.mktime(beginTime_datetime.timetuple()) delta = nowTimestamp - beginTime_timestamp # 比赛已经开始或者已经结束 if delta >= 0: continue briefTimeStr = beginTime[0:4] + '-' + beginTime[ 4:6] + '-' + beginTime[6:8] + ' ' + beginTime[ 8:10] + ':' + beginTime[10:12] if briefTimeStr not in AllBeginTimes: AllBeginTimes.append(briefTimeStr) if oneGameArray[4].isdigit() or oneGameArray[4] == '': onegame.homeTeam = oneGameArray[5].encode('utf-8') onegame.friendTeam = oneGameArray[6].encode('utf-8') else: onegame.homeTeam = oneGameArray[4].encode('utf-8') onegame.friendTeam = oneGameArray[5].encode('utf-8') AllGames.append(onegame) # 获取欧赔,亚盘数据 onegame.oddCompanies = getOneGameODD(host, onegame) onegame.handiCompanies = getOneGameHandi(host, onegame) titlestr = ''.join([ str(onegame.beginTime), ':', onegame.leauge, ':', onegame.homeTeam, 'vs', onegame.friendTeam, ' id: ', str(onegame.soccerID), '澳盘: ', str(onegame.orignal_aomenHandi), ' -> ', str(onegame.now_aomenHandi) ]) contentStr += "<h3 style=\"color:red;\">%s</h3>" % (titlestr, ) # 获取开盘时间 flag = SoccerOrignalPanTime.gethandiTime(onegame.soccerID) if flag: # contentStr += '澳盘开盘早\n'.join([str(onegame.beginTime), ':', onegame.leauge, ':', onegame.homeTeam, 'vs', onegame.friendTeam]) contentStr += "<h4 style=\"color:red;\" align=\"center\">澳盘开盘早</h4>" # 获取初始盘口数量 if len(onegame.orignalHandiList) > 2: contentStr += "<h4 style=\"color:red;\" align=\"center\">初盘混乱</h4>" # contentStr += '初盘混乱\n' # contentStr += ''.join( # [str(onegame.beginTime), ':', onegame.leauge, ':', onegame.homeTeam, 'vs', onegame.friendTeam]) contentStr += "<table bgcolor=\"black\"cellspacing=\"1px\"width=\"375px\" align=\"center\">" \ "<caption style=\"color:red;\"><h5>亚盘</h5></caption><tr bgcolor=#663399><th>博彩公司</th><th>盘口</th><th>数量</th><th>赢盘</th><th>走盘</th><th>输盘</th><th>胜</th><th>平</th><th>负</th></tr> " tempHandistr = getHandiProbability(onegame) if tempHandistr is not None: contentStr += tempHandistr # contentStr += '\n' tempNowHandistr = getnowHandiProbability(onegame) if tempNowHandistr is not None: contentStr += "<tr bgcolor=#888888><th>即时盘口</th><th>%s</th><th></th><th></th><th></th><th></th><th></th><th></th><th></th></tr> " % ( str(len(onegame.nowHandiList))) contentStr += tempNowHandistr contentStr += '</table>' else: contentStr += '</table>' contentStr += '</table>' contentStr += "<table bgcolor=\"black\"cellspacing=\"1px\"width=\"375px\" align=\"center\"><caption style=\"color:red;\"><h5>欧赔</h5></caption>" \ "<tr bgcolor=\"white\" ><td>博彩公司</td> <td>数量</td><td>胜</td><td>平</td><td>负</td><td>胜率</td><td>平率</td><td>负率</td>" tempOddstr = getOrignalODDProbability(onegame) if tempOddstr is not None: contentStr += tempOddstr # contentStr += '\n' tempNowOddstr = getnowODDProbability(onegame) if tempNowOddstr is not None: contentStr += "<tr bgcolor=#888888 ><td>即时欧赔</td> <td></td><td></td><td></td><td></td><td></td><td></td><td></td>" contentStr += tempNowOddstr contentStr += '</table>' else: contentStr += '</table>' time.sleep(3) i = datetime.datetime.now() if gameType == 1: subjectstr = '精简足球分析' elif gameType == 2: subjectstr = '十四场足球分析' else: subjectstr = '初盘分析' send_mail("%s %s/%s/%s" % (subjectstr, i.year, i.month, i.day), contentStr, 'html')
def getOneGameHandi(host, game): resultStr = '' url = '' try: # url = 'http://xxx:8072/phone/Handicap.aspx?ID=' + str(game.soccerID) + '&an=iosQiuTan&av=5.9&from=2&lang=0' url = '%s/phone/Handicap.aspx?ID=%s&an=iosQiuTan&av=7.1&from=2&lang=0&subversion=1' % (host, str(game.soccerID)) except BaseException as e: print e if url != '': resultStr = get_resultstr_with_url(url) if resultStr != '': array = resultStr.split('!') if isinstance(game, FootballGame): companys = [] temp_maxHandi = -10 temp_minHandi = -10 temp_maxHandiCompany = '' temp_minHandiCompany = '' temp_topMax = 0.00 temp_bottomMax = 0.00 temp_topMaxCompany = '' temp_bottomMaxCompany = '' temp_topMin = 10.00 temp_bottomMin = 10.00 temp_topMinCompany = '' temp_bottomMinCompany = '' temp_ori_maxHandi = -10 temp_ori_minHandi = -10 temp_ori_maxHandiCompany = '' temp_ori_minHandiCompany = '' temp_ori_topMax = 0.00 temp_ori_bottomMax = 0.00 temp_ori_topMaxCompany = '' temp_ori_bottomMaxCompany = '' temp_ori_topMin = 10.00 temp_ori_bottomMin = 10.00 temp_ori_topMinCompany = '' temp_ori_bottomMinCompany = '' for unit in array: company = BetCompany() company.result = game.soccer company.league = game.leauge company.homeSoccer = game.allHome company.friendSoccer = game.allFriend company.soccerGameId = game.soccerID unitArray = unit.split('^') try: company.companyTitle = unitArray[0] company.companyID = int(unitArray[1]) company.orignal_top = float(unitArray[2]) company.orignal_Handicap = float(unitArray[3]) # 获取初盘种类 if company.orignal_Handicap not in game.orignalHandiList: game.orignalHandiList.append(company.orignal_Handicap) company.orignal_bottom = float(unitArray[4]) company.now_top = float(unitArray[5]) company.now_Handicap = float(unitArray[6]) company.now_bottom = float(unitArray[7]) # 获取终盘种类 if company.now_Handicap not in game.nowHandiList: game.nowHandiList.append(company.now_Handicap) except (IndexError, ValueError) as e: print e print unitArray except Exception as e: print e if company.companyTitle == '澳门': game.orignal_aomenHandi = company.orignal_Handicap game.now_aomenHandi = company.now_Handicap companys.append(company) if temp_maxHandi == -10 or abs(temp_maxHandi) < abs(company.now_Handicap): temp_maxHandi = company.now_Handicap temp_maxHandiCompany = company.companyTitle if temp_minHandi == -10 or abs(temp_minHandi) > abs(company.now_Handicap): temp_minHandi = company.now_Handicap temp_minHandiCompany = company.companyTitle if temp_topMax < company.now_top: temp_topMax = company.now_top temp_topMaxCompany = company.companyTitle if temp_bottomMax < company.now_bottom: temp_bottomMax = company.now_bottom temp_bottomMaxCompany = company.companyTitle if (temp_topMin > company.now_top) and (company.now_top > 0.00): temp_topMin = company.now_top temp_topMinCompany = company.companyTitle if temp_bottomMin > company.now_bottom: temp_bottomMin = company.now_bottom temp_bottomMinCompany = company.companyTitle if temp_ori_maxHandi == -10 or abs(temp_ori_maxHandi) < abs(company.orignal_Handicap): temp_ori_maxHandi = company.orignal_Handicap temp_ori_maxHandiCompany = company.companyTitle if temp_ori_minHandi == -10 or abs(temp_ori_minHandi) > abs(company.orignal_Handicap): temp_ori_minHandi = company.orignal_Handicap temp_ori_minHandiCompany = company.companyTitle if temp_ori_topMax < company.orignal_top: temp_ori_topMax = company.orignal_top temp_ori_topMaxCompany = company.companyTitle if temp_ori_bottomMax < company.orignal_bottom: temp_ori_bottomMax = company.orignal_bottom temp_ori_bottomMaxCompany = company.companyTitle if temp_ori_topMin > company.orignal_top: temp_ori_topMin = company.orignal_top temp_ori_topMinCompany = company.companyTitle if temp_ori_bottomMin > company.orignal_bottom: temp_ori_bottomMin = company.orignal_bottom temp_ori_bottomMinCompany = company.companyTitle if temp_maxHandiCompany != '澳门' and temp_maxHandi == game.now_aomenOdd: temp_maxHandiCompany = '澳门' if temp_ori_maxHandiCompany != '澳门' and temp_ori_maxHandi == game.orignal_aomenHandi: temp_ori_maxHandiCompany = '澳门' game.maxHandi = temp_maxHandi game.maxHandiCompany = temp_maxHandiCompany game.minHandi = temp_minHandi game.minHandiCompany = temp_minHandiCompany game.topMax = temp_topMax game.bottomMax = temp_bottomMax game.topMaxCompany = temp_topMaxCompany game.bottomMaxCompany = temp_bottomMaxCompany game.topMin = temp_topMin game.topMinCompany = temp_topMinCompany game.bottomMin = temp_bottomMin game.bottomMinCompany = temp_bottomMinCompany game.ori_maxHandi = temp_ori_maxHandi game.ori_maxHandiCompany = temp_ori_maxHandiCompany game.ori_minHandi = temp_ori_minHandi game.ori_minHandiCompany = temp_ori_minHandiCompany game.ori_topMax = temp_ori_topMax game.ori_bottomMax = temp_ori_bottomMax game.ori_topMaxCompany = temp_ori_topMaxCompany game.ori_bottomMaxCompany = temp_ori_bottomMaxCompany game.ori_topMin = temp_ori_topMin game.ori_topMinCompany = temp_ori_topMinCompany game.ori_bottomMin = temp_ori_bottomMin game.ori_bottomMinCompany = temp_ori_bottomMinCompany return companys else: return [] else: return []
def getTodaySoccer(soccer_type = 0): typeStr = '' if isinstance(soccer_type,int): typeStr = str(soccer_type) # type == 3 竞彩 # type == 1 精简 # type == 2 十四场 url = "http://61.143.224.166:8071/phone/schedule_0_" + typeStr + ".txt?an=iosQiuTan&av=2.4&from=2&r=" + str(int(time.time())) # url = "http://112.91.160.49:8071/phone/schedule_0_" + str(type) + ".txt?an=iosQiuTan&av=5.9&from=2&r=1494229747" print url resultStr = get_resultstr_with_url(url) AllGames = [] AllBeginTimes = [] if resultStr != '': # print resultStr allArray = resultStr.split('$$') leagueStr = '' if soccer_type == 1: leagueStr = allArray[0] else: leagueStr = allArray[1] allLeague = leagueStr.split('!') dic = {} for league in allLeague: oneLeague = league.split('^') dic[oneLeague[1]] = oneLeague[0] if soccer_type == 1: gameStr = allArray[1] else: gameStr = allArray[2] games = gameStr.split('!') firstobject = games[0] for game in games: # if game is not firstobject: # continue; onegame = FootballGame() oneGameArray = game.split('^') oneGameArray.remove('') gameing = int(oneGameArray[2]) if gameing != 0: print "比赛已经开始或结束" continue onegame.soccerID = int(oneGameArray[0]) onegame.leauge = dic.get(oneGameArray[1]) beginTime = oneGameArray[3].encode('utf-8') onegame.beginTime = beginTime[0:4] + '-' + beginTime[4:6] + '-' + beginTime[6:8] + ' ' + beginTime[ 8:10] + ':' + beginTime[ 10:12] briefTimeStr = beginTime[0:4] + '-' + beginTime[4:6] + '-' + beginTime[6:8] + ' ' + beginTime[ 8:10] + ':' + beginTime[ 10:12] if briefTimeStr not in AllBeginTimes: AllBeginTimes.append(briefTimeStr) if oneGameArray[4].isdigit() or oneGameArray[4] == '': onegame.homeTeam = oneGameArray[5] onegame.friendTeam = oneGameArray[6] else: onegame.homeTeam = oneGameArray[4] onegame.friendTeam = oneGameArray[5] # 获取开盘时间 flag = gethandiTime(onegame.soccerID) if flag: print onegame.soccerID print ''.join([str(onegame.beginTime), ':', onegame.leauge, ':', onegame.homeTeam, 'vs', onegame.friendTeam]) else: pass time.sleep(3)