DEV Community

kayYOLO
kayYOLO

Posted on

2

A Spotify robot

Spotify robot

I want to scrape a Spotify playlist from a web page, at first I try to use selenium, but it is not obtaining the full list, as the song list is dynamically loaded, I must scroll down to the bottom, then it can load all songs.

Finally, I find one Visual Studio Code automation development tool, clicknium (it should be new in 2022), it is really easy to use and one click to locate the UI element.
I just need to record two locators and write several lines of python code, the job is accomplished.

As the list is dynamically loaded, I use an iterate index to search each item, as clicknium can automatically scroll the item into view, it will trigger to load new items, so I don't need to take care of the dynamic loading.

I use a parametric locator for title and author

titleImage description

Image description

As one item may have multiple authors, so I use the following code to get multiple author's names and links:

    element = tab.find_element(locator.chrome.open.div_author, {'index':index})
    authers = element.children
    for item in element.children:
        artist.append(item.get_text())
        link.append(item.get_property('href'))
Enter fullscreen mode Exit fullscreen mode

If you want to try Clicknium, you can get started with the video on clicknium official site.

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay