`open_http':500内部服务器错误(OpenURI :: HTTPError)

时间:2016-03-11 10:44:42

标签: ruby json http parsing

我正在尝试解析网址,但仍然保持这500.请问有什么建议吗?

require 'open-uri'
require 'json'
require 'csv'

url = 'https://gist.githubusercontent.com/gregclermont/ca9e8abdff5dee9ba9db/raw/
7b2318efcf8a7048f720bcaff2031d5467a4a2c8/users.json'
encoded_url = URI.encode(url)

open(encoded_url) do |stream|
  quote = JSON.parse(stream.read)
  puts quote
end

1 个答案:

答案 0 :(得分:0)

require 'open-uri'
require 'json'

url = 'https://gist.githubusercontent.com/gregclermont/ca9e8abdff5dee9ba9db/raw/7b2318efcf8a7048f720bcaff2031d5467a4a2c8/users.json'

open(url) { |f| JSON.parse(f.read) }

对我来说很好。