Skip to content

Instantly share code, notes, and snippets.

@emnopal
Created June 3, 2024 05:41
Show Gist options
  • Select an option

  • Save emnopal/f1fb4ceb4d4dadf4ea879df6798611a2 to your computer and use it in GitHub Desktop.

Select an option

Save emnopal/f1fb4ceb4d4dadf4ea879df6798611a2 to your computer and use it in GitHub Desktop.

Revisions

  1. emnopal renamed this gist Jun 3, 2024. 1 changed file with 0 additions and 0 deletions.
  2. emnopal created this gist Jun 3, 2024.
    20 changes: 20 additions & 0 deletions scraping-youtube-music-playlist,js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    const foo = document.getElementsByTagName('ytmusic-responsive-list-item-renderer');
    const musicObj = {}

    for (let i = 0; i < foo.length; i++){
    let newObj = foo[i];
    let otherObj = newObj.getElementsByTagName('yt-formatted-string');
    for (let j = 0; j < otherObj.length; j++){
    let a = otherObj[j];
    let aObj = a.getElementsByTagName('a');
    let aObjGHTML = aObj[0];
    if (aObjGHTML){
    if (aObjGHTML.href.includes('watch')) {
    // console.log(aObjGHTML)
    musicObj[aObjGHTML.innerHTML] = aObjGHTML.href
    }
    }
    }
    }

    console.log(musicObj)