简体   繁体   中英

How to run ScrAPI with Ruby?

I'm trying to run scrapi with rails with this code:

require 'rubygems'
require 'scrapi'
require 'tidy'

scraper = Scraper.define do
    process "title", :page_name => :text
    result :page_name
end

uri = URI.parse("http://railscasts.com/episodes/173-screen-scraping-with-scrapi")
p scraper.scrape(uri)

but I get the following error:

DL is deprecated, please use Fiddle
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/tidy-1.1.2/lib/tidy/tidybuf.rb:5:in `<class:Tidybuf>': uninitialized constant DL::Importable (NameError)
        from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/tidy-1.1.2/lib/tidy/tidybuf.rb:3:in `<top (required)>'
        from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/tidy-1.1.2/lib/tidy.rb:25:in `<module:Tidy>'
        from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/tidy-1.1.2/lib/tidy.rb:21:in `<top (required)>'
        from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `require'
        from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
        from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:144:in `require'
        from scrapitest.rb:3:in `<main>'

has anybody got an idea why is that and what could I do to fix it?

Thank you.

Try http://github.com/libc/tidy_ffi instead. It seems tidy gem is not mantained anymore.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM