Ejemplo n.º 1
0
def hist_FD_contest_salaries():
    todays_date=time.strftime("%Y-%m-%d")
    table='hist_fanduel_data'
    recordset=dbo.get_table_last_row(table,'Date')
    if str(recordset[0][1])==todays_date:
        print "hist_fd_contest_salares: salaries already historized in %s for today " % table
        time.sleep(5)   
        return
    s,session_id=fdo.get_fanduel_session()
    contest_dict=fdo.get_FD_contests(s)
    sports_list=['mlb','nba','nhl','nfl'] #pick this option if you wanna historize all sports
    #sports_list=['mlb','nba']
    for sport in sports_list:
        print sport
        sport_contest_dict=(x for x in contest_dict if x['sport']==sport)
        test_dict_case=(x for x in contest_dict if x['sport']==sport) #assign duplicate var to avoid list mutation
        if len(list(test_dict_case))>0: #test if there are contests for the sport
            historized_contests=[]
            ContestID=''
            rw=1
            for contest in sport_contest_dict: #loop through each for given sport
                Url='https://www.fanduel.com/e/Game'+contest['entryURL'][contest['entryURL'].find('Game\\')+5:]
                # print contest['startString']
                if  contest['gameId'] not in historized_contests and len(contest['startString'])<14 and contest['entryURL'].find('accept_public_challenge')==-1: #check for contests at other times
                    print 'now historizing %s contest#: %d' % (sport,contest['gameId'])
                    hist_FD_playerdata(sport.upper(),Url,contest['gameId'])
                    print '%s contest#: %d historized succesfully' % (sport,contest['gameId'])
                    historized_contests.append(contest['gameId'])
    fdo.end_fanduel_session(s)
    return
Ejemplo n.º 2
0
def hist_FD_contest_salaries():
    todays_date = time.strftime("%Y-%m-%d")
    table = 'hist_fanduel_data'
    recordset = dbo.get_table_last_row(table, 'Date')
    if str(recordset[0][1]) == todays_date:
        print "hist_fd_contest_salares: salaries already historized in %s for today " % table
        time.sleep(5)
        return
    s, session_id = fdo.get_fanduel_session()
    contest_dict = fdo.get_FD_contests(s)
    sports_list = ['mlb', 'nba', 'nhl',
                   'nfl']  #pick this option if you wanna historize all sports
    #sports_list=['mlb','nba']
    for sport in sports_list:
        print sport
        sport_contest_dict = (x for x in contest_dict if x['sport'] == sport)
        test_dict_case = (x for x in contest_dict if x['sport'] == sport
                          )  #assign duplicate var to avoid list mutation
        if len(list(test_dict_case)
               ) > 0:  #test if there are contests for the sport
            historized_contests = []
            ContestID = ''
            rw = 1
            for contest in sport_contest_dict:  #loop through each for given sport
                Url = 'https://www.fanduel.com/e/Game' + contest['entryURL'][
                    contest['entryURL'].find('Game\\') + 5:]
                # print contest['startString']
                if contest['gameId'] not in historized_contests and len(
                        contest['startString']
                ) < 14 and contest['entryURL'].find(
                        'accept_public_challenge'
                ) == -1:  #check for contests at other times
                    print 'now historizing %s contest#: %d' % (
                        sport, contest['gameId'])
                    hist_FD_playerdata(sport.upper(), Url, contest['gameId'])
                    print '%s contest#: %d historized succesfully' % (
                        sport, contest['gameId'])
                    historized_contests.append(contest['gameId'])
    fdo.end_fanduel_session(s)
    return