Mechanize

About Mechanize ruby gem

Solving /var/lib/gems/1.8/gems/mechanize-0.9.3/lib/www/mechanize/util.rb:40:in ‘iconv’: can't convert nil into String (TypeError)

I've seen on some Japanese web pages the solution to this error. It seems something related with the underlying Nokogiri parsing lib. The solution, which works for me, is to configure Mechanize to use Hpricot as the html parser instead of Nokogiri.

require 'rubygems'
require 'mechanize'
require 'hpricot'
 
WWW::Mechanize.html_parser = Hpricot
agent = WWW::Mechanize.new
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License