このコードに問題があります:
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])))のようなことをしても、ここでは何の効果もありません。