Tiny URL meta-data fetcher that scraps the meta-data of a given
URL
string.
Under the hood it uses node-fetch to fetch the metadata, parses it and returns it as json object.
npm install meta-fetcher
const fetchMetaData = require('meta-fetcher');
(async () => {
const result = await fetchMetaData('https://hoppscotch.io/');
console.log(result);
/*
{
basic_metadata: {
website: 'https://hoppscotch.io/',
title: 'Hoppscotch • A free, fast and beautiful API request builder',
description: 'A free, fast and beautiful API request builder'
},
opengraph: {
'og:image': 'https://hoppscotch.io/banner.jpg',
'og:type': 'website',
'og:title': 'Hoppscotch',
'og:site_name': 'Hoppscotch',
'og:description': 'A free, fast and beautiful API request builder',
'og:url': 'https://hoppscotch.io/'
},
opengraph_social: {
'twitter:card': 'summary_large_image',
'twitter:site': '@liyasthomas',
'twitter:creator': '@liyasthomas'
},
favicons: [
'https://hoppscotch.io/icon.png',
'https://hoppscotch.io/icon.png',
'https://hoppscotch.io/_nuxt/icons/icon_64x64.9834b3.png'
]
}
*/
})();
You can optionally set the userAgent
and fromEmail
options in request Header
while fetching the meta-data.
const fetchMetaData = require('meta-fetcher');
(async () => {
const result = await fetchMetaData('https://hoppscotch.io/', {
userAgent: 'Rocktim',
fromEmail: 'srocktim61@gmail.com'
});
console.log(result);
})();
It can also fetch meta-data from shortened-url
.For example:
const fetchMetaData = require('meta-fetcher');
(async () => {
const result = await fetchMetaData('https://bit.ly/2Fj9sNF');
console.log(result);
})();
You can set these options in Header while fetching the data if needed.
Option | Required | Default Value |
---|---|---|
userAgent |
No | meta-fetcher |
fromEMail |
No | metafetch@email.com |
metaDataFetch(url, options)
Type: string
url string that you want to fetch the meta-data from.
Type: object
Optional Header
paramerter you can set if needed.
For any new feature request or bug report, please open an issue or pull request in GitHub.
MIT © Rocktim Saikia