Is there an easy way to check the status code of another website (e.g. http://google.com) in Ruby on Rails?
Ideally, the list of URLs to check would be pulled from a DB and processed via CRON (or equivalent).
require 'net/http'
http = Net::HTTP.new('www.google.com',80)
response = http.request_get('/')
p response.status
Slightly more efficient (traffic wise) might be:
response = http.request_head('/')
p response.status
Source: http://ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTP.html#M001403
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With