r/PythonLearning • • 7h ago

Help Request Need Help With My Selenium Spotify Playlist Scraper

Hello, I am attempting to make a spotify playlist scraper. The html reading and everything else is working correctly but the automatic scrolling is not fully working yet and I am stuck. For some reason when i get to about the 100 song mark, Spotify refuses to load any more songs for me. I have tried waiting it out, scrolling a bit more to hopefully trigger it to load, and adding some fake clicks to try to trigger spotify to load. I dont know why it is doing this because when I manually use page down to scroll on a seperate browser it works perfectly. Here is a video of what is happening, and I have linked my github repo for you guys to take a look at it because I cannot post both a video and an image.

HERE

3 Upvotes

2 comments sorted by

1

u/mountain-snowman 1h ago

There are many ways through many events to detect the point when Spotify needs to load more songs. You have to figure out what event triggers the load function and use selenium to trigger that event.

If you are developing not a tool but rather a script that you are planning to use only a couple of times, you can use the devtools for scraping. Scroll manually to load songs and then manually call the script to scrape. Finally, get all your data in json.

1

u/Austinwhitely 14m ago

Okay thanks for helping me understand a bit better. I still would like to make this as a mostly automatic program to at least have a completed project in my portfolio.

But regarding finding the event triggers to load the songs, is there an easy way to narrow down what trigger I'm looking to access in the f12 mode. Because when I am looking at the page in element mode, all of the code is really bunches up and nested which make it hard for me to parse what a section does.

Thanks in advance