Skip to content

Instantly share code, notes, and snippets.

@augustt198
Created May 17, 2014 20:21
Show Gist options
  • Save augustt198/edd896e2007f1c44abce to your computer and use it in GitHub Desktop.
Save augustt198/edd896e2007f1c44abce to your computer and use it in GitHub Desktop.
Takes a screenshot of a webpage every time interval
# 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