Forum: Ruby Hpricot 'emptyelem'?

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.
907f29cb608004d2156d5ce88240f09b?d=identicon&s=25 Tim Mcd (zonbi)
on 2009-02-03 22:57
So I require hpricot, open-uri, and net/http in IRB. I type this bit of
code;
doc = Hpricot(open("http://redhanded.hobix.com/index.html"))

then I run
images = (doc/"img")

and I get this for images:

#<Hpricot::Elements[{emptyelem <img src="/images/redhanded.gif"
alt="RedHanded">}, {emptyelem <img src="/images/prag-ruby-book.jpg"
alt="PickAxe II">}, {emptyelem <img src="/images/redhanded-duck.gif"
alt="Type the Duck">}, {emptyelem <img src="/images/bubble_icon.gif"
height="20" alt="Get Conversations about RedHanded » sneaking Ruby
through the system" width="24">}, {emptyelem <img
src="/images/hackety-org.png" alt="">}, {emptyelem <img
src="/images/hackety-0.4-err1.png" alt="">}, {emptyelem <img
src="/images/hackety-soda.png" alt="">}, {emptyelem <img
src="/images/hacky-mouse-sketch.png" alt="">}, {emptyelem <img
src="/images/irb-lex.gif" alt="">}, {emptyelem <img
src="/images/gem-mirror-only.gif" alt="">}, {emptyelem <img
src="/images/aside-from-that-there-is-a-range.gif" alt="">}, {emptyelem
<img src="/images/a-personal-expando.png" alt="">}, {emptyelem <img
src="/images/hpricot-aby.png" alt="">}, {emptyelem <img
src="/images/view-as-hpricot.png" alt="">}, {emptyelem <img
src="/images/keepvid.png" alt="">}, {emptyelem <img
src="/images/randfeed.png" alt="">}, {emptyelem <img
src="/images/soundtrack-poster.png" alt="">}]>


Now I want to be able to download all the images from this web page. But
I don't see being able to just go (in psuedo code)

open(images[0], w) do |file|
write(images[0]
end

Because of all the weird 'emptyelem' bits. How do I get around these?
907f29cb608004d2156d5ce88240f09b?d=identicon&s=25 Tim Mcd (zonbi)
on 2009-02-03 23:06
Ok so I fixed the issue.
This topic is locked and can not be replied to.