Click here to Skip to main content
15,906,467 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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:

Python
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()
Posted
Updated 4-Feb-23 12:31pm
v2
Comments
Dave Kreskowiak 4-Feb-23 20:06pm    
OK, so you have no code at all digging into the resulting data structure to pull the data out. You've created a parser, but never used it for anything.
Richard Deeming 6-Feb-23 10:39am    
REPOST
This is the same question you posted last week, with all of the useful code ripped out:
Web scraping ESPN NFL with Python[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900