mechanize:Mechanize::Page#bases_with
以下のような HTML で
<html> <head> <title>base test</title> <base href="http://127.0.0.1:8080/test00_base.html"> </head> <body> </body> </html>
>> require 'mechanize' => true >> agent = Mechanize.new => #<Mechanize:0xb74e1328 ... >> page = agent.get('http://127.0.0.1:8080/test00_base.html') => #<Mechanize::Page {url #<URI::HTTP:0xb74dda70 URL:http://127.0.0.1:8080/test00_base.html>} {meta} {title "base test"} {iframes} {frames} {links} {forms}> >> page.bases_with(:href => //).each {|base| puts "* #{base.href}"} * http://127.0.0.1:8080/test00_base.html => [#<Mechanize::Page::Base "" "http://127.0.0.1:8080/test00_base.html"> ] >> page.base_with(:href => //).each {|base| puts "* #{base.href}"} NoMethodError: undefined method `each' for #<Mechanize::Page::Base:0xb74d1310> from (irb):5 >> page.base_with(:href => //) {|base| puts "* #{base.href}"} * http://127.0.0.1:8080/test00_base.html => #<Mechanize::Page::Base "" "http://127.0.0.1:8080/test00_base.html">