I want to make a python program that when given a link to a Spotify playlist will return a list of the track names. This is what I have so far.
from bs4 import BeautifulSoup
from selenium import webdriver
url="https://open.spotify.com/playlist/1xXEN6UhQEMsVhX4KitlhW"
driver = webdriver.Firefox()
driver.get(url)
page = driver.page_source
page_soup = BeautifulSoup(page,'html.parser')
tracks = page_soup.findAll("div",{"class":"tracklist-name"})
print(tracks)
print(len(tracks))
driver.close()
However this only returns the first 100 songs. I have discovered that typing document.getElementsByClassName("tracklist-name") into the developer console in browser will also only return the first 100 songs, unless I have scrolled to the bottom of the page, so I want to scroll to the bottom of the page first but window.scrollTo(0, document.body.scrollHeight) does not work because the playlist isn't in the main body, the actual body of the page cannot be scrolled at all (I don't know all the technical terms I am a newbie at Javascript).
So how would I write a script that scrolls to the bottom of the Spotify playlist such that I can extract all the songs, not just the first 100?