open-uri and can’t convert Hash into String
I’m posting this in hopes that search engines grab it and put it at the top of their list when other poor soul’s run into this problem.
If you’re trying to grab a web resource using Open-URI, and you are using basic authentication (username/password) then you’ll need to make sure to require 'open-uri' or you’ll get:
open("http://example.com/site", :http_basic_authentication => ["username", "password"])
TypeError: can't convert Hash into String
Of course, then you toss some yummy Hpricot into the mix for parsing/scraping the good bits of the HTML.
My name is
March 20th, 2007 at 9:36 am (#)
Or you can use something like scRUBYt! - basic authentication is not yet supported in the present version, but will be added with the next release.
October 23rd, 2008 at 3:07 pm (#)
Googled and got your post.
/doh. I forgot to require ‘open-uri’
Thankyou.