0

Im scraping a website using Celerity gem and I want to save an image but I dont know how to do it XD

With the next Celerity command I get an IO object

irb(main):260:0* image = @browser.image(:xpath, ".//*[@class='notdTop']/img").download
=> #<IO:0x277e07ae>

How can I save this object to a jpg file?? I tried this, but didnt work:

irb(main):261:0> image.flush
IOError: not opened for writing

but the IO object is not closed because I got this:

irb(main):264:0> image.closed?
=> false

Anyone can help me please?

EmP
  • 11
  • 2

1 Answers1

2

Try:

image.save(filename)

http://rubydoc.info/gems/celerity/0.8.9/Celerity/Image#save-instance_method

Casper
  • 33,403
  • 4
  • 84
  • 79