This repository has been archived on 2020-12-10. You can view files and clone it, but cannot push or open issues or pull requests.
IRProject/photo_scraper/spiders/infinite_scroll.lua

19 lines
457 B
Lua
Raw Permalink Normal View History

2020-11-04 14:36:32 +00:00
function main(splash)
local num_scrolls = 20
local scroll_delay = 0.8
local scroll_to = splash:jsfunc("window.scrollTo")
local get_body_height = splash:jsfunc(
"function() {return document.body.scrollHeight;}"
)
assert(splash:go(splash.args.url))
splash:wait(splash.args.wait)
for _ = 1, num_scrolls do
scroll_to(0, get_body_height())
splash:wait(scroll_delay)
end
return splash:html()
end