puppeteer-infinite-scroller
Advanced tools
Comparing version
@@ -1,1 +0,1 @@ | ||
async function y(t,o){let{scrollDelay:n=1e3,itemCount:a=10,pageFunction:r,selector:e}=o;if(!e&&!r)throw new Error("Either selector or pageFunction must be provided as an option");if(e&&typeof e!="string")throw new Error("Selector must be a string");if(r&&typeof r!="function")throw new Error("PageFunction must be a function");if(typeof a!="number")throw new Error("ItemCount must be a number");if(typeof n!="number")throw new Error("ScrollDelay must be a number");try{return await l(t,[],a,e,r,n)}catch(i){return console.log("Error:",i.message),[]}}async function l(t,o,n,a,r,e){if(n<=o.length)return o.slice(0,n);let i=[];a?i=await t.evaluate(w=>{let f=document.querySelectorAll(w);return Array.from(f).map(u=>{let b=Array.from(u.attributes).reduce((s,c)=>(s[c.name]=u.getAttribute(c.name),s),{});return{tagName:u.tagName,...b}})},a):r&&(i=await t.evaluate(r)),o.push(...i);let m=await t.evaluate("document.body.scrollHeight");return await t.evaluate("window.scrollTo(0, document.body.scrollHeight)"),await t.waitForFunction(`document.body.scrollHeight > ${m}`),await t.waitForTimeout(e),l(t,o,n,a,r,e)}module.exports=y; | ||
"use strict";async function y(t,o){let{scrollDelay:n=1e3,itemCount:a=10,pageFunction:e,selector:r}=o;if(!r&&!e)throw new Error("Either selector or pageFunction must be provided as an option");if(r&&typeof r!="string")throw new Error("Selector must be a string");if(e&&typeof e!="function")throw new Error("PageFunction must be a function");if(typeof a!="number")throw new Error("ItemCount must be a number");if(typeof n!="number")throw new Error("ScrollDelay must be a number");try{return await l(t,[],a,r,e,n)}catch(i){return console.log("Error:",i.message),[]}}async function l(t,o,n,a,e,r){if(n<=o.length)return o.slice(0,n);let i=[];a?i=await t.evaluate(f=>{let w=document.querySelectorAll(f);return Array.from(w).map(u=>{let b=Array.from(u.attributes).reduce((s,c)=>(s[c.name]=u.getAttribute(c.name),s),{});return{tagName:u.tagName,...b}})},a):e&&(i=await t.evaluate(e)),o.push(...i);let m=await t.evaluate("document.body.scrollHeight");return await t.evaluate("window.scrollTo(0, document.body.scrollHeight)"),await t.waitForFunction(`document.body.scrollHeight > ${m}`),await t.waitForTimeout(r),l(t,o,n,a,e,r)}module.exports=y; |
{ | ||
"name": "puppeteer-infinite-scroller", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Provides a simple and efficient solution for scraping data loaded through infinite scrolling on web pages using Puppeteer.", | ||
"main": "lib/index.js", | ||
"typings": "lib/index.d.ts", | ||
"scripts": { | ||
"test": "jest", | ||
"build": "esbuild index.js --bundle --platform=node --target=node10.4 --outfile=out.js", | ||
"build": "node build/index.js", | ||
"example": "node examples/index.js", | ||
@@ -35,4 +36,10 @@ "release:major": "npm version $(semver $npm_package_version -i major) && npm publish --tag latest", | ||
"jest": "^29.6.2", | ||
"puppeteer": "^21.0.1" | ||
} | ||
"npm-dts": "^1.3.12", | ||
"puppeteer": "^21.0.1", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.2.2" | ||
}, | ||
"files": [ | ||
"lib/*" | ||
] | ||
} |
@@ -1,2 +0,2 @@ | ||
# Puppeteer-Infinite-Scroller | ||
# Puppeteer Infinite Scroller | ||
[](https://www.npmjs.com/package/puppeteer-infinite-scroller) | ||
@@ -3,0 +3,0 @@ [](https://github.com/DulanHewage/puppeteer-infinite-scroller/issues) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
20
150%0
-100%7446
-3.91%6
100%5
-16.67%