So far I have been able to stitch this together 🙂
begin
open("http://www.somemain.com/" + path + "/" + blah)
rescue OpenURI::HTTPError
@failure += painting.permalink
else
@success += painting.permalink
end
But how do I read the output of the service that I would be calling?
Open-URI extends
open, so you’ll get a type of IO stream returned:You have to read that to get content:
A lot of times a method will let you pass different types as a parameter. They check to see what it is and either use the contents directly, in the case of a string, or read the handle if it’s a stream.
For HTML and XML, such as RSS feeds, we’ll typically pass the handle to a parser and let it grab the content, parse it, and return an object suitable for searching further: