Browse Source

added support of lazy loaded images

Gildas 7 năm trước cách đây
mục cha
commit
e61caa45d9
1 tập tin đã thay đổi với 3 bổ sung0 xóa
  1. 3 0
      node-puppeteer/single-file-puppeteer.js

+ 3 - 0
node-puppeteer/single-file-puppeteer.js

@@ -66,6 +66,9 @@ exports.getPageData = async options => {
 			await page.setUserAgent(options.userAgent);
 		}
 		await page.setBypassCSP(true);
+		if (options.loadDeferredImages) {
+			SCRIPTS.unshift("../lib/lazy/web/web-lazy-loader-before");
+		}
 		await Promise.all(SCRIPTS.map(scriptPath => page.evaluateOnNewDocument(fs.readFileSync(require.resolve(scriptPath)).toString())));
 		await page.goto(options.url, {
 			waitUntil: options.puppeteerWaitUntil || "networkidle0"