url-metadata
Version:
Request a url and scrape the metadata from its HTML using Node.js or the browser.
18 lines (15 loc) • 362 B
JavaScript
module.exports = function ($) {
const $linkTags = $('link')
const extracted = []
$linkTags.each(function (index, el) {
const hreflang = $(this).attr('hreflang')
if (hreflang) {
const attrs = {
hreflang: $(this).attr('hreflang'),
href: $(this).attr('href')
}
extracted.push(attrs)
}
})
return extracted
}