extracting data from a website (spotify) using javascript

308 views Asked by At

I'm trying to extract text data from a list on spotify (a list of artists I follow) using javascript console in firefox browser. I'm using this code to extract all the artist names from the elements with class 'title':

  artists = document.getElementsByClassName('title')

Unfortunately, in Firefox I only get 4 random elements that having nothing to do with the artists. However in Chrome it works, I'll get a list with all the artist names as a output. But only after I selected one element using the inspector function first.

Unfortunely Chrome doesn't proper load the spotify webpage so the list is incomplete. How can I make this work using the Firefox javascript console?

Maybe it has something to do with the Spotify webpage is only visible after logging into my account. Thanks in advance.

1

There are 1 answers

2
Ivan On BEST ANSWER

Would something like this work?

var all = document.querySelectorAll('.following .title');
all.forEach(function(item) { console.log(item.innerHTML) })

When I run this in my console I get something like this. You could of course add each text item to a new array and do whatever with it.

Followed artists in Spotify web player console