Created
May 17, 2014 20:21
-
-
Save augustt198/edd896e2007f1c44abce to your computer and use it in GitHub Desktop.
Takes a screenshot of a webpage every time interval
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requires the command 'pageres' - https://github.com/sindresorhus/pageres | |
args = ARGV | |
if args.length < 1 | |
raise Exception.new 'Must have at least one argument: "website [interval in seconds] [resolution in format 100x100]' | |
end | |
url = args[0] | |
interval = args[1] ? args[1].to_i : 60 | |
resolution = args[2] ? args[2] : '1920x1080' | |
puts "taking pictures of #{url} at an interval of #{interval} seconds with the resolution #{resolution}" | |
dir = "#{url}_screenshots" | |
`mkdir #{dir}` | |
count = 1 | |
while true | |
`cd #{dir}; pageres #{url} #{resolution}` | |
file = "#{url}-#{resolution}" | |
`cd #{dir}; mv #{file}.png #{file}-#{count}.png` | |
count += 1 | |
sleep interval | |
if count % 5 == 0 | |
puts "taken #{count} screenshots" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment