puppeteer-autoscroll-down
Advanced tools
Comparing version 0.1.5 to 0.1.6
{ | ||
"name": "puppeteer-autoscroll-down", | ||
"version": "0.1.5", | ||
"description": "Small tool for puppeteer which scrolling page to bottom based on Body element.", | ||
"version": "0.1.6", | ||
"description": "Handle infinite scroll on websites by puppeteer", | ||
"main": "index.js", | ||
@@ -15,10 +15,11 @@ "scripts": { | ||
"devDependencies": { | ||
"eslint": "^6.8.0", | ||
"@types/puppeteer": "^2.0.1", | ||
"eslint": "^7.0.0", | ||
"eslint-config-airbnb": "^18.1.0", | ||
"eslint-config-prettier": "^6.10.1", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-import": "^2.20.2", | ||
"eslint-plugin-jest": "^23.8.2", | ||
"eslint-plugin-jest": "^23.10.0", | ||
"husky": "^4.2.5", | ||
"lint-staged": "^10.1.6", | ||
"prettier": "^2.0.4" | ||
"lint-staged": "^10.2.2", | ||
"prettier": "^2.0.5" | ||
}, | ||
@@ -40,4 +41,4 @@ "husky": { | ||
"scroll", | ||
"dom", | ||
"node.js" | ||
"infinite", | ||
"dom" | ||
], | ||
@@ -44,0 +45,0 @@ "homepage": "https://github.com/mbalabash/puppeteer-autoscroll-down/blob/master/README.md", |
@@ -1,42 +0,24 @@ | ||
## Small tool for puppeteer which scrolling page to bottom based on Body element | ||
## Handle infinite scroll on websites by puppeteer | ||
**This package using `window.scrollBy` method for scrolling.** | ||
**We use [`window.scrollBy`](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollBy) method for scrolling pages.** | ||
**See https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollBy** | ||
### Usage | ||
### Install: | ||
```js | ||
npm i puppeteer-autoscroll-down | ||
``` | ||
or | ||
```js | ||
yarn add puppeteer-autoscroll-down | ||
``` | ||
### Example: | ||
```js | ||
const browser = await puppeteer.launch({ headless: false }) | ||
const browser = await puppeteer.launch() | ||
const page = await browser.newPage() | ||
await page.setViewport({ width: 1366, height: 768 }) | ||
await page.goto(SOME_URL) | ||
await page.goto('https://en.wikipedia.org/wiki/Main_Page') | ||
const lastPosition = await scrollPageToBottom(page) | ||
await page.screenshot({ path: path.normalize(`${__dirname}/example.png`) }) | ||
console.log(`lastPosition: ${lastPosition}`) | ||
await browser.close() | ||
``` | ||
**You can use returned last scroll position and request/response hooks to handle async content uploading.** | ||
**You can use returned value with request/response hooks to handle async content uploading.** | ||
### Scrolling options | ||
**`scrollStep {Number}` - Number of pixels to scroll on each step.** | ||
**`scrollStep` - Number of pixels to scroll on each step.** | ||
**`scrollDelay {Number}` - A delay between each scroll step in ms.** | ||
**`scrollDelay` - A delay between each scroll step in ms.** | ||
@@ -48,1 +30,17 @@ ```js | ||
``` | ||
### Install | ||
```js | ||
npm i puppeteer-autoscroll-down | ||
``` | ||
or | ||
```js | ||
yarn add puppeteer-autoscroll-down | ||
``` | ||
### Contributing | ||
Feel free to ask or open an issue. |
Sorry, the diff of this file is not supported yet
11
79
6559
9
46