0.10.0 • Published 5 years ago

@web-master/node-web-scraper v0.10.0

Weekly downloads
22
License
MIT
Repository
github
Last release
5 years ago

Description

It scrapes the specific page :)

Installation

$ npm install --save @web-master/node-web-scraper

Usage

Basic

import scrape from '@web-master/node-web-scraper';

const data = await scrape({
  target: 'http://example.com',
  fetch: {
    title: 'h1',
    info: {
      selector: 'p > a',
      attr: 'href',
    },
  },
});

console.log(data);

// {
//   title: 'Example Domain',
//   info: 'http://www.iana.org/domains/example'
// }

Waitable (by using puppeteer)

import scrape from '@web-master/node-web-scraper';

const data = await scrape({
  target: 'https://news.ycombinator.com/item?id=20821022',
  waitFor: 3 * 1000, // wait for the content loaded! (like single page apps)
  fetch: {
    title: '.title > a',
  },
});

console.log(data);

// {
//   title: 'How we reduced deployment times by 95%'
// }

TypeScript Support

import scrape from '@web-master/node-web-scraper';

interface WikiSite {
  url: string;
}

interface Wikipedia {
  sites: WikiSite[];
}

const wiki: Wikipedia = await scrape({
  target: 'https://www.wikipedia.org',
  fetch: {
    sites: {
      listItem: '.central-featured a.link-box',
      data: {
        url: {
          attr: 'href',
          convert: (x: string) => `https:${x}`,
        },
      },
    },
  },
});

console.log(wiki.sites);

// [
//   { url: 'https://en.wikipedia.org/' },
//   { url: 'https://ja.wikipedia.org/' },
//   ...
//   ...
//   { url: 'https://de.wikipedia.org/' }
// ]

Related

0.10.0

5 years ago

0.9.0

5 years ago

0.8.0

5 years ago

0.7.1

5 years ago

0.7.0

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago