This code checks if the given link exists and returns an HTTP Code 200.
def self.link_ok? link url = URI.parse( link ) req = Net::HTTP.new(url.host, url.port) req.use_ssl = true req.verify_mode = OpenSSL::SSL::VERIFY_NONE res = req.request_head(url.path) res.code.to_i == 200 rescue => e p "ERROR #{e.message}" return false end