2012-11-01 19:18:05 +00:00
|
|
|
class Anemone::Extractors::MetaRefresh < Anemone::Extractors::Base
|
|
|
|
|
2013-08-30 21:28:33 +00:00
|
|
|
def run
|
|
|
|
doc.search( "//meta[@http-equiv='refresh']" ).map do |url|
|
|
|
|
begin
|
|
|
|
_, url = url['content'].split( ';', 2 )
|
|
|
|
next if !url
|
|
|
|
unquote( url.split( '=', 2 ).last )
|
|
|
|
rescue
|
|
|
|
next
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue
|
|
|
|
nil
|
|
|
|
end
|
2012-11-01 19:18:05 +00:00
|
|
|
|
2013-08-30 21:28:33 +00:00
|
|
|
def unquote( str )
|
|
|
|
[ '\'', '"' ].each do |q|
|
|
|
|
return str[1...-1] if str.start_with?( q ) && str.end_with?( q )
|
|
|
|
end
|
|
|
|
str
|
|
|
|
end
|
2012-11-01 19:18:05 +00:00
|
|
|
|
|
|
|
end
|