r/CodingHelp • • 2h ago

[Python] Need Help With My Selenium Spotify Playlist Scraper

0 Upvotes

2 comments sorted by

•

u/AutoModerator 2h ago

Thank you for posting on r/CodingHelp!

Please check our Wiki for answers, guides, and FAQs: https://coding-help.vercel.app

Our Wiki is open source - if you would like to contribute, create a pull request via GitHub! https://github.com/DudeThatsErin/CodingHelp

We are accepting moderator applications: https://forms.fillout.com/t/ua41TU57DGus

We also have a Discord server: https://discord.gg/geQEUBm

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

•

u/PLBjt 1h ago

Spotify virtualizes that list, so only around 100 rows exist in the DOM at once and it loads the next batch based on the scroll position of the inner container, not the window. If you're doing window.scrollTo or sending PageDown to body, nothing moves after the first batch. Grab the div that actually scrolls (the one with overflow-y inside main) and either bump its scrollTop in a loop or scrollIntoView the last visible row with execute_script, then wait until a new row index shows up (the rows usually carry aria-rowindex). Collect tracks as you go into a dict keyed by that index, because rows near the top get dropped from the DOM while you scroll. If you're open to it, the Web API's playlist tracks endpoint gives you the whole thing paginated with no scroll fight.