I am trying to perform web scraping using Python on the ESPN website to extract historical soccer game results scores only into a csv file. I’m unable to find a way to add data as displayed in the desired output. Could someone help me a way to get the desired output. I am unable to fetch any relevant tags to scrape using BeautifulSoup on python. The website I am using to scrape the data and the desired output is below:
Website:
https://www.espn.com/soccer/scoreboard/_/league/all/date/20230121
desired output:
Date, League, Home_Team, Home_Team_Score, Away_Team, Away_Team_Score
01/23/2022, English Premier League, Liverpool, 0, Chelsea, 0
01/23/2022, English Premier League, AFC Bournemouth, 1, Nottingham Forest, 1
01/23/2022, English Premier League, Leicester City, 2, BRIGHTON & HOVE ALBION, 2
What I have tried:
The start of the code:
import bs4
from bs4 import BeautifulSoup
import requests
url = "https://www.espn.com/soccer/scoreboard/_/league/all/date/20230121"
response = urlopen(url)
urlname = requests.get(url)
bs = bs4.BeautifulSoup(urlname.text,'lxml')
soup = BeautifulSoup(requests.get(url).content, 'html.parser')
soup.prettify()