Skip to content

Latest commit

 

History

History
111 lines (80 loc) · 2.6 KB

README.md

File metadata and controls

111 lines (80 loc) · 2.6 KB

cooparser

npm version install size npm downloads Open Source Helpers

Sites information parser for the browser and node.js with javascript & typescript

Table of Contents

Features

  • When you give the site's url to cooparser and then, cooparser will give you the object has some information about that URL
  • The information from URL is title, content, link(URL), favicon, thumbnail, provider
  • We supports both javascript and typescript

Installing

Using npm:

$ npm install cooparser

Using yarn:

$ yarn add cooparser

How to use

note

We use axios for getting data from the site.

So you should use async/await for this library.

The example of javascript code is as follows:

import { cooparser } from 'cooparser';

const getDataAboutURL = async () => {
    const data = await cooparser.parse('https://google.com');
    // You can see the object here.
    console.log(data);
}

getDataAboutURL();

The example of typescript code is as follows:

import { cooparser, ParseResponse } from 'cooparser';

const getDataAboutURL = async () => {
    const data:ParseResponse = await cooparser.parse('https://google.com');
    // You can see the object here.
    console.log(data);
}

getDataAboutURL();

Interface

You can see ParseResponse at next chapter(Response Schema).

The methods we provide are:

interface Cooparser {
    parse: (url: string) => Promise<ParseResponse>;
    parseList: (urlList: string[]) => Promise<ParseResponse[]>;
}

Response Schema

The response is as follows:

// Parse Response
{
    title: string
    content: string
    link: string
    favicon: string
    thumbnail: string
    provider: string
}

Credits

The 'cooparser' could be completed with the help of @jhaemin. Thank you very much to Haemin.

Contributors

License

MIT