mechanize:Mechanize::Page#images
以下のような HTML で
<html> <head> <title>image test</title> </head> <body> <img src="img1.png" width="256" height="128" alt="foo"> <img src="img2.png" width="200" height="100" alt="bar"> </body> </html>
>> require 'mechanize' => true >> agent = Mechanize.new => #<Mechanize:0xb74a82e4 ... >> page = agent.get('http://127.0.0.1:8080/test04_image.html') => #<Mechanize::Page {url #<URI::HTTP:0xb74a49c8 URL:http://127.0.0.1:8080/test04_image.html>} {meta} {title "image test"} {iframes} {frames} {links} {forms}> >> page.images => [#<Mechanize::Page::Image:0xb749b468 @page=#<Mechanize::Page {url #<URI::HTTP:0xb74a49c8 URL:http://127.0.0.1:8080/test04_image.html>} {meta} {title "image test"} {iframes} {frames} {links} {forms}> , @node=#<Nokogiri::XML::Element:0x..fdba4da5c name="img" attributes=[#<Nokogiri::XML::Attr:0x..fdba4d17e name="src" value="img1.png">, #<Nokogiri::XML::Attr:0x..fdba4d174 name="width" value="256">, #<Nokogiri::XML::Attr:0x..fdba4d16a name="height" value="128">, #<Nokogiri::XML::Attr:0x..fdba4d160 name="alt" value="foo">]>>, #<Mechanize::Page::Image:0xb749b404 @page=#<Mechanize::Page {url #<URI::HTTP:0xb74a49c8 URL:http://127.0.0.1:8080/test04_image.html>} {meta} {title "image test"} {iframes} {frames} {links} {forms}> , @node=#<Nokogiri::XML::Element:0x..fdba4da2a name="img" attributes=[#<Nokogiri::XML::Attr:0x..fdba4c4e0 name="src" value="img2.png">, #<Nokogiri::XML::Attr:0x..fdba4c4d6 name="width" value="200">, #<Nokogiri::XML::Attr:0x..fdba4c4cc name="height" value="100">, #<Nokogiri::XML::Attr:0x..fdba4c4c2 name="alt" value="bar">]>>] >> page.images[0].node => #<Nokogiri::XML::Element:0x..fdba4da5c name="img" attributes=[#<Nokogiri::XML::Attr:0x..fdba4d17e name="src" value="img1.png">, #<Nokogiri::XML::Attr:0x..fdba4d174 name="width" value="256">, #<Nokogiri::XML::Attr:0x..fdba4d16a name="height" value="128">, #<Nokogiri::XML::Attr:0x..fdba4d160 name="alt" value="foo">]> >> page.images[0].page => #<Mechanize::Page {url #<URI::HTTP:0xb74a49c8 URL:http://127.0.0.1:8080/test04_image.html>} {meta} {title "image test"} {iframes} {frames} {links} {forms}>