Scraping the Billboard Hot 100
- Target of out first task is to scrap top100 songs from specified date from bill board list
- Get all of song titles
- Use Spotify API to create a new playlist
- Add these songs to our new playlist
- Finally we have new playlist of Top 100 with specify date
Billboard Hot 100
#travel_date = input("which year you want to travel to? Type the date in this format YYYY-MM-DD:")
travel_date = "2022-09-30"
- Scrape the top 100 song titles from Billboard web site on that date into a Python list
from wsgiref import headers
import requests
from bs4 import BeautifulSoup
billboard_url = f"<https://www.billboard.com/charts/hot-100/{travel_date}/>"
response = requests.get(billboard_url)
soup = BeautifulSoup(response.text,"html.parser")
titles = soup.find_all(name="h3", class_="u-max-width-330")
title_list = [title.getText().strip() for title in titles]
title_list
Creating and Adding to Spotify Playlist
pip install spotipy
Registry and Authenticate with Spotify
1. Registry user account on Spotify.com
2. Get user information from Spotify account <https://developer.spotify.com/dashboard/applications/27ac73ad261c49af85aa148276970037>
3. Copy your client_id and client_sceret from Spotify