要求“open-url”执行Nokogiri测试器时加载错误 [英] Require "open-url" load error when executing Nokogiri tester
本文介绍了要求“open-url”执行Nokogiri测试器时加载错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图按照RailsCast来使用Nokogiri。
I am trying to follow the RailsCast to use Nokogiri.
测试脚本文件中只有几行非常基本的代码:
Just a few very basic lines in my testing script file:
require 'rubygems'
require 'nokogiri'
require 'open-url'
url = "http://www.walmart.com/search/search-ng.do?search_constraint=0&ic=48_0&search_query=Batman&Find.x=0&Find.y=0&Find=Find"
doc = Nokogiri::HTML(open(url))
puts doc.at_css("title").text
但是当我执行它的时候,错误:
But when I execute it, I run into an error:
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- open-url (LoadError)
from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from nokogiri.test.rb:3:in `<main>'
我按照以下指示安装了开放网址gem: https://github.com/openurl/openurl
如何解决错误信息?
I did install open url gem following this instruction:https://github.com/openurl/openurl How do I fix the error message?
推荐答案
只是一个错字。使用 open-uri
(不是 open-url
)。
Just a typo. Use open-uri
(not open-url
).
这篇关于要求“open-url”执行Nokogiri测试器时加载错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文