मैं रूबी के लिए काफी नया हूं। मैंने ऑनलाइन दस्तावेज को देखने की कोशिश की है, लेकिन मुझे कुछ भी नहीं मिला है जो काफी काम करता है। मैं निम्नलिखित HTTP अनुरोधों में उपयोगकर्ता-एजेंट शामिल करना चाहता हूं, bot get_response() और प्राप्त करें()। क्या कोई मुझे सही दिशा दिखा सकता है?HTTP अनुरोधों में उपयोगकर्ता-एजेंट, रूबी
# Preliminary check that Proggit is up
check = Net::HTTP.get_response(URI.parse(proggit_url))
if check.code != "200"
puts "Error contacting Proggit"
return
end
# Attempt to get the json
response = Net::HTTP.get(URI.parse(proggit_url))
if response.nil?
puts "Bad response when fetching Proggit json"
return
end
मुझे लगता है कि यह आपकी समस्या का समाधान है: http://www.dzone.com/snippets/send-custom-headers-ruby या http://stackoverflow.com/questions/587559/ruby-how-to-make -an-http-get-with-modified-headers – nhahtdh