[Python] Python, Web Scraping [duplicate]

Discussão em 'Python' iniciado por Stack, Agosto 26, 2025.

  1. Stack

    Stack Membro Participativo

    I tried scraping a website using BeautifulSoup and no matter the method or selector I try it always returns an empty list. This was supposed to print the top 1001 songs on the billboard chart

    from bs4 import BeautifulSoup
    import requests

    date = input("Which year do you want to travel to? Type the date in this format YYYY-MM-DD: ")

    response = requests.get("https://www.billboard.com/charts/hot-100/" + date)

    soup = BeautifulSoup(response.text, 'html.parser')
    song_names_spans = soup.find_all("span", class_="chart-element__information__song")
    song_names = [song.getText() for song in song_names_spans]

    Continue reading...

Compartilhe esta Página