Last active
July 25, 2021 14:43
-
-
Save ljaviertovar/534f564a8855e8a84894ac26ee390da3 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
// import libraries | |
const puppeteer = require("puppeteer"); | |
const urlencode = require("urlencode"); | |
// define vriables | |
let search = 'The Doors'; | |
const SP_BASE_URL = "https://open.spotify.com"; | |
const SP_SEARCH_URL = SP_BASE_URL + "/search/" + urlencode(search); | |
const YT_BASE_URL = "https://www.youtube.com"; | |
// launch new browser with headless = false to see the browser and maximize the window | |
const browser = await puppeteer.launch({ | |
headless: false, | |
args: ["--start-maximized"], | |
}); | |
// open new page | |
const page = await browser.newPage(); | |
// assing the windows size | |
await page.setViewport({ width: 1280, height: 800 }); | |
// go to spotify URI to search the playlist | |
await page.goto(SP_SEARCH_URL, { waitUntil: "networkidle2" }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment