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