The EASIEST Way To Scrape Pinnacle Odds

The Scraper Guy
2 min readApr 29, 2022

Following on from the Bet365 article this time its the turn of the so called sharpest sportsbook in the world Pinnacle.

Lets get into it.

Lets import some libraries.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import pandas as pd
import pandas as pd
import statsmodels
import numpy as np
import datetime
import time
from pandas_datareader import data as pdr
from statsmodels.tsa.stattools import adfuller
import pandas as pd
import numpy as np
%matplotlib inline
import statistics
import requests #The requests library for HTTP requests in Python
import xlsxwriter #The XlsxWriter libarary for
import math #The Python math module
from scipy import stats #The SciPy stats module
from selenium.webdriver.support.ui import Select

Next lets initialize our selenium chrome wedriver

driver = webdriver.Chrome('D:/Downloads/chromedriver_win32/chromedriver.exe')
driver.get('https://www.pinnacle.com/en/soccer/italy-serie-a/matchups#period:0')

We are going to scarping match odds from Serie A Football Matches.

We will then scrape teams and odds to make sure we have found the correct classes

teams = driver.find_elements_by_class_name("style_participant__H8-ku")
for i in teams:
print(i.text)
odds = driver.find_elements_by_class_name("style_price__15SlF")
for i in odds:
print(i.text)

Then we can initialize our dataframe and columns we will need

my_columns = ['Home Team','Away Team','Home Team Odds','Draw Odds','Away Team Odds']
final_dataframe = pd.DataFrame(columns = my_columns)

And a simple function that takes in a string and converts it to a list

def Convert(string):
li = list(string.split(","))
return li

We will then create a new string with the team names and convert it to a list and separate the list into home and away teams

string_new = ''
for i in teams:
string_new = string_new + i.text + ","
print(string_new)
teams = Convert(string_new)
home_teams = teams[::2]
home_teams = list(filter(None, home_teams))
print(home_teams)
away_teams = teams[1::2]
print(away_teams)

Again repeat this but for the odds

string_new2 = ''
for i in odds:
string_new2 = string_new2 + i.text + ","
print(string_new2)odds = Convert(string_new2)
print(odds)
home_odds = odds[::3]
home_odds = list(filter(None, home_odds))
print(home_odds)
draw_odds = odds[1::3]
print(draw_odds)
away_odds = odds[2::3]
print(away_odds)

And finally we can add all our data to the dataframe

final_dataframe['Home Team'] = home_teams
final_dataframe['Away Team'] = away_teams
final_dataframe['Home Team Odds'] = home_odds
final_dataframe['Draw Odds'] = draw_odds
final_dataframe['Away Team Odds'] = away_odds
final_dataframe

And our dataframe should look like the above ^

As easy as that.

Thanks for reading hit a follow more for tutorials like this.

--

--