Windows 上带有 scrapyt 的 Ruby 1.9.2
在Windows上使用scrubyt和Ruby 1.9.2,在调用Scrubyt::Extractor.define do时出现以下错误
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:479:in load_missing_constant': Scrubyt::Navigation is not missing constant Mechanize! (ArgumentError)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:183:inblock in const_missing'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:181:in each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:181:inconst_missing'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/scrubyt-0.4.31/lib/scrubyt/core/navigation/agents/mechanize.rb:17:in block in included'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/scrubyt-0.4.31/lib/scrubyt/core/navigation/agents/mechanize.rb:16:inmodule_eval'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/scrubyt-0.4.31/lib/scrubyt/core/navigation/agents/mechanize.rb:16:in included'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/scrubyt-0.4.31/lib/scrubyt/core/shared/extractor.rb:29:ininclude'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/scrubyt-0.4.31/lib/scrubyt/core/shared/extractor.rb:29:in block in define'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/scrubyt-0.4.31/lib/scrubyt/core/shared/extractor.rb:28:inclass_eval'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/scrubyt-0.4.31/lib/scrubyt/core/shared/extractor.rb:28:in `define'
似乎与scruyt/中的@@agent = Mechanize::Mechanize.new
有关core/navigation/agents/mechanize.rb 表明 Mechanize 未加载,尽管在文件中指定了“require 'mechanize'”
我安装了 mechanize (2.0.1), hpricot (0.8.4)、fireawtir (1.9.3) 和 nokogiri (1.5.0)
关于这个问题的原因有什么想法吗?
Using scrubyt with Ruby 1.9.2 on Windows, and get the following error when calling Scrubyt::Extractor.define do
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:479:in load_missing_constant': Scrubyt::Navigation is not missing constant Mechanize! (ArgumentError)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:183:inblock in const_missing'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:181:in each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:181:inconst_missing'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/scrubyt-0.4.31/lib/scrubyt/core/navigation/agents/mechanize.rb:17:in block in included'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/scrubyt-0.4.31/lib/scrubyt/core/navigation/agents/mechanize.rb:16:inmodule_eval'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/scrubyt-0.4.31/lib/scrubyt/core/navigation/agents/mechanize.rb:16:in included'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/scrubyt-0.4.31/lib/scrubyt/core/shared/extractor.rb:29:ininclude'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/scrubyt-0.4.31/lib/scrubyt/core/shared/extractor.rb:29:in block in define'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/scrubyt-0.4.31/lib/scrubyt/core/shared/extractor.rb:28:inclass_eval'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/scrubyt-0.4.31/lib/scrubyt/core/shared/extractor.rb:28:in `define'
It seems to be related to @@agent = Mechanize::Mechanize.new
in scrubyt/core/navigation/agents/mechanize.rb that Mechanize is not loaded despite that in the file "require 'mechanize'" is specified
I installed mechanize (2.0.1), hpricot (0.8.4), fireawtir (1.9.3) and nokogiri (1.5.0)
Any ideas about why the issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
现在通过使用 mechanize (0.9.3) 解决,并将 scrapyt-0.4.31\lib\scrubyt\core\navigation\agents\mechanize.rb、@@agent = Mechanize::Mechanize.new 更改为 @@agent = WWW::机械化。新。可能只是我自己的问题,但在这里发布解决方案以防其他人可以使用它......
Solved now by using mechanize (0.9.3) and changed scrubyt-0.4.31\lib\scrubyt\core\navigation\agents\mechanize.rb, @@agent = Mechanize::Mechanize.new to @@agent = WWW::Mechanize.new. Might just be a problem at my own, but post the solution here in case anyone else can use it...