Skip to content

Instantly share code, notes, and snippets.

@maiha
Created August 27, 2009 19:45
Show Gist options
  • Save maiha/176507 to your computer and use it in GitHub Desktop.
Save maiha/176507 to your computer and use it in GitHub Desktop.
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
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