Created
July 3, 2012 15:48
-
-
Save akwiatkowski/3040596 to your computer and use it in GitHub Desktop.
Storm timelapse
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
url = "http://blitzortung.net/Images/image_b_pl.png" | |
ref = "http://blitzortung.net" | |
agent = "Internet Explorer 8.0" | |
interval = 10*60 | |
sleep_interval = 20 | |
next_download_t = Time.now.to_i | |
Dir.mkdir('data') unless File.exists?('data') | |
loop do | |
# proper interval | |
next_download_t = Time.now.to_i + interval | |
# sleep to maintain proper interval | |
sleep_time = next_download_t - Time.now.to_i | |
while sleep_time > 0 | |
puts "sleeping #{sleep_time}" | |
sleep_time -= sleep_interval | |
sleep(sleep_interval) | |
end | |
puts "sleep end" | |
t = Time.now.to_i | |
dest = "data/storm_#{t}.png" | |
command = "wget --dns-timeout=5 --connect-timeout=5 --read-timeout=5 --quiet --referer=\"#{ref}\" --user-agent=\"#{agent}\" --load-cookies data/cookies.txt --keep-session-cookies --save-cookies data/cookies.txt \"#{url}\" -O#{dest}" | |
puts "downloading #{t}" | |
`#{command}` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment