我正在尝试读取某个网站的 html。
尝试 @something = open("http://www.google.com/")
失败并出现以下错误:
Errno::ENOENT in testController#show
No such file or directory - http://www.google.com/
转到 http://www.google.com/
,我显然看到了该网站。我做错了什么?
谢谢!
最佳答案
您需要先require 'open-uri'
才能open()
远程路径。
见 the docs了解更多信息。
关于ruby-on-rails - 如何在 Rails 中打开 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2954596/