0

我正在尝试从肌腱源代码运行示例,但它无法在我的机器上运行。这是示例(直接取自他们的 github):

get "http://www.amazon.com/gp/bestsellers/books/ref=sv_b_3"
noko.css(".zg_itemRow").each do |item|
  row = { }
  row[:url] = item.css(".zg_title a").first[:href]
  row[:title] = item.css(".zg_title")
  row[:img] = item.css(".zg_itemImage_normal img").first[:src]
  csv_emit(row)
end

我正在使用带有 ruby​​ 1.9.3 和 rvm 的 ubuntu 12.04。这是我输入的内容,然后是错误。

jefferton@ubuntu:~/IdeaProjects/sinew_scrape$ sinew sell_list.sinew
curl http://www.amazon.com/gp/bestsellers/books/ref=sv_b_3
/home/jefferton/.rvm/gems/ruby-1.9.3-head/gems/sinew-1.0.2/lib/sinew/text_util.rb:48:in `popen': No such file or directory - tidy -asxml  -bare  -quiet  -utf8  -wrap 0 --doctype omit --hide-comments yes --force-output yes -f /dev/null (Errno::ENOENT)
from /home/jefferton/.rvm/gems/ruby-1.9.3-head/gems/sinew-1.0.2/lib/sinew/text_util.rb:48:in `html_tidy'
from /home/jefferton/.rvm/gems/ruby-1.9.3-head/gems/sinew-1.0.2/lib/sinew/main.rb:33:in `html'
from /home/jefferton/.rvm/gems/ruby-1.9.3-head/gems/sinew-1.0.2/lib/sinew/main.rb:59:in `noko'
from sell_list.sinew:9:in `_run'
from /home/jefferton/.rvm/gems/ruby-1.9.3-head/gems/sinew-1.0.2/lib/sinew/main.rb:121:in `instance_eval'
from /home/jefferton/.rvm/gems/ruby-1.9.3-head/gems/sinew-1.0.2/lib/sinew/main.rb:121:in `_run'
from /home/jefferton/.rvm/gems/ruby-1.9.3-head/gems/sinew-1.0.2/lib/sinew/main.rb:16:in `initialize'
from /home/jefferton/.rvm/gems/ruby-1.9.3-head/gems/sinew-1.0.2/bin/sinew:19:in `new'
from /home/jefferton/.rvm/gems/ruby-1.9.3-head/gems/sinew-1.0.2/bin/sinew:19:in `block in <top (required)>'
from /home/jefferton/.rvm/gems/ruby-1.9.3-head/gems/sinew-1.0.2/bin/sinew:18:in `each'
from /home/jefferton/.rvm/gems/ruby-1.9.3-head/gems/sinew-1.0.2/bin/sinew:18:in `<top (required)>'
from /home/jefferton/.rvm/gems/ruby-1.9.3-head/bin/sinew:19:in `load'
from /home/jefferton/.rvm/gems/ruby-1.9.3-head/bin/sinew:19:in `<main>'
from /home/jefferton/.rvm/gems/ruby-1.9.3-head/bin/ruby_noexec_wrapper:14:in `eval'
from /home/jefferton/.rvm/gems/ruby-1.9.3-head/bin/ruby_noexec_wrapper:14:in `<main>'

我希望我知道要问的更具体的问题,但我不确定在这里做什么。

谢谢。

4

2 回答 2

1

您必须先安装 Html-Tidy 和 Curl,请参阅https://github.com/gurgeous/sinew/wiki 您在这里得到的错误是因为未找到 Html-Tidy。将其安装到没有空格(不是程序文件)的文件夹中,并将路径添加到您的系统或用户 PATH 变量。对卷曲做同样的事情。从命令行而不是在它们自己的地图中测试这两个应用程序,看看它们是否工作。

于 2012-06-17T23:30:39.663 回答
1

That library might be worth looking into but I can't imagine why they would use curl over mechanize or what html tidy is supposed to be for. And shelling out to executables like that is just a bad approach. My opinion is to avoid it and use mechanize instead.

于 2012-06-18T01:37:54.717 回答