[Python] Unable to get the proper data of La Liga Points Table from the FC Barcelona website...

Discussão em 'Python' iniciado por Stack, Dezembro 7, 2024.

  1. Stack

    Stack Membro Participativo

    Im trying to extract the points table data from the https://www.fcbarcelona.com/en/football/first-team/standings website. I want to extract the data of the current table (24-25) but it is extracting the previous years (23-24) table data

    Code:

    from bs4 import BeautifulSoup
    import requests

    url = 'https://www.fcbarcelona.com/en/football/first-team/standings'
    response = requests.get(url)
    soup = BeautifulSoup(response.content, 'html.parser')

    team_names_tag = soup.find_all("span", class_="team-row__name--short")
    team_names=[]

    for team_name in team_names_tag:
    team_names.append(team_name.text.replace("\n", "").strip())

    print(team_names)


    points_tag = soup.find_all("td", class_="table-stat-row table-stat-row--points")
    points=[]

    for point in points_tag:
    points.append(point.text.replace("\n", "").strip())

    print(points)


    Output:

    ['R. Madrid', 'FC Barcelona', 'Girona', 'Atlético', 'Athletic Club', 'Real Sociedad', 'Betis', 'Villarreal', 'Valencia', 'Alavés', 'Osasuna', 'Getafe', 'Celta de Vigo', 'Sevilla', 'Mallorca', 'UD Las Palmas', 'Rayo', 'Cádiz', 'Almería', 'Granada']
    ['95', '85', '81', '76', '68', '60', '57', '53', '49', '46', '45', '43', '41', '41', '40', '40', '38', '33', '21', '21']

    Continue reading...

Compartilhe esta Página