oh and I thought I should provide the error message itself: NoMethodError (undefined method `read' for #<URI::HTTP:0x256f764>):
On Jan 24, 1:41 am, cdubd <[email protected]> wrote: > Hey Everyone, > > I have a pretty interesting problem that I thought I would try and get > some feedback on. The following method below accepts a URL string as a > parameter ex "http://www.google.com," and it uses regular expressions > to try and find the images in the html. The odd thing is.... that I > have tested it over and over again.... and it has always grabbed the > images and worked exactly as I coded it too, but lately it has been > telling me that the URI class doesn't have a read method.... when it > must because I have been using it! > > I am just so confused why rails would suddenly have this issue, and I > am wondering if anyone can make heads or tails out of it. The code is > posted below. > > Thanks! > > <================== CODE ===========================================> > > def get_images(url) > @image_links = [] > > if validate_link(url) == false > return @image_links > end > > if ((url =~ /\.jpg/)||(url =~ /\.png/)||(url =~ /\.gif/)) == nil > begin > uri = URI.parse(url) > str = uri.read > host = uri.host > rescue SystemCallError > return @image_links > > end > > @body = str.scan(/<body.+<\/body>/) > @images = str.scan(/(src=\"http.+\.jpg?\")/) > str = @images.to_s > @images = str.scan(/\".+?\"/) > @image_links = filter_images(@images) > @image_links.push("no_image.jpg") > else > @image_links.push(url) > @image_links.push("no_image.jpg") > end > > return @image_links > end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

