autogram
Advanced tools
Comparing version 0.0.6 to 0.0.7
23
index.js
@@ -74,8 +74,19 @@ const os = require('os'); | ||
const scrollDown = async (page) => { | ||
const scrollDown = async (page, timeout = 3000) => { | ||
console.log('Scrolling down the page...'); | ||
await page.evaluate(() => { | ||
window.scrollBy(0, window.innerHeight + 1000); | ||
}); | ||
await wait(10000); | ||
await page.evaluate(async (timeout) => { | ||
await new Promise((resolve) => { | ||
let totalHeight = 0; | ||
const distance = 100; | ||
const timer = setInterval(() => { | ||
window.scrollBy(0, distance); | ||
totalHeight += distance; | ||
}, 200); | ||
setTimeout(() => { | ||
if (timer) clearInterval(timer); | ||
resolve(); | ||
}, timeout); | ||
}); | ||
}, timeout); | ||
await wait(2000); | ||
}; | ||
@@ -128,5 +139,5 @@ | ||
const followSectionUsers = async (page, section) => { | ||
await scrollDown(page); | ||
state.imageIndex[state.currentTag] = state.imageIndex[state.currentTag] || 0; | ||
const images = (await page.$$(section)).slice(state.imageIndex[state.currentTag]); | ||
await scrollDown(page); | ||
console.log({ currentTag: state.currentTag, imageIndex: state.imageIndex[state.currentTag], images: images.length, allImages: (await page.$$(section)).length }) | ||
@@ -133,0 +144,0 @@ if (images.length === 0) return; |
{ | ||
"name": "autogram", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
17886
391