I added a little bit of code to allow scraping multiple days, as I'm in Aus time zone it would sometimes be getting the next days data, so this helps to get everything.
def scrape_games(self, sport="NBA", date="", current_line=True,allGames=True):
_line = 'currentLine' if current_line else 'openingLine'
spreads = moneylines = totals = []
if date == "":
date = datetime.today().strftime("%Y-%m-%d")
yesterday = datetime.now() - timedelta(hours=18)
tomorrow = datetime.now() + timedelta(hours=18)
if allGames == True:
dates = [yesterday.strftime("%Y-%m-%d"),date,tomorrow.strftime("%Y-%m-%d")]
else:
dates = [date]
self.dates = dates
for date in dates:
I added a little bit of code to allow scraping multiple days, as I'm in Aus time zone it would sometimes be getting the next days data, so this helps to get everything. def scrape_games(self, sport="NBA", date="", current_line=True,allGames=True): _line = 'currentLine' if current_line else 'openingLine' spreads = moneylines = totals = [] if date == "": date = datetime.today().strftime("%Y-%m-%d") yesterday = datetime.now() - timedelta(hours=18) tomorrow = datetime.now() + timedelta(hours=18) if allGames == True: dates = [yesterday.strftime("%Y-%m-%d"),date,tomorrow.strftime("%Y-%m-%d")] else: dates = [date] self.dates = dates for date in dates:
normal code here