def app(match_id): #match_id = sys.argv[1] m_match = spider.get_match(match_id) if isStart(m_match.match_time): print '已经开赛' return 0 m_match.display() match_url = 'http://odds.500.com/fenxi/shuju-' + str(match_id) + '.shtml' content = spider.url_get(match_url, "gb2312") WebSuggest = netdata.get_Suggest(content) (home_url, away_url) = netdata.get_Team_url(content) odd_url = 'http://odds.500.com/fenxi/ouzhi-' + str(match_id) + '.shtml' content = spider.url_get(odd_url, "gb2312") (wodd, lodd) = netdata.get_now_Odds(content) (home_rv, home_rv_wodd) = getTeamMatDis(home_url, wodd, lodd, 1) (away_rv, away_rv_wodd) = getTeamMatDis(away_url, lodd, wodd, 0) if home_rv.num_matches == 0 or away_rv.num_matches == 0: print ' ' print ' ' return 0 print '===============================================' SelShow(home_rv, away_rv) show(home_rv, home_rv_wodd) show(away_rv, away_rv_wodd) print '=============== 澳门心水推荐 =================' print WebSuggest showMarket(match_id) showOddsChangePre(match_id) print ' ' print ' '
def test(match_id): #match_id = sys.argv[1] m_match = spider.get_match(match_id) # if isStart(m_match.match_time): # print '已经开赛' # return 0 m_match.display() match_url = 'http://odds.500.com/fenxi/shuju-' + str(match_id) + '.shtml' content = spider.url_get(match_url, "gb2312") WebSuggest = netdata.get_Suggest(content) (home_url, away_url) = netdata.get_Team_url(content) odd_url = 'http://odds.500.com/fenxi/ouzhi-' + str(match_id) + '.shtml' content = spider.url_get(odd_url, "gb2312") (wodd, lodd) = netdata.get_now_Odds(content) (home_rv, home_rv_wodd, home_goal) = getTeamMatDis(home_url, wodd, lodd, 1) (away_rv, away_rv_wodd, away_goal) = getTeamMatDis(away_url, lodd, wodd, 0) print '===============================================' SelShow(home_rv, away_rv) show(home_rv, home_rv_wodd) show(away_rv, away_rv_wodd) print '=============== 澳门心水推荐 =================' print WebSuggest print ' ' print m_match.host_team + ' ' + str(home_goal) + ':' + str( away_goal) + ' ' + m_match.guest_team print ' ' print ' '
def appSaveMat(match_id): if(os.path.exists(str(match_id)+'.npy')): return 0 m_match = spider.get_match(match_id) #if isStart(m_match.match_time): # return 0 match_url = 'http://odds.500.com/fenxi/ouzhi-'+ str(match_id) +'.shtml' content = spider.url_get(match_url,"gb2312") (home_url,away_url) = netdata.get_Team_url(content) #start Mat = [] Odds_Vec = netdata.get_now_all_odds(content) home_rv = BSc.getTeamMatDis(home_url,Odds_Vec[0],Odds_Vec[2],1)[0] away_rv = BSc.getTeamMatDis(away_url,Odds_Vec[2],Odds_Vec[0],0)[0] Pre_Vec_Home = home_rv.get_pre_vec() Pre_Vec_Away = away_rv.get_pre_vec() Betfair_Vec = fm.getBetfairsth(match_id)[0] Company_Vec = fm.getBetfairsth(match_id)[1] Home_EG_Vec = [home_rv.get_average_goal(),0,away_rv.get_average_lose()] Away_EG_Vec = [away_rv.get_average_goal(),0,home_rv.get_average_lose()] (home_this_goals,home_this_loses) = BSc.getTeamMatDis(home_url,Odds_Vec[0],Odds_Vec[2],1)[4:6] (away_this_goals,away_this_loses) = BSc.getTeamMatDis(away_url,Odds_Vec[2],Odds_Vec[0],0)[4:6] Home_VG_Vec = [np.var(home_this_goals),0,np.var(away_this_loses)] Away_VG_Vec = [np.var(away_this_goals),0,np.var(home_this_loses)] return [list(Pre_Vec_Home),list(Pre_Vec_Away),list(Odds_Vec),Betfair_Vec,Company_Vec,Home_EG_Vec,Away_EG_Vec,Home_VG_Vec,Away_VG_Vec]
def toRedis(match_id, pool): m_match = spider.get_match(match_id) match_url = 'http://odds.500.com/fenxi/shuju-' + str(match_id) + '.shtml' content = spider.url_get(match_url, "gb2312") WebSuggest = netdata.get_Suggest(content) (home_url, away_url) = netdata.get_Team_url(content) odd_url = 'http://odds.500.com/fenxi/ouzhi-' + str(match_id) + '.shtml' content = spider.url_get(odd_url, "gb2312") (wodd, lodd) = netdata.get_now_Odds(content) #(home_rv,home_rv_wodd)=getTeamMatDis(home_url,wodd,lodd) #(away_rv,away_rv_wodd)=getTeamMatDis(away_url,lodd,wodd) (home_rv, home_rv_wodd, home_goal) = getTeamMatDis(home_url, wodd, lodd, 1) (away_rv, away_rv_wodd, away_goal) = getTeamMatDis(away_url, lodd, wodd, 0) #print '===============================================' #(BigBall,SmaBall,MySuggest)=SelShow(home_rv,away_rv) #show(home_rv,home_rv_wodd) #show(away_rv,away_rv_wodd) home_vec = home_rv.get_pre_vec() away_vec = away_rv.get_pre_vec() if home_rv.num_matches < 2 or away_rv.num_matches < 2: return 0 MySuggest = GiveSuggest(wodd, lodd, home_vec, away_vec) (BigBall, SmaBall) = BSc.CalGoal(home_rv.get_average_goal(), home_rv.get_average_lose(), away_rv.get_average_goal(), away_rv.get_average_lose()) match_dict = { "web": m_match.match_link, "name": m_match.match_name, "hometeam": m_match.host_team, "awayteam": m_match.guest_team, "time": m_match.match_time, "homeodd": str(wodd), "awayodd": str(lodd), "homenum": str(home_rv.num_matches), "awaynum": str(away_rv.num_matches), "homepregoal": str(home_rv.get_average_goal()), "awaypregoal": str(away_rv.get_average_goal()), "homeprelose": str(home_rv.get_average_lose()), "awayprelose": str(away_rv.get_average_lose()), "biggoal": str(BigBall), "smagoal": str(SmaBall), "hpl": str(home_vec[0]), "hpd": str(home_vec[1]), "hpw": str(home_vec[2]), "apl": str(away_vec[0]), "apd": str(away_vec[1]), "apw": str(away_vec[2]), "websuggest": WebSuggest, "mysuggest": MySuggest, "homerealgoal": str(home_goal), "awayrealgoal": str(away_goal) } #pool = redis.ConnectionPool(host='127.0.0.1',port=6379) #pool = redis.ConnectionPool(host='115.28.138.54',port=6379) rd = redis.StrictRedis(connection_pool=pool) rd.hmset(match_id, match_dict) print 'id writed: ' + match_id return 'writed'
def get_match_res(match_id): m_match = spider.get_match(match_id) match_url = 'http://odds.500.com/fenxi/shuju-' + str(match_id) + '.shtml' goal_res_r = re.compile(r'<strong>(.*):(.*)</strong>') content = spider.url_get(match_url, "gb2312") goal_res = goal_res_r.findall(content) if len(goal_res) == 0: return 0 res = [float(goal_res[0][0]), float(goal_res[0][1])] return res
def print_match_res(match_id): m_match = spider.get_match(match_id) match_url = 'http://odds.500.com/fenxi/shuju-'+ str(match_id) +'.shtml'; res_r = re.compile(r'<strong>(.*):(.*)</strong>'); content = spider.url_get(match_url,"gb2312"); res = res_r.findall(content); print m_match.match_name; print m_match.match_time; print m_match.host_team+' ' + res[0][0] +':'+ res[0][1] + ' ' + m_match.guest_team; print ' '
def app(match_id): #match_id = sys.argv[1] m_match = spider.get_match(match_id) #if isStart(m_match.match_time): # print '已经开赛' # return 0 m_match.display() match_url = 'http://odds.500.com/fenxi/shuju-' + str(match_id) + '.shtml' content = spider.url_get(match_url, "gb2312") WebSuggest = netdata.get_Suggest(content) (home_url, away_url) = netdata.get_Team_url(content) odd_url = 'http://odds.500.com/fenxi/ouzhi-' + str(match_id) + '.shtml' content = spider.url_get(odd_url, "gb2312") (wodd, lodd) = netdata.get_now_Odds(content) #print home_url;print wodd;print lodd; (home_rv, home_rv_wodd, home_last_3_goals, home_last_3_losts, home_this_goals, home_this_loses, real_home_goal) = BSc.getTeamMatDis(home_url, wodd, lodd, 1) (away_rv, away_rv_wodd, away_last_3_goals, away_last_3_losts, away_this_goals, away_this_loses, real_away_goal) = BSc.getTeamMatDis(away_url, lodd, wodd, 0) if home_rv.num_matches < 1 or away_rv.num_matches < 1: print ' ' print ' ' return 0 print '===============================================' SelShow(home_rv, away_rv) show(home_rv, home_rv_wodd, home_this_goals, home_this_loses) show(away_rv, away_rv_wodd, away_this_goals, away_this_loses) print '====================== ⚽ ======================' print m_match.host_team + ' 最近三场进球: ' + str( home_last_3_goals) + ' 最近三场失球:' + str(home_last_3_losts) print m_match.guest_team + ' 最近三场进球: ' + str( away_last_3_goals) + ' 最近三场失球:' + str(away_last_3_losts) print '=============== 🐷 澳门心水推荐 🐷 =================' print WebSuggest showMarket(match_id) #showOddsChangePre(match_id) print '=============== 澳门亚盘 =================' appA.AppUseAomen(match_id) print '=============== 澳门初盘 =================' appA.AppUseAomen_s(match_id) print '=============== 韦德大小球 =================' #fw.AppUseWeddOdds(match_id) #os.system('python AppUseWedd.py ' + str(match_id) ) appW.AppUseWedd(match_id) print '=============== 韦德初盘 =================' appW.AppUseWedd_s(match_id) #os.system('./AutobetTool.sh ' + str(match_id) ) print '=============== 真实比分 =================' print str(real_home_goal) + ' : ' + str(real_away_goal) print ' ' print ' '
def toRedis(match_id): m_match = spider.get_match(match_id) match_url = 'http://odds.500.com/fenxi/shuju-'+ str(match_id) +'.shtml' content = spider.url_get(match_url,"gb2312") WebSuggest = netdata.get_Suggest(content) (home_url,away_url) = netdata.get_Team_url(content) odd_url = 'http://odds.500.com/fenxi/ouzhi-'+ str(match_id) +'.shtml' content = spider.url_get(odd_url,"gb2312") (wodd,lodd) = netdata.get_now_Odds(content) (home_rv,home_rv_wodd)=getTeamMatDis(home_url,wodd,lodd) (away_rv,away_rv_wodd)=getTeamMatDis(away_url,lodd,wodd) print '===============================================' (BigBall,SmaBall,MySuggest)=SelShow(home_rv,away_rv) show(home_rv,home_rv_wodd) show(away_rv,away_rv_wodd) home_vec = home_rv.get_pre_vec() away_vec = away_rv.get_pre_vec() match_dict = {"web":m_match.match_link, "name":m_match.match_name, "hometeam":m_match.host_team, "awayteam":m_match.guest_team, "time":m_match.match_time, "homeodd":str(wodd), "awayodd":str(lodd), "homenum":str(home_rv.num_matches), "awaynum":str(away_rv.num_matches), "homepregoal":str(home_rv.get_average_goal()), "awaypregoal":str(away_rv.get_average_goal()), "homeprelose":str(home_rv.get_average_lose()), "awayprelose":str(away_rv.get_average_lose()), "biggoal":str(BigBall), "smagoal":str(SmaBall), "hpl":str(home_vec[0]), "hpd":str(home_vec[1]), "hpw":str(home_vec[2]), "apl":str(away_vec[0]), "apd":str(away_vec[1]), "apw":str(away_vec[2]), "websuggest":WebSuggest, "mysuggest":str(MySuggest), "homerealgoal":'null', "awayrealgoal":'null'} pool = redis.ConnectionPool(host='127.0.0.1',port=6379) rd = redis.StrictRedis(connection_pool=pool) rd.hmset(sys.argv[1],match_dict)
def test(match_id): #match_id = sys.argv[1] m_match = spider.get_match(match_id) m_match.display() match_url = 'http://odds.500.com/fenxi/shuju-'+ str(match_id) +'.shtml' content = spider.url_get(match_url,"gb2312") (home_url,away_url) = netdata.get_Team_url(content) odd_url = 'http://odds.500.com/fenxi/ouzhi-'+ str(match_id) +'.shtml' content = spider.url_get(odd_url,"gb2312") (wodd,lodd) = netdata.get_now_Odds(content) (home_rv,home_rv_wodd,home_goal)=getTeamMatDis(home_url,wodd,lodd,1) (away_rv,away_rv_wodd,away_goal)=getTeamMatDis(away_url,lodd,wodd,0) print '===============================================' SelShow(home_rv,away_rv) show(home_rv,home_rv_wodd) show(away_rv,away_rv_wodd) print ' ' print ' '
def makeDataXYtrain_forPsql(day1,day2,company): Lines = [] for day in range(day1,day2): match_ids = spider.crawl_match_list_by_date(str(today.year) + "-09-" + str(day)) print '当天共'+str(len(match_ids))+'场比赛,正在下载...' pbar = ProgressBar().start();i=1;total=len(match_ids); for match_id in match_ids: info = fm.getAppointOddsAndRes(match_id,company) if info==0:continue pbar.update(int(100*(float(i)/total))) #DataX.append([match_id]+info[0]) #DataX.append(np.dot((np.float64(np.array(info[0]))[0:3]-np.float64(np.array(info[0]))[3:6]),10)/np.float64(np.array(info[0]))[3:6]) #DataY.append([np.int32(np.array(info[1])[0]),np.int32(np.array(info[1])[1])]) m_macth = spider.get_match(match_id) Lines.append(tuple([match_id]+info[0]+[info[1][0],info[1][1]]+[m_macth.host_team,m_macth.guest_team,m_macth.match_name,company,m_macth.match_time])) i+=1 pbar.finish() return Lines
def HD_GetMatch(match_id): m_match = spider.get_match(match_id) match_url = 'http://odds.500.com/fenxi/shuju-' + str(match_id) + '.shtml' content = spider.url_get(match_url, "gb2312") WebSuggest = netdata.get_Suggest(content) (home_url, away_url) = netdata.get_Team_url(content) odd_url = 'http://odds.500.com/fenxi/ouzhi-' + str(match_id) + '.shtml' content = spider.url_get(odd_url, "gb2312") (wodd, lodd) = netdata.get_now_Odds(content) (home_rv, home_rv_wodd, home_goal) = getTeamMatDis(home_url, wodd, lodd, 1) (away_rv, away_rv_wodd, away_goal) = getTeamMatDis(away_url, lodd, wodd, 0) home_vec = home_rv.get_pre_vec() away_vec = away_rv.get_pre_vec() if home_rv.num_matches < 1 or away_rv.num_matches < 1: return 0 (BigBall, SmaBall) = BSc.CalGoal(home_rv.get_average_goal(), home_rv.get_average_lose(), away_rv.get_average_goal(), away_rv.get_average_lose()) BS_IfRight = Task_BSJudge(BigBall, SmaBall, home_goal, away_goal) return (home_rv.num_matches, away_rv.num_matches, home_vec, away_vec, BigBall, SmaBall, wodd, lodd, home_goal, away_goal)
# -*- coding: utf-8 -*- """ soccer bet main function file """ __author__ = 'ggstar' import sys import spider import portfoliomodel import time def test(): args = sys.argv if len(args) == 1: print 'Hello, world!' elif len(args) == 2: print 'Hello, %s!' % args[1] else: print 'Too many arguments!' m_match_ids = spider.crawl_match_list() for m_match_id in m_match_ids: m_match = spider.get_match(m_match_id) portfolio = portfoliomodel.best_portfolio(m_match) m_match.display() portfolio.display() time.sleep(4)
#!/usr/bin/env python # -*- coding: utf-8 -*- """ soccer bet main function file """ __author__ = 'ggstar' import spider import portfoliomodel import time import sys reload(sys) sys.setdefaultencoding('utf8') m_match_ids = spider.crawl_match_list() for m_match_id in m_match_ids: print m_match_id m_match = spider.get_match(m_match_id) portfolio = portfoliomodel.best_portfolio(m_match) m_match.display() portfolio.display() time.sleep(4)
def test_isStart(match_id): #content = spider.url_get('http://odds.500.com/fenxi/shuju-642942.shtml',"gb2312") m_match = spider.get_match(match_id) print isStart(m_match.match_time)
# -*- coding: utf-8 -*- """try using the apis of soccerbet""" __author__ = 'hanss401' import spider import portfoliomodel import time import sys reload(sys) sys.setdefaultencoding('utf8') m_match_ids = spider.crawl_match_list() print len(m_match_ids) match_id = m_match_ids[0] print match_id one_match = spider.get_match(match_id) print len(one_match.item_arr) for i in range(0, len(one_match.item_arr)): #print one_match.item_arr[i].l_odds print one_match.item_arr[i].cl_odds print one_match.host_team print one_match.match_name print one_match.match_time
def to_redis(match_id, pool): #match_id = sys.argv[1] m_match = spider.get_match(match_id) if am.isStart(m_match.match_time): print '已经开赛' sys.exit(1) #return 0 #m_match.display() match_url = 'http://odds.500.com/fenxi/shuju-' + str(match_id) + '.shtml' content = spider.url_get(match_url, "gb2312") WebSuggest = netdata.get_Suggest(content) (home_url, away_url) = netdata.get_Team_url(content) odd_url = 'http://odds.500.com/fenxi/ouzhi-' + str(match_id) + '.shtml' content = spider.url_get(odd_url, "gb2312") (wodd, lodd) = netdata.get_now_Odds(content) (home_rv, home_rv_wodd, home_last_3_goals, home_last_3_losts, home_this_goals, home_this_loses) = BSc.getTeamMatDis(home_url, wodd, lodd, 1) (away_rv, away_rv_wodd, away_last_3_goals, away_last_3_losts, away_this_goals, away_this_loses) = BSc.getTeamMatDis(away_url, lodd, wodd, 0) if home_rv.num_matches < 2 or away_rv.num_matches < 2: sys.exit(1) #return 0 (BigBall, SmaBall) = BSc.CalGoal(home_rv.get_average_goal(), home_rv.get_average_lose(), away_rv.get_average_goal(), away_rv.get_average_lose()) home_vec = home_rv.get_pre_vec() away_vec = away_rv.get_pre_vec() MySuggest = GiveSuggest(wodd, lodd, home_vec, away_vec) match_dict = { "web": m_match.match_link, "name": str(m_match.match_name), "hometeam": str(m_match.host_team), "awayteam": str(m_match.guest_team), "time": str(m_match.match_time), "homeodd": str(wodd), "awayodd": str(lodd), "homenum": str(home_rv.num_matches), "awaynum": str(away_rv.num_matches), "homepregoal": str(home_rv.get_average_goal()), "awaypregoal": str(away_rv.get_average_goal()), "homeprelose": str(home_rv.get_average_lose()), "awayprelose": str(away_rv.get_average_lose()), "biggoal": str(BigBall), "smagoal": str(SmaBall), "hpl": str(home_vec[0]), "hpd": str(home_vec[1]), "hpw": str(home_vec[2]), "apl": str(away_vec[0]), "apd": str(away_vec[1]), "apw": str(away_vec[2]), "websuggest": WebSuggest, "mysuggest": MySuggest, "home_last_3_goals_ave": str(np.mean(home_last_3_goals)), "home_last_3_loses_ave": str(np.mean(home_last_3_losts)), "away_last_3_goals_ave": str(np.mean(away_last_3_goals)), "away_last_3_loses_ave": str(np.mean(away_last_3_losts)), "home_last_3_goals_var": str(np.var(home_last_3_goals)), "home_last_3_loses_var": str(np.var(home_last_3_losts)), "away_last_3_goals_var": str(np.var(away_last_3_goals)), "away_last_3_loses_var": str(np.var(away_last_3_losts)), "home_this_goals_var": str(np.var(home_this_goals)), "home_this_loses_var": str(np.var(home_this_loses)), "away_this_goals_var": str(np.var(away_this_goals)), "away_this_loses_var": str(np.var(away_this_loses)) } rd = redis.StrictRedis(connection_pool=pool) rd.hmset(match_id, match_dict) print 'id writed: ' + match_id sys.exit(0)
def get_MatchInfo(match_id): one_match = spider.get_match(match_id) return one_match
#!/usr/bin/python # -*- coding: utf-8 -*- import psycopg2 as ps import spider conn = ps.connect(database="oddsdata", user="******", password="******", host="127.0.0.1", port="5432") print 'Open successful' #cur = conn.cursor() def insertIntoOddsdata(match_id, ps1, ps2, ps3, pf1, pf2, pf3, goal1, goal2, team1, team2, league, company, match_time, conn): Str = "INSERT INTO oddsdata_ex ( match_id,ps1,ps2,ps3,pf1,pf2,pf3,goal1,goal2,team1,team2,league,company,match_time) VALUES (" + match_id + "," + ps1 + "," + ps2 + "," + ps3 + "," + pf1 + "," + pf2 + "," + pf3 + "," + goal1 + "," + goal2 + ",'" + team1 + "','" + team2 + "','" + league + "','" + company + "','" + match_time + "');" cur = conn.cursor() cur.execute(Str) conn.commit() conn.close() team1 = spider.get_match('642942').match_name insertIntoOddsdata('111006', '2.11', '2.12', '3.11', '2.12', '2.01', '4.11', '1', '2', team1.decode("UTF8").encode("UTF8"), 'LIV', 'PremierLeague', 'wedd', '2012-06-07 14:00:02.412827+08', conn)