Created
March 25, 2014 17:29
-
-
Save dmgarland/9766899 to your computer and use it in GitHub Desktop.
URL checker
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
require 'pry' | |
require 'httparty' | |
failed = [] | |
File.open('urls.csv', 'r').each_with_index do |line, number| | |
next if number == 0 | |
path = line.split(",").first | |
url = "http://localhost:9293#{path}" | |
puts url | |
begin | |
response = HTTParty.get(url) | |
failed << path if response.code != 200 # (or 301?) | |
rescue Exception => e | |
puts "Couldn't open #{url}: #{e.message}" | |
end | |
end | |
File.open('failed.csv', 'w') { |f| f.write failed.join(",") } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment