modelscrape

1.0.4 • Public • Published

modelscrape

Cheerio-based scraping helper to scrape websites based on models/templates.

Features

  • Template based scraping.
  • Multiple entity definition in a single template.

Installing

Using npm:

$ npm install modelscrape

or from github:

$ npm install mariomenjr/modelscrape

Example

Basic usage:

const modelscrape = require("modelscrape");

// Using pre-loaded template
modelscrape()
    .then((collection) => {
        console.log(collection);
    })
    .catch((error) => {
        console.error(error);
    });

// Using custom template
modelscrape({
    url: "https://google.com",
    queryObjects: [
        {
            name: "PupusasSearch",
            endpoint: "search?q=pupusas",
            collections: [
                {
                    name: "Search",
                    query: ".ZINbbc > .kCrYT",
                    props: [
                        {
                            name: "title",
                            query: "a > div.vvjwJb",
                        },
                        {
                            name: "url",
                            query: "a > div.UPmit",
                        },
                    ],
                },
            ],
        },
    ],
})
    .then((collection) => {
        return console.log(collection);
    })
    .catch((error) => {
        return console.error(error);
    });

Package Sidebar

Install

npm i modelscrape

Weekly Downloads

2

Version

1.0.4

License

MIT

Unpacked Size

18.5 kB

Total Files

26

Last publish

Collaborators

  • mariomenjr