Code Monkey home page Code Monkey logo

meta-fetcher's Introduction

meta-fetcher ๐Ÿ”Ž

Tiny URL meta-data fetcher that scraps the meta-data of a given URL string.

Travis (.com) branch XO code style

Under the hood it uses node-fetch to fetch the metadata, parses it and returns it as json object.

Install

npm install meta-fetcher

Basic Usage

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'
        ]
        }
    */ 
})();

Advanced Usage (with options)

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: '[email protected]'
	});
	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);
})();

Options

You can set these options in Header while fetching the data if needed.

Option Required Default Value
userAgent No meta-fetcher
fromEMail No [email protected]

API

metaDataFetch(url, options)

url

Type: string url string that you want to fetch the meta-data from.

options

Type: object Optional Header paramerter you can set if needed.

Contribute

For any new feature request or bug report, please open an issue or pull request in GitHub.

License

MIT ยฉ Rocktim Saikia

meta-fetcher's People

Contributors

rocktimsaikia avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.