Last active
July 25, 2021 14:51
-
-
Save ljaviertovar/792fb886b2504db5780b5bda8ca12963 to your computer and use it in GitHub Desktop.
Scraper to get songs of spotify and create playlist on youtube
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// go to the playlists section | |
const [linkPlaylist] = await page.$x("//a[contains(text(), 'Playlist')]"); | |
await linkPlaylist.click(); | |
await page.waitForNavigation(); | |
// get all playlists found | |
const listPlaylists = await page.evaluate(() => { | |
let list = []; | |
let playlists = Array.from( | |
document.querySelectorAll("._3802c04052af0bb5d03956299250789e-scss") | |
); | |
playlists.map((playlist) => { | |
let linkPlayList = playlist.querySelector("a"); | |
list.push({ | |
title: linkPlayList.getAttribute("title"), | |
link: linkPlayList.getAttribute("href"), | |
}); | |
}); | |
return list; | |
}); | |
// go to first playlist | |
await page.goto(SP_BASE_URL + listPlaylists[0].link, { waitUntil: "networkidle2" }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment