import requests from bs4 import BeautifulSoup url = "https://www.premierleague.com/tables" html = requests.get(url).content soup = BeautifulSoup(html, "html.parser") table = soup.find("table", {"class": "tableDark"}) headers = [header.text.strip() for header in table.find_all("th")] teams_data = [] for row in table.find_all("tr"): team_data = [data.text.strip() for data in row.find_all("td")] if team_data: teams_data.append(team_data) # Print table headers print("{:<4} {:<20} {:<6} {:<6} {:<6} {:<6} {:<6} {:<6} {:<6} {:<6}".format(*headers)) # Print table data for team in teams_data: print("{:<4} {:<20} {:<6} {:<6} {:<6} {:<6} {:<6} {:<6} {:<6} {:<6}".format(*team))
top of page
prem lion.png
Competition

PREMIER LEAGUE

bottom of page