Skip to content

Instantly share code, notes, and snippets.

@usure
Created July 3, 2012 18:00
Show Gist options
  • Save usure/3041409 to your computer and use it in GitHub Desktop.
Save usure/3041409 to your computer and use it in GitHub Desktop.
random imgur
require 'net/http'
require 'uri'
def isLive?(url)
uri = URI.parse(url)
response = nil
Net::HTTP.start(uri.host, uri.port) { |http|
response = http.head(uri.path.size > 0 ? uri.path : "/")
}
return response.code == "200"
end
for i in 0..9
link = isLive?("http://imgur.com/AMCU#{i}")
if link == true
puts "http://imgur.com/AMCU#{i}.jpg"
end
end
for i in 0..9
link = isLive?("http://imgur.com/BMCU#{i}")
if link == true
puts "http://imgur.com/BMCU#{i}.jpg"
end
end
for i in 0..9
link = isLive?("http://imgur.com/CMCU#{i}")
if link == true
puts "http://imgur.com/CMCU#{i}.jpg"
end
end
for i in 0..9
link = isLive?("http://imgur.com/DMCU#{i}")
if link == true
puts "http://imgur.com/DMCU#{i}.jpg"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment