Last active
March 21, 2024 00:17
-
-
Save josharagon/209eb30152a9bad3da5d4992ca680c67 to your computer and use it in GitHub Desktop.
crates.io tracklist scraper
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
function extractTrackLinks(temp) { | |
const doc = document.createElement('div'); | |
doc.innerHTML = temp.outerHTML; | |
const tracks = doc.querySelectorAll('.tracks tr:not(.headerRow)'); | |
if (tracks.length === 0) { | |
console.log("No tracks found in the table."); | |
return; | |
} | |
const trackLinks = []; | |
for (let i = 0; i < tracks.length; i++) { | |
const track = tracks[i]; | |
const trackLink = track.querySelector('td:nth-child(3) a').getAttribute('href'); | |
if (trackLink) { | |
trackLinks.push("https://www.beatport.com" + trackLink); | |
} | |
} | |
// Join the track links array into a single string with line breaks | |
return trackLinks.join('\n'); | |
} | |
const allTrackLinks = extractTrackLinks(temp1); | |
console.log(allTrackLinks); |
update - return all track ids for beatport.
can use soundiiz to auto add to playlist
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
store .tracks table element as global var
run extractArtistTitle(temp1) etc..