Sen descrición

Illia Antypenko b384a00f8e Fix builds on ubuntu latest (#120) hai 4 semanas
.github b384a00f8e Fix builds on ubuntu latest (#120) hai 4 semanas
lib bf37013041 Add gotoOptions param (#61) hai 1 ano
test ec7685159f Bump chai from 4.4.1 to 5.1.1 (#104) hai 5 meses
.codeclimate.yml 9fe0cb74c8 Extend CI config, remove package-lock.json, add codeclimate (#38) %!s(int64=3) %!d(string=hai) anos
.eslintrc.yml 0ae842b691 Update plugin for website-scraper v5 (#39) %!s(int64=3) %!d(string=hai) anos
.gitignore 9fe0cb74c8 Extend CI config, remove package-lock.json, add codeclimate (#38) %!s(int64=3) %!d(string=hai) anos
LICENSE ff56fa90c8 Fix author's name hai 1 ano
README.md fe5e835f6a Use new headless mode in one of the tests (#80) hai 1 ano
package.json d57be93527 Bump mocha from 10.8.2 to 11.0.1 (#118) hai 1 mes

README.md

Version Downloads Node.js CI Test Coverage

website-scraper-puppeteer

Plugin for website-scraper which returns html for dynamic websites using puppeteer.

This module is an Open Source Software maintained by one developer in free time. If you want to thank the author of this module you can use GitHub Sponsors or Patreon.

Requirements

  • nodejs version >= 18
  • website-scraper version >= 5

Installation

npm install website-scraper website-scraper-puppeteer

Usage

import scrape from 'website-scraper';
import PuppeteerPlugin from 'website-scraper-puppeteer';

await scrape({
    urls: ['https://www.instagram.com/gopro/'],
    directory: '/path/to/save',
    plugins: [ 
      new PuppeteerPlugin({
        launchOptions: { headless: "new" }, /* optional */
        gotoOptions: { waitUntil: "networkidle0" }, /* optional */
        scrollToBottom: { timeout: 10000, viewportN: 10 }, /* optional */
        blockNavigation: true, /* optional */
      })
    ]
});

Puppeteer plugin constructor accepts next params:

  • launchOptions - (optional) - puppeteer launch options, can be found in puppeteer docs
  • gotoOptions - (optional) - puppeteer page.goto options, can be found in puppeteer docs
  • scrollToBottom - (optional) - in some cases, the page needs to be scrolled down to render its assets (lazyloading). Because some pages can be really endless, the scrolldown process can be interrupted before reaching the bottom when one or both of the bellow limitations are reached:
    • timeout - in milliseconds
    • viewportN - viewport height multiplier
  • blockNavigation - (optional) - defines whether navigation away from the page is permitted or not. If it is set to true, then the page is locked to the current url and redirects with location.replace(anotherPage) will not pass. Defaults to false

How it works

It starts Chromium in headless mode which just opens page and waits until page is loaded. It is far from ideal because probably you need to wait until some resource is loaded or click some button or log in. Currently this module doesn't support such functionality.