Created
August 27, 2009 19:45
-
-
Save maiha/176507 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'mechanize' | |
| WWW::Mechanize::Page.class_eval do | |
| def images | |
| @images ||= search('img').map do |img| | |
| case src = img['src'] | |
| when %r{^https?://} | |
| src | |
| else | |
| (uri + src).to_s | |
| end | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| irb(main):001:0> include ::Webrat::Methods | |
| irb(main):002:0> Webrat.configure.mode = :mechanize | |
| irb(main):003:0> visit 'http://gist.github.com/' | |
| irb(main):004:0> webrat.response.images | |
| => ["http://gist.github.com/images/modules/header/logo_gist.png", ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment