我成功安装了Ruby 1.9.1和Nokogiri,但是,当我尝试使用Nokogiri时,我收到以下错误:
uninitialized constant ::Nokogiri
Run Code Online (Sandbox Code Playgroud)
这似乎是因为无法找到Nokogiri宝石.这是我的代码:
File::open("test.html"){|file|
puts file.class => file
page = Nikogiri::HTML(file) => uninitialized constant ::Nokogiri
puts page.class
}
Run Code Online (Sandbox Code Playgroud)
但这有效:
page = Nokogiri::HTML(open("test.html"))
file = open("test.html") => file
page = Nokogiri::HTML(file)
puts page.class => document
Run Code Online (Sandbox Code Playgroud)
你能帮我找出什么问题吗?
代码有拼写错误:
page = Nikogiri::HTML(file) # => uninitialized constant ::Nokogiri
# ^
Run Code Online (Sandbox Code Playgroud)