I need to scrape Live matches only from https://www.livescore.com/en/football/live/. The code below now gives me back the full list of football matches available (not started, live and finished) with home team name, away team name and start time. What I need is a dataframe with live match, home team name, away team name and current minute of play.
THX
import requests
import pandas as pd
import datetime
url = "https://prod-public-api.livescore.com/v1/api/react/date/soccer/20220309/0.00?MD=1"
jsonData = requests.get(url).json()
rows = []
for stage in jsonData['Stages']:
events = stage['Events']
for event in events:
gameDateTime = event['Esd']
date_time_obj = datetime.datetime.strptime(str(gameDateTime), '%Y%m%d%H%M%S')
gameTime = date_time_obj.strftime("%H:%M")
homeTeam = event['T1'][0]['Nm']
awayTeam = event['T2'][0]['Nm']
row = {
'Home':homeTeam,
'Away':awayTeam,
'Time':gameTime}
rows.append(row)
df = pd.DataFrame(rows)