저는 Ruby를 처음 접했습니다. 나는 온라인 문서를 조사해 보았으나 꽤 잘 작동하는 것은 발견하지 못했다. 다음 HTTP 요청, bot get_response() 및 get()에 User-Agent를 포함하고 싶습니다. 누군가 올바른 방향으로 나를 가리킬 수 있습니까?HTTP 요청의 사용자 에이전트, Ruby
# 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