Skip to content

Instantly share code, notes, and snippets.

@dmgarland
Created March 25, 2014 17:29
Show Gist options
  • Save dmgarland/9766899 to your computer and use it in GitHub Desktop.
Save dmgarland/9766899 to your computer and use it in GitHub Desktop.
URL checker
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