1.0.4 • Published 4 years ago

modelscrape v1.0.4

Weekly downloads
13
License
MIT
Repository
github
Last release
4 years ago

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);
    });