0

我想从网站获得这些数据,但(export.benzinpreis-aktuell.de/exportdata.txt?code=e0bDB27ekW83a95)我不知道该怎么做。

System.open_url(export.benzinpreis-aktuell.de/exportdata.txt?code=e0bDB27ekW83a95)

我可以打开页面,但是当我想读取数据时它不起作用。

我也试过这个,

      require 'uri'
      require 'net/http'

  def read
    r = Net::HTTP.get_reponse( URI.parse('http://export.benzinpreis-aktuell.de/exportdata.txt?code=e0bDB27ekW83a95') ) 
   redirect :action => :index 
  end

但我收到错误消息

require_compiled: error: can not find net/http
App error: no such file to load -- net/http

我该如何纠正这个问题?

4

2 回答 2

1

You should put net-http and uri in your build.yml file (in extensions section), because these libraries are not included/compiled by default in a rhodes build:

extensions: 
- net-http
- uri
于 2013-05-29T14:17:27.707 回答
0

这应该做你需要的:

require 'open-uri'

file = open('http://your.url.goes.here.com/page/whatever')
result = file.read
puts result
于 2013-05-29T15:27:54.113 回答