Scrubyt 不适用于 Windows
我运行的是Windows XP。我刚刚安装了最新版本的 Ruby(1.9) - Hpricot、Mechanize 和 Scrubyt 安装没有任何问题。我尝试使用我能找到的最简单的例子来让 scrapyt 工作。示例:
require 'rubygems'
require 'scrubyt'
data = Scrubyt::Extractor.define do
fetch 'http://google.com'
title '//head/title'
end
data.to_xml.write($stdout, 1)
但是,我不断收到错误:
C:/ruby/lib/ruby/gems/1.9.1/gems/scrubyt-0.4.06/lib/scrubyt.rb:1: warning: varia
ble $KCODE is no longer effective; ignored
C:/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no
such file to load -- jcode (LoadError)
from C:/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `
require'
from C:/ruby/lib/ruby/gems/1.9.1/gems/scrubyt-0.4.06/lib/scrubyt.rb:2:in
`<top (required)>'
from C:/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:53:in `
require'
from C:/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:53:in `
rescue in require'
from C:/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `
require' from te.rb:2:in `<main>'
我尝试了几个入门示例,都给出了相同的错误消息。我今天刚开始使用 ruby,所以我无法真正弄清楚发生了什么。
谢谢!
I am running Windows XP. I just installed the latest version of Ruby(1.9) - Hpricot, Mechanize and Scrubyt installed without any issues. I have tried to work with the simplest examples I could find to get scrubyt working. example :
require 'rubygems'
require 'scrubyt'
data = Scrubyt::Extractor.define do
fetch 'http://google.com'
title '//head/title'
end
data.to_xml.write($stdout, 1)
but, I keep getting the error :
C:/ruby/lib/ruby/gems/1.9.1/gems/scrubyt-0.4.06/lib/scrubyt.rb:1: warning: varia
ble $KCODE is no longer effective; ignored
C:/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no
such file to load -- jcode (LoadError)
from C:/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `
require'
from C:/ruby/lib/ruby/gems/1.9.1/gems/scrubyt-0.4.06/lib/scrubyt.rb:2:in
`<top (required)>'
from C:/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:53:in `
require'
from C:/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:53:in `
rescue in require'
from C:/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `
require' from te.rb:2:in `<main>'
I have tried several starter examples, all give the same error message. I just started with ruby today, so I can't really figure out what's going on.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来
scrubyt
还没有为 ruby 1.9 做好准备,因为jcode
在 1.8 中使用到 处理编码问题。从 1.9 开始,ruby 具有更好的编码支持(尤其是 utf-8),因此不再需要jcode
。使用 1.9.2:
使用 1.8.7:
我尝试按如下方式更改 Scrubyt 文件来解决该问题:
并遇到了更多问题...因此需要做更多工作才能让 Scrubyt 与 ruby 1.9 一起运行。
FWIW,您的用例很可能更复杂,但您的示例可以使用 Mechanize (Scrubyt 内部使用)来完成:
It seems
scrubyt
is not ruby 1.9-ready, asjcode
was used in 1.8 to deal with encoding issues. As of 1.9, ruby has a better encoding support (esp. utf-8) and therefore doesn’t needjcode
anymore.With 1.9.2:
With 1.8.7:
I tried to change the Scrubyt files as follows to work around that issue:
and got further problems... So more work would need to be done to get Scrubyt to run with ruby 1.9.
FWIW, your use case is more than likely more complicated, but your example can be done with Mechanize (which Scrubyt uses internally):