views:

36

answers:

1

What I've done so far..

sudo gem install scrapi

sudo gem install tidy

This didn't work because it didn't have the libtidy.dylib

So I did this :

sudo port install tidy

sudo cp libtidy.dylib /Library/Ruby/Gems/1.8/gems/scrapi-1.2.0/lib/tidy/libtidy.dylib

Then I started following the simple railscast at : http://media.railscasts.com/videos/173_screen_scraping_with_scrapi.mov

Right after Mr. Bates finished the first save for scrapitest.rb , I tried to run this code :

require 'rubygems'
require 'scrapi'

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

uri = URI.parse("http://www.walmart.com/search/search-ng.do?search_query=lost+season+3&ic=48_0&search_constraint=0")
p scraper.scrape(uri)

With this code :

ruby scrapitest.rb

And it returned this error :

/Library/Ruby/Gems/1.8/gems/tidy-1.1.2/lib/tidy/tidybuf.rb:39: [BUG] Segmentation fault
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]

Abort trap

Completely out of ideas..

+1  A: 

If you're getting the error: /opt/ruby/ruby-1.8.6/lib/ruby/gems/1.8/gems/tidy-1.1.2/lib/tidy/tidybuf.rb:40: [BUG] Segmentation fault

It's because the data types don't match up in the latest Tidy (0.99) (/usr/include/buffio.h - $Date: 2007/01/23 11:17:45 $ )

The resolution is to patch tidybuf.rb:

--- tidybuf.rb  2007-04-10 09:09:01.000000000 -0500
+++ tidybuf.rb.patched  2007-04-10 09:08:55.000000000 -0500
@@ -11,6 +11,7 @@
   # Mimic TidyBuffer.
   #
   TidyBuffer = struct [
+    "int* allocator",
     "byte* bp",
     "uint size",
     "uint allocated",    
Trip