我对这段代码有疑问:
require 'rubygems'
require 'rdf'
require 'rdf/raptor'
RDF::Reader.open("http://reegle.info/countries/IN.rdf") do |reader|
reader.each_statement do |statement|
puts statement.inspect
end
end
当试图打开上述 url 时,我被重定向到一个 URI.parse 显然不喜欢的 url:
http://sparql.reegle.info?query=CONSTRUCT+{+%3Chttp://reegle.info/countries/IN%3E+?p+?o.+%3Chttp://reegle.info/countries/IN.rdf%3E+foaf:primaryTopic+%3Chttp://reegle.info/countries/IN%3E;+cc:license+%3Chttp://www.nationalarchives.gov.uk/doc/open-government-licence%3E;+cc:attributionName+"REEEP";+cc:attributionURL+%3Chttp://reegle.info/countries/IN%3E.+}+WHERE+{+%3Chttp://reegle.info/countries/IN%3E+?p+?o.}&format=application/rdf%2Bxml
所以我收到以下错误:
URI::InvalidURIError: bad URI(is not URI?)
任何想法,如何解决这个问题?
谢谢
PS 执行类似 URI.parse(URI.encode([url]))) 的操作在这里没有任何效果。