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/imgur/spiders/infinite_scroll.lua
Claudio Maggioni (maggicl) 68f7091ecb Done scraper
2020-11-04 15:36:32 +01:00

18 lines
457 B
Lua

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