mechanize:Mechanize::Page#meta

以下のような HTML で

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="content-style-type" content="text/css">
<meta http-equiv="content-script-type" content="text/javascript">
<title>meta test</title>
</head>
<body>

</body>
</html>
>> require 'mechanize'
=> true
>> agent = Mechanize.new
=> #<Mechanize:0xb74b1380 ...
>> page = agent.get('http://127.0.0.1:8080/test07_meta.html')
=> #<Mechanize::Page
 {url #<URI::HTTP:0xb74adac8 URL:http://127.0.0.1:8080/test07_meta.html>}
 {meta}
 {title "meta test"}
 {iframes}
 {frames}
 {links}
 {forms}>

>> page.meta
=> []



require 'mechanize'

class Mechanize
  class Page < Mechanize::File
    def meta
      @meta = search('head > meta').map do |node|
        node
      end.compact
    end
  end
end

agent = Mechanize.new
page = agent.get('http://127.0.0.1:8080/test07_meta.html')
p page.meta

で、

[#<Nokogiri::XML::Element:0x..fdbb0911c name="meta" attributes=[#<Nokogiri::XML::Attr:0x..fdbb0905e name="http-equiv" value="content-type">, #<Nokogiri::XML::Attr:0x..fdbb09054 name="content" value="text/html; charset=utf-8">]>, #<Nokogiri::XML::Element:0x..fdbb090f4 name="meta" attributes=[#<Nokogiri::XML::Attr:0x..fdbb08d70 name="http-equiv" value="content-style-type">, #<Nokogiri::XML::Attr:0x..fdbb08d66 name="content" value="text/css">]>, #<Nokogiri::XML::Element:0x..fdbb090cc name="meta" attributes=[#<Nokogiri::XML::Attr:0x..fdbb08a82 name="http-equiv" value="content-script-type">, #<Nokogiri::XML::Attr:0x..fdbb08a78 name="content" value="text/javascript">]>]
require 'mechanize'

class Mechanize
  class Page < Mechanize::File
    def meta
      @meta ||= search('head > meta').map do |node|
        next unless node['http-equiv'] && node['content']
        (equiv, content) = node['http-equiv'], node['content']
        if equiv && equiv.downcase == 'refresh'
        #  Meta.parse(content, uri) do |delay, href|
        #    node['delay'] = delay
        #    node['href'] = href
        #    Meta.new(node, @mech, self)
        #  end
        end
      end.compact
    end
  end
end

agent = Mechanize.new
page = agent.get('http://127.0.0.1:8080/test07_meta.html')
p page.meta

で、

[]