Forum: Ruby on Rails open_uri failure on good uri.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Don F. (Guest)
on 2009-01-28 03:36
(Received via mailing list)
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?):
http://www.mauipropertytax.com/Datalets.asp?mnu=PS...
        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
Rob B. (Guest)
on 2009-01-28 04:23
(Received via mailing list)
On Jan 27, 2009, at 8:35 PM, Don F. wrote:
> 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

Rob B.    http://agileconsultingllc.com
removed_email_address@domain.invalid
Don F. (Guest)
on 2009-01-28 06:05
(Received via mailing list)
That worked perfectly. Thanks

Don

On Jan 27, 4:22 pm, Rob B. <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.