def parseExpekt(comp=1): Matches = {} Matches['events'] = {} Matches['events']['name'] = {} Matches['events']['matchtime'] = {} Matches['events']['odds'] = {} df = pd.DataFrame(columns=['name', 'matchtime', 'home', 'draw', 'away']) i = 0 header = { 'UserAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Firefox/49.0' } if comp == 1: tmp = requests.get( 'https://en.expekt.com/fotball/eng-premier-league-3', headers=header) elif comp == 2: tmp = requests.get('https://en.expekt.com/fotball/nor-eliteserien-156', headers=header) elif comp == 3: tmp = requests.get( 'https://no.expekt.com/fotball/spa-primera-division-7', headers=header) elif comp == 8: tmp = requests.get('https://no.expekt.com/ishockey/nhl-83', headers=header) elif comp == 11: tmp = requests.get('https://no.expekt.com/fotball/champions-league-8', headers=header) elif comp == 43: tmp = requests.get('https://en.expekt.com/football/world-cup-1', headers=header) soup = BeautifulSoup(tmp.content, "lxml") for tr in soup.find_all("div", {"class": "match-entry"}): Matches['events']['name'][i] = tr.attrs['data-track-event-name'] df.loc[i, 'name'] = tr.attrs['data-track-event-name'] j = 0 tmpvals = numpy.empty((1, 3)) for td in tr.find_all("span", {"class": "oddValue"}): tmpvals[0][j] = td.text.replace(',', '.') df.iloc[i, j + 2] = float(td.text.replace(',', '.')) j += 1 Matches['events']['odds'][i] = tmpvals i += 1 df.name = fixNaming.fixNaming(df.name) Matches['events']['name'] = fixNaming.fixNaming(Matches['events']['name']) return Matches, df
def parseSmarkets(comp): header = { 'UserAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Firefox/49.0' } Matches = {} Matches['events'] = {} Matches['events']['name'] = {} Matches['events']['matchtime'] = {} Matches['events']['odds'] = {} if comp == 1: url = "https://smarkets.com/v0/listings/slug/sport/football/premier-league-2017-2018/" tmp = requests.get(url, headers=header) data = tmp.json() events = str([ int(data['event_ids'][i]) for i in range(len(data['event_ids'])) ])[1:-1].replace(" ", "") url2 = "https://smarkets.com/v0/events/ids/" + events + "/live/" tmp2 = requests.get(url2, headers=header) data2 = tmp2.json() i = 0 for key in data['events']: Matches['events']['name'][i] = data['events'][key]['name'] Matches['events']['matchtime'][i] = parse( data['events'][key]['start_datetime']) contracts = data['events'][key]['primary_contracts_ids'] tmpvals = numpy.empty((1, len(contracts))) for j in range(len(contracts)): if j == 0: idx = 0 elif j == 1: idx = 2 elif j == 2: idx = 1 try: tmpvals[0][idx] = 1 / ( data2['quotes'][contracts[j]]['offers'][0]['price'] / 10000) except: tmpvals[0][idx] = 1. Matches['events']['odds'][i] = tmpvals i += 1 Matches['events']['name'] = fixNaming.fixNaming(Matches['events']['name']) return Matches
def parseMatchbook(comp): header = { 'UserAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Firefox/49.0' } Matches = {} Matches['events'] = {} Matches['events']['name'] = {} Matches['events']['matchtime'] = {} Matches['events']['odds'] = {} if comp == 1: url = "https://www.matchbook.com/edge/rest/events?language=en¤cy=USD&exchange-type=back-lay&odds-type=DECIMAL&price-depth=6&price-order=price%20desc&include-event-participants=true&offset=0&per-page=18&tag-url-names=soccer%2Cengland%2Cpremier-league" tmp = requests.get(url, headers=header) data = tmp.json() for i in range(len(data['events'])): Matches['events']['name'][i] = data['events'][i]['name'] Matches['events']['matchtime'][i] = parse(data['events'][i]['start']) url2 = "https://www.matchbook.com/edge/rest/events/" + str( data['events'][i]['id'] ) + "?language=en¤cy=USD&exchange-type=back-lay&odds-type=DECIMAL&include-markets=true&include-prices=true&include-runners=true&market-per-page=500&price-depth=6&price-order=price%20desc&include-event-participants=true" tmp2 = requests.get(url2, headers=header) data2 = tmp2.json() tmpvals = numpy.empty((1, len(data2['markets'][0]['runners']))) for j in range(len(data2['markets'][0]['runners'])): if j == 0: idx = 0 elif j == 1: idx = 2 elif j == 2: idx = 1 try: tmpvals[0][idx] = data2['markets'][0]['runners'][j]['prices'][ 0]['odds'] except: tmpvals[0][idx] = 1. Matches['events']['odds'][i] = tmpvals Matches['events']['name'] = fixNaming.fixNaming(Matches['events']['name']) return Matches
def parseNordicbet(comp): header = { 'UserAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Firefox/49.0' } Matches = {} Matches['events'] = {} Matches['events']['name'] = {} Matches['events']['matchtime'] = {} Matches['events']['odds'] = {} df = pd.DataFrame(columns=['name', 'matchtime', 'home', 'draw', 'away']) if comp == 1: #PL url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/901/en/event?betgroupgroupingids=36&eventPhase=1&marketCount=50&page=1&subCategoryIds=3' elif comp == 2: #TL url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/901/en/event?betgroupgroupingids=36&eventPhase=1&marketCount=50&page=1&subCategoryIds=128' elif comp == 3: #La Liga url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/901/en/event?betgroupgroupingids=36&eventPhase=1&marketCount=50&page=1&subCategoryIds=12' elif comp == 4: #Serie A url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/901/en/event?betgroupgroupingids=36&eventPhase=1&marketCount=50&page=1&subCategoryIds=9' elif comp == 5: #Ligue 1 url = 'https://bts-api-a.bpsgameserver.com/isa/v2/601/en/event?betGroupIds=1,5,4058,65,127&categoryIds=1&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=13&subCategoryIds=19' elif comp == 6: #Bundesliga url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/901/en/event?betgroupgroupingids=36&eventPhase=1&marketCount=50&page=1&subCategoryIds=15' elif comp == 7: #Championship url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/904/no/event?betgroupgroupingids=36&eventPhase=1&marketCount=50&page=1&subCategoryIds=4' elif comp == 8: #NHL url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/904/no/event?betgroupgroupingids=36&eventPhase=1&marketCount=50&page=1&subCategoryIds=50' elif comp == 9: #FA Cup url = 'https://bts-api-a.bpsgameserver.com/isa/v2/605/no/event?betGroupIds=1,5,4058,65,127&categoryIds=1&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=11&subCategoryIds=7' elif comp == 10: #Europa League url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/901/en/event?betgroupgroupingids=36&eventPhase=1&marketCount=50&page=1&subCategoryIds=2612' elif comp == 11: #Champions League url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/901/en/event?betgroupgroupingids=36&eventPhase=1&marketCount=50&page=1&subCategoryIds=6134' elif comp == 12: #KHL url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/901/en/event?betgroupgroupingids=36&eventPhase=1&marketCount=50&page=1&subCategoryIds=3207' elif comp == 13: #WC Qualification Europe url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/901/en/event?betgroupgroupingids=36&eventPhase=1&marketCount=50&page=1&subCategoryIds=1609' elif comp == 14: #WC hockey url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/901/en/event?betgroupgroupingids=36&eventPhase=1&marketCount=50&page=1&subCategoryIds=444' elif comp == 15: #Allsvenskan url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/901/en/event?betgroupgroupingids=36&eventPhase=1&marketCount=50&page=1&subCategoryIds=1' elif comp == 16: #U20 VM url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/901/en/event?betgroupgroupingids=36&eventPhase=1&marketCount=50&page=1&subCategoryIds=1163' elif comp == 17: #NM url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/901/en/event?betgroupgroupingids=36&eventPhase=1&marketCount=50&page=1&subCategoryIds=134' elif comp == 18: #MLS url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/901/en/event?betgroupgroupingids=36&eventPhase=1&marketCount=50&page=1&subCategoryIds=250' elif comp == 19: #U21 EM url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/901/en/event?betgroupgroupingids=36&eventPhase=1&marketCount=50&page=1&subCategoryIds=563' elif comp == 20: url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/901/en/event?betgroupgroupingids=36&eventPhase=1&eventSortBy=2&marketCount=50&page=1&subCategoryIds=257' elif comp == 21: url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/901/en/event?betgroupgroupingids=36&eventPhase=1&eventSortBy=2&marketCount=50&page=1&subCategoryIds=577' elif comp == 22: url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/901/en/event?betgroupgroupingids=36&eventPhase=1&eventSortBy=2&marketCount=50&page=1&subCategoryIds=578' elif comp == 23: url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/901/en/event?betgroupgroupingids=36&eventPhase=1&eventSortBy=2&marketCount=50&page=1&subCategoryIds=4830' elif comp == 25: url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/904/no/event?betgroupgroupingids=36&eventPhase=1&eventSortBy=2&marketCount=50&page=1&subCategoryIds=129' elif comp == 31: url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/904/no/event?betgroupgroupingids=36&eventPhase=1&eventSortBy=2&marketCount=50&page=1&subCategoryIds=148' elif comp == 32: url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/904/no/event?betgroupgroupingids=36&eventPhase=1&eventSortBy=2&marketCount=50&page=1&subCategoryIds=2079' elif comp == 42: url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/904/no/event?betgroupgroupingids=36&eventPhase=1&eventSortBy=2&marketCount=50&page=1&subCategoryIds=548' elif comp == 43: url = 'https://sbsitefacade2.bpsgameserver.com/isa/v2/904/no/event?betgroupgroupingids=36&eventPhase=1&eventSortBy=2&marketCount=50&page=1&subCategoryIds=3505' tmp = requests.get(url, headers=header) Nordicbettmp = tmp.json() for i in range(len(Nordicbettmp['el'])): Matches['events']['name'][i] = Nordicbettmp['el'][i]['en'] df.loc[i, 'name'] = Nordicbettmp['el'][i]['en'] Matches['events']['matchtime'][i] = parse(Nordicbettmp['el'][i]['sd']) df.loc[i, 'matchtime'] = parse(Nordicbettmp['el'][i]['sd']) tmpvals = numpy.empty((1, len(Nordicbettmp['el'][i]['ml'][0]['msl']))) for j in range(len(Nordicbettmp['el'][i]['ml'][0]['msl'])): tmpvals[0][j] = Nordicbettmp['el'][i]['ml'][0]['msl'][j]['msp'] df.iloc[i, j + 2] = Nordicbettmp['el'][i]['ml'][0]['msl'][j]['msp'] Matches['events']['odds'][i] = tmpvals df.name = fixNaming.fixNaming(df.name) Matches['events']['name'] = fixNaming.fixNaming(Matches['events']['name']) return Matches, df
def parseNT(comp): header = { 'UserAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Firefox/49.0', 'GET': '/api-langoddsen/getGameInformation.json?categories=true&filter=ligue HTTP/1.1', 'Host': 'www.norsk-tipping.no', 'Referer': 'https://www.norsk-tipping.no/sport/langoddsen', 'Connection': 'keep-alive' } Matches = {} Matches['events'] = {} Matches['events']['name'] = {} Matches['events']['matchtime'] = {} Matches['events']['odds'] = {} df = pd.DataFrame(columns=['name', 'matchtime', 'home', 'draw', 'away']) eventnameid = 1 if comp == 1: NTcomp = 1 elif comp == 2: NTcomp = 5 elif comp == 3: NTcomp = 36 elif comp == 4: NTcomp = 33 elif comp == 5: NTcomp = 4 elif comp == 6: NTcomp = 42 elif comp == 7: NTcomp = 2 elif comp == 8: NTcomp = 142 eventnameid = 0 elif comp == 10: NTcomp = 10909 elif comp == 11: NTcomp = 23 elif comp == 12: NTcomp = 673 elif comp == 15: NTcomp = 24 elif comp == 17: NTcomp = 6 elif comp == 15: NTcomp = 24 elif comp == 25: NTcomp = 6 elif comp == 37: NTcomp = 120 elif comp == 39: NTcomp = 100016613 tmp = requests.get( 'https://www.norsk-tipping.no/api-langoddsen/getGameInformation.json?categories=true&filter=ligue', headers=header) nt = json.loads(tmp.text[19:len(tmp.text) - 6]) j = 0 for i in range(len(nt['events'])): if nt['events'][i]['eventDetails'][1] == NTcomp and len( nt['events'][i]['eventDetails'][6]) > 0: Matches['events']['name'][j] = nt['events'][i]['eventDetails'][2][ eventnameid] df.loc[j, 'name'] = nt['events'][i]['eventDetails'][2][eventnameid] Matches['events']['matchtime'][ j] = datetime.datetime.fromtimestamp( nt['events'][i]['eventDetails'][4] / 1000, datetime.timezone.utc) df.loc[j, 'matchtime'] = datetime.datetime.fromtimestamp( nt['events'][i]['eventDetails'][4] / 1000, datetime.timezone.utc) tmpvals = numpy.empty( (1, len(nt['events'][i]['eventDetails'][6][0][3][2]))) for k in range(len(nt['events'][i]['eventDetails'][6][0][3][2])): tmpvals[0][ k] = nt['events'][i]['eventDetails'][6][0][3][2][k] / 100 df.iloc[ j, k + 2] = nt['events'][i]['eventDetails'][6][0][3][2][k] / 100 Matches['events']['odds'][j] = tmpvals j = j + 1 df.name = fixNaming.fixNaming(df.name) Matches['events']['name'] = fixNaming.fixNaming(Matches['events']['name']) return Matches, df
def parseBetfairExchange(comp): header = { 'host': 'strands.betfair.com', 'X-Application': 'nzIFcwyWhrlwYMrh', 'Accept': 'application/json, text/plain, */*', 'Accept-Language': 'en-US,en;q=0.5', 'Connection': 'keep-alive', 'Pragma': 'no-cache', 'Cache-Control': 'no-cache', 'Content-Type': 'application/json' } Matches = {} Matches['events'] = {} Matches['events']['name'] = {} Matches['events']['matchtime'] = {} Matches['events']['eventId'] = {} Matches['events']['odds'] = {} Matches['events']['marketId'] = {} if comp == 1: competitionId = 10932509 elif comp == 2: competitionId = 11068551 elif comp == 3: competitionId = 117 elif comp == 4: competitionId = 81 elif comp == 5: competitionId = 55 elif comp == 6: competitionId = 59 elif comp == 15: competitionId = 129 url = 'https://strands.betfair.com/api/eds/navigation-aggregator/v1?competitionId=' + str( competitionId) tmp = requests.get(url, headers=header) matchtmp = tmp.json() flds = list(matchtmp['fixtures'].keys()) posturl = 'https://strands.betfair.com/api/eds/coupon/v1' postbody = '{"search":{"type":"COMPETITION","ids":[' + str( competitionId ) + ']},"filters":{"selectBy":"TIME","timeFrame":"ALL","marketType":"MATCH_ODDS"},"limits":{"maxEventTypes":5,"maxEventsPerEventType":50,"maxCompetitions":5}}' tmp2 = requests.post(posturl, postbody, headers=header) tmpevent = tmp2.json() k = 0 for i in range(len(flds)): for j in range(len(matchtmp['fixtures'][flds[i]])): Matches['events']['name'][k] = matchtmp['fixtures'][ flds[i]][j]['name'] Matches['events']['matchtime'][k] = parse( matchtmp['fixtures'][flds[i]][j]['openDate']) Matches['events']['eventId'][k] = matchtmp['fixtures'][ flds[i]][j]['eventId'] k = k + 1 for i in range(len(tmpevent[0]['competitions'][0]['events'])): try: idEvent = list(Matches['events']['eventId'].values()).index( tmpevent[0]['competitions'][0]['events'][i]['eventId']) Matches['events']['marketId'][idEvent] = tmpevent[0][ 'competitions'][0]['events'][i]['marketId'] marketUrl = 'https://www.betfair.com/www/sports/exchange/readonly/v1/bymarket?alt=json¤cyCode=NOK&locale=no&marketIds=' + str( tmpevent[0]['competitions'][0]['events'][i]['marketId'] ) + '&rollupLimit=100&rollupModel=STAKE&types=MARKET_STATE,MARKET_RATES,MARKET_DESCRIPTION,EVENT,RUNNER_DESCRIPTION,RUNNER_STATE,RUNNER_EXCHANGE_PRICES_BEST,RUNNER_METADATA,MARKET_LICENCE' tmpdata = requests.get(marketUrl, headers=header) data = tmpdata.json() tmpvals = numpy.empty((1, len(data['eventTypes'][0]['eventNodes'][0] ['marketNodes'][0]['runners']))) for j in range( len(data['eventTypes'][0]['eventNodes'][0]['marketNodes'] [0]['runners'])): if j == 0: outcome = 0 elif j == 1: outcome = 2 elif j == 2: outcome = 1 try: tmpvals[0][outcome] = data['eventTypes'][0]['eventNodes'][ 0]['marketNodes'][0]['runners'][j]['exchange'][ 'availableToBack'][0]['price'] except: a = 0 Matches['events']['odds'][idEvent] = tmpvals except: a = 0 Matches['events']['name'] = fixNaming.fixNaming(Matches['events']['name']) return Matches
def parseUnibet(comp): header = { 'UserAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Firefox/49.0' } Matches = {} Matches['events'] = {} Matches['events']['name'] = {} Matches['events']['matchtime'] = {} Matches['events']['odds'] = {} df = pd.DataFrame(columns=['name', 'matchtime', 'home', 'draw', 'away']) if comp == 2: #TL url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ub/listView/football/norway/eliteserien.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1503558120523&categoryGroup=COMBINED&displayDefault=true' elif comp == 3: #La Liga url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ub/listView/football/spain/laliga.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1503558156971&categoryGroup=COMBINED&displayDefault=true&category=match' elif comp == 4: #Serie A url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ub/listView/football/italy/serie_a.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1503558193171&categoryGroup=COMBINED&displayDefault=true&category=match' elif comp == 5: #Ligue 1 url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ub/listView/football/france/ligue_1.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1503558281774&categoryGroup=COMBINED&displayDefault=true&category=match' elif comp == 6: #Bundesliga url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ub/listView/football/germany/bundesliga.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1503558235857&categoryGroup=COMBINED&displayDefault=true&category=match' elif comp == 7: #Championship url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ub/listView/football/england/the_championship.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1503558325841&categoryGroup=COMBINED&displayDefault=true&category=match' elif comp == 1: # PL url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ubuk/listView/football/england/premier_league.json?lang=en_GB&market=GB&client_id=2&channel_id=1&ncid=1503521419022&categoryGroup=COMBINED&displayDefault=true' elif comp == 8: #NHL url = 'https://e3-api.kambi.com/offering/api/v3/ub/listView/ice_hockey/nhl.json?lang=en_GB&market=ZZ&client_id=2&channel_id=1&ncid=1482450021775&categoryGroup=COMBINED&displayDefault=true' elif comp == 9: #FA Cup url = 'https://e3-api.kambi.com/offering/api/v3/ubuk/listView/football/england/fa_cup.json?lang=en_GB&market=GB&client_id=2&channel_id=1&ncid=1483687135632&categoryGroup=COMBINED&displayDefault=true' elif comp == 10: #Europa League url = 'https://e4-api.kambi.com/offering/api/v3/ubuk/listView/football/europa_league.json?lang=en_GB&market=GB&client_id=2&channel_id=1&ncid=1481185693162&categoryGroup=COMBINED&displayDefault=true' elif comp == 11: #Champions League url = 'https://e3-api.kambi.com/offering/api/v3/ub/listView/football/champions_league.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1505050337845&categoryGroup=COMBINED&displayDefault=true' elif comp == 12: #KHL url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ub/listView/ice_hockey/khl.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1503558379604&categoryGroup=COMBINED&displayDefault=true' elif comp == 13: #WC Qualification Europe url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ubuk/listView/football/world_cup_qualifying_-_europe.json?lang=en_GB&market=GB&client_id=2&channel_id=1&ncid=1489712503403&categoryGroup=COMBINED&displayDefault=true&category=match' elif comp == 14: #WC Hockey url = 'https://e4-api.kambi.com/offering/api/v3/ubuk/listView/ice_hockey/world_championship.json?lang=en_GB&market=GB&client_id=2&channel_id=1&ncid=1494003009981&categoryGroup=COMBINED&displayDefault=true' elif comp == 15: #Allsvenskan url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ubuk/listView/football/sweden/allsvenskan.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1494969936607&categoryGroup=COMBINED&displayDefault=true' elif comp == 16: #U20 VM url = 'https://e3-api.kambi.com/offering/api/v3/ubuk/listView/football/fifa_world_cup_u20.json?lang=en_GB&market=GB&client_id=2&channel_id=1&ncid=1495479807010&categoryGroup=COMBINED&displayDefault=true' elif comp == 17: #NM url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ub/listView/football/norway/nm_cupen.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1503558418380&categoryGroup=COMBINED&displayDefault=true&category=match' elif comp == 18: #MLS url = 'https://e3-api.kambi.com/offering/api/v3/ub/listView/football/usa/mls.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1495901462871&categoryGroup=COMBINED&displayDefault=true' elif comp == 19: url = 'https://e4-api.kambi.com/offering/api/v3/ubuk/listView/football/uefa_championship_u21.json?lang=en_GB&market=GB&client_id=2&channel_id=1&ncid=1497560040655&categoryGroup=COMBINED&displayDefault=true' elif comp == 20: url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ubuk/listView/football/fifa_confederations_cup.json?lang=en_GB&market=GB&client_id=2&channel_id=1&ncid=1497561687098&categoryGroup=COMBINED&displayDefault=true' elif comp == 21: url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ubuk/listView/tennis/grand_slam/wimbledon.json?lang=en_GB&market=GB&client_id=2&channel_id=1&ncid=1498862322746&categoryGroup=COMBINED&displayDefault=true' elif comp == 22: url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ubuk/listView/tennis/grand_slam/wimbledon_women.json?lang=en_GB&market=GB&client_id=2&channel_id=1&ncid=1499013475233&categoryGroup=COMBINED&displayDefault=true' elif comp == 23: url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ubuk/listView/football/uefa_womens_euro.json?lang=en_GB&market=GB&client_id=2&channel_id=1&ncid=1500198440372&categoryGroup=COMBINED&displayDefault=true&category=match' elif comp == 24: url = 'https://e3-api.kambi.com/offering/api/v3/ubuk/listView/football/club_tournaments/international_champions_cup.json?lang=en_GB&market=GB&client_id=2&channel_id=1&ncid=1500362589664&categoryGroup=COMBINED&displayDefault=true' elif comp == 25: url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ub/listView/football/norway/obos-ligaen.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1503558473950&categoryGroup=COMBINED&displayDefault=true&category=match' elif comp == 26: url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ub/listView/tennis/atp/washington.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1501499363793&categoryGroup=COMBINED&displayDefault=true' elif comp == 27: url = 'https://e3-api.kambi.com/offering/api/v3/ub/listView/baseball/mlb.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1501493795360&categoryGroup=COMBINED&displayDefault=true' elif comp == 28: url = 'https://e4-api.kambi.com/offering/api/v3/ub/listView/tennis/wta/washington.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1501572774893&categoryGroup=COMBINED&displayDefault=true' elif comp == 29: url = 'https://e3-api.kambi.com/offering/api/v3/ub/listView/football/club_tournaments/audi_cup.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1501584939749&categoryGroup=COMBINED&displayDefault=true' elif comp == 31: url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ub/listView/football/england/efl_cup.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1503311064536&categoryGroup=COMBINED&displayDefault=true' elif comp == 32: url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ub/listView/ice_hockey/champions_hockey_league.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1503575918860&categoryGroup=COMBINED&displayDefault=true&category=Match' elif comp == 33: url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ub/listView/tennis/grand_slam/us_open.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1503729034293&categoryGroup=COMBINED&displayDefault=true' elif comp == 34: url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ub/listView/tennis/grand_slam/us_open_women.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1503729137308&categoryGroup=COMBINED&displayDefault=true&category=match' elif comp == 35: url = 'https://e4-api.kambi.com/offering/api/v3/ub/listView/american_football/nfl.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1505034411972&categoryGroup=COMBINED&displayDefault=true' elif comp == 36: url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ub/listView/basketball/nba.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1508599214509&categoryGroup=COMBINED&displayDefault=true&category=match' elif comp == 37: url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ub/listView/ice_hockey/norway/get-ligaen.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1514319717366&categoryGroup=COMBINED&displayDefault=true' elif comp == 38: url = 'https://e4-api.kambi.com/offering/api/v3/ub/listView/handball/european_championship.json?lang=en_GB&market=ZZ&client_id=2&channel_id=1&ncid=1515694247184&categoryGroup=COMBINED&displayDefault=true' elif comp == 39: url = 'https://e4-api.kambi.com/offering/api/v3/ub/listView/tennis/grand_slam/australian_open.json?lang=en_GB&market=ZZ&client_id=2&channel_id=1&ncid=1516044722910&categoryGroup=COMBINED&displayDefault=true&category=match' elif comp == 40: url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ub/listView/tennis/grand_slam/australian_open_women.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1516376613510&categoryGroup=COMBINED&displayDefault=true&category=match' elif comp == 41: url = 'https://e1-api.aws.kambicdn.com/offering/api/v3/ub/listView/tennis/atp/miami.json?lang=no_NO&market=NO&client_id=2&channel_id=1&ncid=1521656107787&categoryGroup=COMBINED&displayDefault=true' elif comp == 42: url = 'https://e4-api.kambi.com/offering/api/v3/ub/listView/tennis/grand_slam/french_open.json?lang=en_GB&market=ZZ&client_id=2&channel_id=1&ncid=1527413592461&categoryGroup=COMBINED&displayDefault=true&category=match' elif comp == 43: url = 'https://api.aws.kambicdn.com/offering/api/v3/ub/listView/football/world_cup_2018.json?lang=en_GB&market=NO&client_id=2&channel_id=1&ncid=1528636372531&categoryGroup=COMBINED&displayDefault=true' tmp = requests.get(url, headers=header) Unibettmp = tmp.json() # Lag en egen Marius-fil #cwd= os.getcwd() #os.system("curl '%s' > %s/cmp.json" %(url, cwd)) #with open('cmp.json') as data_file: # Unibettmp = json.load(data_file) failed = 0 for i in range(len(Unibettmp['events'])): try: if type(Unibettmp['events']) is dict: Matches['events'][i]['name'] = Unibettmp['events'][i]['event'][ 'name'] df.loc[i, 'name'] = Unibettmp['events'][i]['event']['name'] Matches['events'][i][ 'matchtime'] = datetime.datetime.fromtimestamp( Unibettmp['events'][i]['event']['start'] / 1000, datetime.timezone.utc) df.loc[i, 'matchtime'] = datetime.datetime.fromtimestamp( Unibettmp['events'][i]['event']['start'] / 1000, datetime.timezone.utc) else: Matches['events']['name'][i] = Unibettmp['events'][i]['event'][ 'name'] df.loc[i, 'name'] = Unibettmp['events'][i]['event']['name'] Matches['events']['matchtime'][ i] = datetime.datetime.fromtimestamp( Unibettmp['events'][i]['event']['start'] / 1000, datetime.timezone.utc) df.loc[i, 'matchtime'] = datetime.datetime.fromtimestamp( Unibettmp['events'][i]['event']['start'] / 1000, datetime.timezone.utc) tmpvals = numpy.empty( (1, len(Unibettmp['events'][i]['betOffers'][0]['outcomes']))) if type(Unibettmp['events'][i]['betOffers']) is list: for j in range( len(Unibettmp['events'][i]['betOffers'][0] ['outcomes'])): tmpvals[0][j] = Unibettmp['events'][i]['betOffers'][0][ 'outcomes'][j]['odds'] / 1000 df.iloc[i, j + 2] = Unibettmp['events'][i][ 'betOffers'][0]['outcomes'][j]['odds'] / 1000 else: for j in range( len(Unibettmp['events'][i]['betOffers'] ['outcomes'])): tmpvals[0][j] = Unibettmp['events'][i]['betOffers'][0][ 'outcomes'][j]['odds'] / 1000 df.iloc[i, j + 2] = Unibettmp['events'][i][ 'betOffers'][0]['outcomes'][j]['odds'] / 1000 Matches['events']['odds'][i] = tmpvals except: failed = failed + 1 Matches['events']['name'] = fixNaming.fixNaming(Matches['events']['name']) df.name = fixNaming.fixNaming(df.name) return Matches, df
def parseCoolbet(Comp, version=1): header = { 'UserAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Firefox/49.0' } Matches = {} Matches['events'] = {} Matches['events']['name'] = {} Matches['events']['matchtime'] = {} Matches['events']['odds'] = {} df = pd.DataFrame(columns=['name', 'matchtime', 'home', 'draw', 'away']) if Comp == 2: #TL url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=19050&is_mobile=0&lastCategoryId=0' elif Comp == 3: #La Liga url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=19104&is_mobile=0&lastCategoryId=0' elif Comp == 4: #Serie A url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=18994&is_mobile=0&lastCategoryId=0' elif Comp == 5: #Ligue 1 url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=18849&is_mobile=0&lastCategoryId=0' elif Comp == 6: #Bundesliga url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=18986&is_mobile=0&lastCategoryId=0' elif Comp == 7: #Championship url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=18976&is_mobile=0&lastCategoryId=0' elif Comp == 1: #PL url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=18975&offset=0' elif Comp == 8: #NHL url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=18712&is_mobile=0&lastCategoryId=0' elif Comp == 9: #FA Cup url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=19076&is_mobile=0&lastCategoryId=0' elif Comp == 10: #Europa League url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=19129&is_mobile=0&lastCategoryId=0' elif Comp == 11: #Champions League url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=19128&is_mobile=0&lastCategoryId=0' elif Comp == 12: #KHL url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=18834&is_mobile=0&lastCategoryId=0' elif Comp == 13: #WC Qualification Europe url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=20086&is_mobile=0&lastCategoryId=0' elif Comp == 14: #WC Hockey url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=19764&is_mobile=0&lastCategoryId=0' elif Comp == 15: #Allsvenskan url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=19111&is_mobile=0&lastCategoryId=0' elif Comp == 16: #U20 VM url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=43069&is_mobile=0&lastCategoryId=0' elif Comp == 17: #NM url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=19052&is_mobile=0&lastCategoryId=0' elif Comp == 18: #MLS url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=19093&is_mobile=0&lastCategoryId=0' elif Comp == 19: #U21 EM url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=19931&is_mobile=0&lastCategoryId=0' elif Comp == 20: #Confederation Cup url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=43073&is_mobile=0&lastCategoryId=0' elif Comp == 21: #ATP Wimbledon url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=26402&is_mobile=0&lastCategoryId=0' elif Comp == 22: #WTA Wimbledon url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=26403&is_mobile=0&lastCategoryId=0' elif Comp == 23: #EURO Women url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=19933&is_mobile=0&lastCategoryId=0' elif Comp == 24: #International Champions Cup url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=20474&is_mobile=0&lastCategoryId=0' elif Comp == 25: #OBOS-ligaen url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=19051&is_mobile=0&lastCategoryId=0' elif Comp == 26: #ATP Washington url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=26628&is_mobile=0&lastCategoryId=0' elif Comp == 27: #MLB url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=18708&is_mobile=0&lastCategoryId=0' elif Comp == 28: #WTA Washington url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=26630&is_mobile=0&lastCategoryId=0' elif Comp == 29: #Audi Cup url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=44968&is_mobile=0&lastCategoryId=0' elif Comp == 31: #EFL Cup url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=28508&is_mobile=0&lastCategoryId=0' elif Comp == 32: #CHL url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=28500&is_mobile=0&lastCategoryId=0' elif Comp == 33: #US open url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=28666&is_mobile=0&lastCategoryId=0' elif Comp == 34: #US open women url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=28667&is_mobile=0&lastCategoryId=0' elif Comp == 35: #NFL url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=19488&is_mobile=0&lastCategoryId=0' elif Comp == 36: #NBA url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=19158&is_mobile=1&lastCategoryId=0' elif Comp == 37: #GET-ligaen url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=18841&is_mobile=0&lastCategoryId=0' elif Comp == 38: #European championship handball url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=18950&is_mobile=0&lastCategoryId=0' elif Comp == 39: #Australian open url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=29671&is_mobile=0&lastCategoryId=0' elif Comp == 40: #Australian open women url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=34460&is_mobile=0&lastCategoryId=0' elif Comp == 41: #ATP Miami url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=18685&is_mobile=0&lastCategoryId=0' elif Comp == 42: #French Open url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=25277&is_mobile=0&lastCategoryId=0' elif Comp == 43: #VM url = 'https://www.coolbet.com/s/fixtures/fo-match-category/?categoryId=46801&is_mobile=0&lastCategoryId=0' tmp = requests.get(url, headers=header) matchtmp = tmp.json() field = tuple(matchtmp['matches_by_category']) field = field[0] failed = 0 idx = 0 for index in range(len(matchtmp['matches_by_category'][field])): try: if type(matchtmp['matches_by_category'][field][index]) is dict: idx = -1 if len(matchtmp['matches_by_category'][field][index] ['markets']) > 1: k = 0 while k < len(matchtmp['matches_by_category'][field][index] ['markets']) and idx < 0: if matchtmp['matches_by_category'][field][index][ 'markets'][k]['name'] == 'Match Result (1X2)': idx = matchtmp['matches_by_category'][field][ index]['markets'][k]['id'] elif matchtmp['matches_by_category'][field][index][ 'markets'][k]['name'] == 'Money Line': idx = matchtmp['matches_by_category'][field][ index]['markets'][k]['id'] elif matchtmp['matches_by_category'][field][index][ 'markets'][k]['name'] == 'Match Result': idx = matchtmp['matches_by_category'][field][ index]['markets'][k]['id'] k = k + 1 else: idx = matchtmp['matches_by_category'][field][index][ 'markets'][0]['id'] tmp2 = requests.get( 'https://www.coolbet.com/s/sb-odds/odds/current/fo/?where=%7B%22market_id%22:%7B%22in%22:%5B' + str(idx) + '%5D%7D%7D', headers=header) oddstmp = tmp2.json() Matches['events']['name'][index - failed] = matchtmp[ 'matches_by_category'][field][index]['name'] df.loc[index - failed, 'name'] = matchtmp[ 'matches_by_category'][field][index]['name'] Matches['events']['matchtime'][index - failed] = parse( matchtmp['matches_by_category'][field][index] ['match_start']) df.loc[index - failed, 'matchtime'] = Matches['events']['matchtime'][index - failed] field2 = sorted(tuple(oddstmp)) tmpvals = numpy.empty((1, len(field2))) for index2 in range(len(field2)): tmpvals[0][index2] = oddstmp[field2[index2]]['value'] df.iloc[index - failed, index2 + 2] = oddstmp[field2[index2]]['value'] Matches['events']['odds'][index - failed] = tmpvals else: if len(matchtmp['matches_by_category'][field][index] ['markets']) > 1: idx = 0 k = 1 while k < len(matchtmp['matches_by_category'][field][index] ['markets']) and idx < 0: if matchtmp['matches_by_category'][field][index][ 'markets'][k]['name'] == 'Match Result (1X2)': idx = matchtmp['matches_by_category'][field][ index]['markets'][k]['id'] elif matchtmp['matches_by_category'][field][index][ 'markets'][k]['name'] == 'Money Line': idx = matchtmp['matches_by_category'][field][ index]['markets'][k]['id'] elif matchtmp['matches_by_category'][field][index][ 'markets'][k]['name'] == 'Match Result': idx = matchtmp['matches_by_category'][field][ index]['markets'][k]['id'] k = k + 1 else: idx = matchtmp['matches_by_category'][field][index][ 'markets'][0]['id'] tmp2 = requests.get( 'https://www.coolbet.com/s/sb-odds/odds/current/fo/?where=%7B%22market_id%22:%7B%22in%22:%5B' + str(idx) + '%5D%7D%7D', headers=header) oddstmp = tmp2.json() Matches['events']['name'][index - failed] = matchtmp[ 'matches_by_category'][field][index]['name'] Matches['events']['matchtime'][index - failed] = parse( matchtmp['matches_by_category'][field][index] ['match_start']) field2 = tuple(oddstmp) tmpvals = numpy.empty((1, len(field2))) for index2 in range(len(field2)): tmpvals[0][index2] = oddstmp[field2[index2]]['value'] Matches['events']['odds'][index - failed] = tmpvals except: failed = failed + 1 df.name = fixNaming.fixNaming(df.name) Matches['events']['name'] = fixNaming.fixNaming(Matches['events']['name']) return Matches, df
def parseBetsson(comp): header = { 'UserAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Firefox/49.0' } Matches = {} Matches['events'] = {} Matches['events']['name'] = {} Matches['events']['matchtime'] = {} Matches['events']['odds'] = {} df = pd.DataFrame(columns=['name', 'matchtime', 'home', 'draw', 'away']) if comp == 1: url = 'https://bts-api-a.bpsgameserver.com/isa/v2/605/no/event?betGroupIds=1,5,4058,65,127&categoryIds=1&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=11&subCategoryIds=3' elif comp == 2: #TL url = 'https://bts-api-a.bpsgameserver.com/isa/v2/601/en/event?betGroupIds=1,5,4058,65,127&categoryIds=1&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=18&subCategoryIds=128' elif comp == 3: #La Liga url = 'https://bts-api-a.bpsgameserver.com/isa/v2/601/en/event?betGroupIds=1,5,4058,65,127&categoryIds=1&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=25&subCategoryIds=12' elif comp == 4: #Serie A url = 'https://bts-api-a.bpsgameserver.com/isa/v2/601/en/event?betGroupIds=1,5,4058,65,127&categoryIds=1&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=17&subCategoryIds=9' elif comp == 5: #Ligue 1 url = 'https://bts-api-a.bpsgameserver.com/isa/v2/601/en/event?betGroupIds=1,5,4058,65,127&categoryIds=1&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=13&subCategoryIds=19' elif comp == 6: #Bundesliga url = 'https://bts-api-a.bpsgameserver.com/isa/v2/601/en/event?betGroupIds=1,5,4058,65,127&categoryIds=1&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=14&subCategoryIds=15' elif comp == 14: # WC Hockey url = 'https://bts-api-a.bpsgameserver.com/isa/v2/601/en/event?betGroupIds=6,31,32,410,8,66&categoryIds=2&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=129&subCategoryIds=444' elif comp == 24: url = 'https://bts-api-a.bpsgameserver.com/isa/v2/605/no/event?betGroupIds=1,5,4058,65,127&categoryIds=1&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=3&subCategoryIds=13334' elif comp == 26: #ATP Washington url = 'https://bts-api-a.bpsgameserver.com/isa/v2/605/no/event?betGroupIds=27,52,657,51,375,1919&categoryIds=11&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=38&subCategoryIds=4836' elif comp == 27: url = 'https://bts-api-a.bpsgameserver.com/isa/v2/605/no/event?betGroupIds=99,100,56,398,399&categoryIds=19&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=125&subCategoryIds=388' elif comp == 28: url = 'https://bts-api-a.bpsgameserver.com/isa/v2/605/no/event?betGroupIds=27,52,657,51,375,1919&categoryIds=11&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=39&subCategoryIds=4761' elif comp == 29: url = 'https://bts-api-a.bpsgameserver.com/isa/v2/605/no/event?betGroupIds=1,5,4058,65,127&categoryIds=1&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=3&subCategoryIds=6049' elif comp == 33: url = 'https://bts-api-a.bpsgameserver.com/isa/v2/605/no/event?betGroupIds=27,52,657,51,375,1919&categoryIds=11&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=38&subCategoryIds=668' elif comp == 34: url = 'https://bts-api-a.bpsgameserver.com/isa/v2/605/no/event?betGroupIds=27,52,657,51,375,1919&categoryIds=11&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=39&subCategoryIds=669' elif comp == 35: url = 'https://bts-api-a.bpsgameserver.com/isa/v2/605/no/event?betGroupIds=28,55,30,395,396&categoryIds=10&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=131&subCategoryIds=107' elif comp == 36: url = 'https://bts-api-a.bpsgameserver.com/isa/v2/601/en/event?betGroupIds=15,54,36,465,466&categoryIds=4&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=118&subCategoryIds=87' elif comp == 37: url = 'https://bts-api-a.bpsgameserver.com/isa/v2/605/no/event?betGroupIds=6,31,32,410,8,66&categoryIds=2&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=18&subCategoryIds=180' elif comp == 38: url = 'https://bts-api-a.bpsgameserver.com/isa/v2/601/en/event?betGroupIds=10,34,14,68,33&categoryIds=3&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=1&subCategoryIds=208' elif comp == 39: url = 'https://bts-api-a.bpsgameserver.com/isa/v2/601/en/event?betGroupIds=27,52,657,51,375,1919&categoryIds=11&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=38&subCategoryIds=106' elif comp == 40: url = 'https://bts-api-a.bpsgameserver.com/isa/v2/605/no/event?betGroupIds=27,52,657,51,375,1919&categoryIds=11&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=39&subCategoryIds=391' elif comp == 41: url = 'https://bts-api-a.bpsgameserver.com/isa/v2/601/en/event?betGroupIds=27,52,657,51,375,1919&categoryIds=11&eventPhase=1&eventSortBy=1&ocb=1f6efdd0-d13f-44be-9a5a-ea6195cc885d&onlyEvenLineMarkets=false®ionIds=38&subCategoryIds=464' tmp = requests.get(url, headers=header) Betssontmp = tmp.json() for i in range(len(Betssontmp['el'])): Matches['events']['name'][i] = Betssontmp['el'][i]['en'] df.loc[i, 'name'] = Betssontmp['el'][i]['en'] Matches['events']['matchtime'][i] = parse(Betssontmp['el'][i]['sd']) df.loc[i, 'matchtime'] = parse(Betssontmp['el'][i]['sd']) tmpvals = numpy.empty((1, len(Betssontmp['el'][i]['ml'][0]['msl']))) for j in range(len(Betssontmp['el'][i]['ml'][0]['msl'])): tmpvals[0][j] = Betssontmp['el'][i]['ml'][0]['msl'][j]['msp'] df.iloc[i, j + 2] = Betssontmp['el'][i]['ml'][0]['msl'][j]['msp'] Matches['events']['odds'][i] = tmpvals df.name = fixNaming.fixNaming(df.name) Matches['events']['name'] = fixNaming.fixNaming(Matches['events']['name']) return Matches, df
def parseOlybet(comp): header = { 'UserAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Firefox/49.0' } Matches = {} Matches['events'] = {} Matches['events']['name'] = {} Matches['events']['matchtime'] = {} Matches['events']['odds'] = {} df = pd.DataFrame(columns=['name', 'matchtime', 'home', 'draw', 'away']) if comp == 1: #PL url = 'https://olybet.eu/bet/parents/14321' elif comp == 2: #TL url = 'https://olybet.eu/bet/parents/13885' elif comp == 3: #La Liga url = 'https://olybet.eu/bet/parents/14090' elif comp == 4: #Serie A url = 'https://olybet.eu/bet/parents/14025' elif comp == 5: #Ligue 1 url = 'https://olybet.eu/bet/parents/14160' elif comp == 6: #Bundesliga url = 'https://olybet.eu/bet/parents/14172' elif comp == 7: #Championship url = 'https://olybet.eu/bet/parents/14322' elif comp == 8: #NHL url = 'https://olybet.eu/bet/parents/15182' elif comp == 9: #FA Cup url = 'https://www.olybet.eu/bet/parents/14326' elif comp == 10: #Europa League url = 'https://olybet.eu/bet/parents/13191' elif comp == 11: #Champions League url = 'https://olybet.eu/bet/parents/13213' elif comp == 12: #KHL url = 'https://olybet.eu/bet/parents/15170' elif comp == 13: #WC Qualification Europe url = 'https://olybet.eu/bet/parents/19107' elif comp == 14: #WC Hockey url = 'https://olybet.eu/bet/parents/15155' elif comp == 15: #Allsvenskan url = 'https://olybet.eu/bet/parents/13983' elif comp == 16: #U20 VM url = 'https://olybet.eu/bet/parents/13074' elif comp == 17: #NM url = 'https://olybet.eu/bet/parents/13897' elif comp == 18: #MLS url = 'https://olybet.eu/bet/parents/13365' elif comp == 19: #U21 EM url = 'https://olybet.eu/bet/parents/13172' elif comp == 20: #Confederations cup url = 'https://olybet.eu/bet/parents/13088' elif comp == 21: #ATP Wimbledon url = 'https://olybet.eu/bet/parents/16257' elif comp == 22: #WTA Wimbledon url = 'https://olybet.eu/bet/parents/16258' elif comp == 23: #EURO Women url = 'https://olybet.eu/bet/parents/17199' elif comp == 24: url = 'https://olybet.eu/bet/parents/13099' elif comp == 25: url = 'https://olybet.eu/bet/parents/13863' elif comp == 26: url = 'https://olybet.eu/bet/parents/15627' elif comp == 27: url = 'https://olybet.eu/bet/parents/15134' elif comp == 28: url = 'https://olybet.eu/bet/parents/15618' elif comp == 29: url = 'https://olybet.eu/bet/parents/13084' elif comp == 31: url = 'https://olybet.eu/bet/parents/14375' elif comp == 32: url = 'https://olybet.eu/bet/parents/15173' elif comp == 33: url = 'https://olybet.eu/bet/parents/15626' elif comp == 34: url = 'https://olybet.eu/bet/parents/15635' elif comp == 35: url = 'https://www.olybet.eu/bet/parents/15114' elif comp == 36: url = 'https://www.olybet.eu/bet/parents/16628' elif comp == 37: url = 'https://www.olybet.eu/bet/parents/15216' elif comp == 38: url = 'https://www.olybet.eu/bet/parents/14521' elif comp == 39: url = 'https://www.olybet.eu/bet/parents/16197' elif comp == 40: url = 'https://www.olybet.eu/bet/parents/16194' elif comp == 41: url = 'https://www.olybet.eu/bet/parents/15632' elif comp == 42: url = 'https://www.olybet.eu/bet/parents/16095' elif comp == 43: url = 'https://www.olybet.eu/bet/parents/13076' tmp = requests.get(url, headers=header) matchtmp = tmp.json() string = matchtmp['data'] starttag = 'Minimalt antall kombinerte' idstart = string.rfind(starttag) if idstart < 0: string = string else: string = string[idstart:len(string)] nametag = ';name":"' endnametag = '","alt_name":"' oddstag = '","coef":"' endoddstag = '","option":"' timetag = '<span class="event-sport-and-time"> <span class="datetime" title="' timeids = list(main.find_all(string, timetag)) nameids = list(main.find_all(string, nametag)) endnameids = list(main.find_all(string, endnametag)) oddsids = list(main.find_all(string, oddstag)) endoddsids = list(main.find_all(string, endoddstag)) # calculate how many outcomes there are per game. mnames = {} for i in range(len(nameids)): mnames[i] = string[nameids[i] + len(nametag):endnameids[i]] temp = set(val for dic in mnames for val in mnames.values()) N_outcomes = int(len(oddsids) / len(temp)) for i in range(len(timeids)): Matches['events']['name'][i] = string[nameids[i * N_outcomes] + len(nametag ):endnameids[i * N_outcomes]] df.loc[i, 'name'] = string[nameids[i * N_outcomes] + len(nametag):endnameids[i * N_outcomes]] Matches['events']['matchtime'][i] = parse( string[timeids[i] + len(timetag):timeids[i] + len(timetag) + 16] + ' UTC') df.loc[i, 'matchtime'] = parse( string[timeids[i] + len(timetag):timeids[i] + len(timetag) + 16] + ' UTC') tmpvals = numpy.empty((1, N_outcomes)) for j in range(N_outcomes): tmpvals[0][j] = float( string[oddsids[i * N_outcomes + j] + len(oddstag):endoddsids[i * N_outcomes + j]]) df.iloc[i, j + 2] = float( string[oddsids[i * N_outcomes + j] + len(oddstag):endoddsids[i * N_outcomes + j]]) Matches['events']['odds'][i] = tmpvals Matches['events']['name'] = fixNaming.fixNaming(Matches['events']['name']) df.name = fixNaming.fixNaming(df.name) return Matches, df