open_uri failure on good uri.

I am trying to open a URI using doc = Nokogiri::HTML(open(url)). I get the following error:

URI::InvalidURIError: bad URI(is not URI?):|1|\*&item=1         from /usr/local/ruby/lib/ruby/1.8/uri/common.rb:436:in `split'         from /usr/local/ruby/lib/ruby/1.8/uri/common.rb:485:in `parse'         from /usr/local/ruby/lib/ruby/1.8/open-uri.rb:29:in `open'

The problem is, if I paste the url in a browser it does go to the proper page. What am I missing

Try replacing the | characters with %7C

Or try:

doc = Nokogiri::HTML(open(URI.encode(url)))


Rob Biedenharn

That worked perfectly. Thanks