How to scroll a page using phantomJs

I want to make a page loading its images only when the user scrolls the page. Just setting page.scrollPosition not affected. I need something that will change the scroll position over time.

+4
source share
1 answer

Not sure if this is the best way, but it works. It evaluates the script on the page, which increases document.body.scrollTop over time and takes a screenshot after a fixed time.

 page.open "http://www.somePage.com", (status) -> setTimeout(( -> page.evaluate(-> pos = 0 scroll = -> pos += 250 window.document.body.scrollTop = pos setTimeout(scroll, 100) scroll() ) setTimeout((-> page.render('bild.png') phantom.exit() ), 5000) ), 1000) 
+7
source

Source: https://habr.com/ru/post/1479736/


All Articles