You can use the Net :: HTTP built-in library to do most of this for you:
require 'net/http' Net::HTTP.start('stackoverflow.com') do |http| response = http.request_head('/robots.txt') response['Last-Modified']
If you want, you can convert it to the desired date using Time.parse .
source share