getting the status code of a HTTP redirected page
问题 I'm using curb to test some URLs in Ruby: require 'curb' def test_url() c = Curl::Easy.new("http://www.wikipedia.org/wiki/URL_redirection") do |curl| curl.follow_location= true curl.head = true end c.perform puts "status => " + c.status puts "body => " + c.body_str puts "final url => " + c.last_effective_url end test_url This outputs: status => 301 Moved Permanently body => final url => http://en.wikipedia.org/wiki/URL_redirection In this case, www.wikipedia.org/wiki/URL_redirection redirects