Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Parse keywords from URL
let url = "https://www.amazon.com/SanDisk-128GB-microSDXC-Memory-Adapter/dp/B073JYC4XM/";
let kwparse = (url.replace('https://','').replace('http://','').replace('www','').replace('com','').split('-').join().split('/').join().split('.')).join(',').replace(/^,/, '')
let kwuniq = [...new Set(kwparse.split(','))].filter(function(e){return e});
console.log(kwuniq)
// ["amazon", "SanDisk", "128GB", "microSDXC", "Memory", "Adapter", "dp", "B073JYC4XM"]
// Hat Tip - Find a cleaner version at https://gist.github.com/dsottimano/52060e6a43d96804f33c59366c472305
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.