Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iamtalhaasghar/45da0db61e2468c0d5bf98cae516a41e to your computer and use it in GitHub Desktop.
Save iamtalhaasghar/45da0db61e2468c0d5bf98cae516a41e to your computer and use it in GitHub Desktop.
A simple javascript code snippet to scrap video list from a youtube playlist. Just open up the playlist in a new tab. Go to Console, paste the code and boom!!! ProTip: Copy the console log to clipboard and then paste the clipboard contents to a newly created .csv file. You will have your required data in a nice clean format.
/*
I use this script to scrap video titles of a playlist of my competitor and
then I use those keywords in my playlist videos too.
Tested on Firefox 80.0.1
Not sure about other browsers
*/
// get div containing playlist items
playlist = document.getElementsByTagName('ytd-playlist-video-renderer')
videoNames = ''
for(i=0; i < playlist.length; i++){
video = playlist[i].innerText.replace(',','').split('\n') // converts "videoname, title, views" => "videoname title views"
videoNames += video.toString() +"\n"
}
// Enjoy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment