website-scraper-puppeteer
v2.0.0
Published
Plugin for website-scraper which returns html for dynamic websites using puppeteer
Maintainers
Readme
website-scraper-puppeteer
Plugin for website-scraper which returns html for dynamic websites using puppeteer.
Sponsors
Maintenance of this project is made possible by all the contributors and sponsors. If you'd like to sponsor this project and have your avatar or company logo appear below click here. 💖
Requirements
- nodejs version >= 20
- website-scraper version >= 5
Installation
npm install website-scraper website-scraper-puppeteerUsage
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 */
})
]
});Puppeteer plugin constructor accepts next params:
launchOptions- (optional) - puppeteer launch options, can be found in puppeteer docsgotoOptions- (optional) - puppeteer page.goto options, can be found in puppeteer docsscrollToBottom- (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 millisecondsviewportN- viewport height multiplier
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.
