On Wed, Oct 22, 2008 at 8:18 AM, Aaron P.
<[email protected]
wrote:
You can submit it via the mechanize rubyforge tracker here:
http://rubyforge.org/tracker/?group_id=1453
Ok. Did that.
-s no longer works with gem. Sould be --source
I realize that is kind of a pain in the butt, so I’ve posted a
development version of the gem on my internet homesite. Just download
the gem from here:
http://tenderlovemaking.com/nokogiri-0.0.0.20081021110113.gem
gem install nokogiri-0.0.0.20081021110113.gem
produced:
No definition for owned_eh
(twice)
Unfortunately, it doesn’t work at all. And even more unfortunately, it’s
not
easy for me to debug, because while ‘pp page.parser’ in the Hpricot case
gives a detailed result from the parsing process, it just gives:
#<Nokogiri::HTML::Document:0x7f06c01d3260
@decorators={“node”=>[], “nodeset”=>[]}>
in the nokogiri version.
I have distilled a small example, without too many dependencies:
#!/usr/bin/ruby -w
require ‘rubygems’
if ENV[‘NOKOGIRI’]
require ‘nokogiri’
end
require ‘mechanize’
if ENV[‘NOKOGIRI’]
WWW::Mechanize.html_parser = Nokogiri::HTML
end
class ImdbScraper
def initialize
@agent = WWW::Mechanize.new { |agent|
agent.user_agent_alias = ‘Linux Mozilla’
}
@baseurl = ‘http://www.imdb.com’
page = @agent.get(@baseurl)
@search = page.form(‘find’)
end
def search(lookfor, year = nil)
@search.q = lookfor
page = @agent.submit(@search)
end
end
s = ImdbScraper.new
page = s.search(‘The Catered Affair’, ‘1956’)
puts page.at(‘//div.info’)
end-of-program
Run with and without the NOKOGIRI environment variable set, and see the
difference.
Maybe I’m missing something else that is silently ignored ?
Cheers,
Han H.