| WWW-Mechanize-Meta documentation | Contained in the WWW-Mechanize-Meta distribution. |
WWW::Mechanize::Meta - Adds HEAD tag parsing to WWW::Mechanize
Version 0.07
use WWW::Mechanize::Meta;
my $mech = WWW::Mechanize::Meta->new();
my @css=$mech->link('stylesheet');
foreach (@css){
print "$_->{href}\n";
}
Returns link tag with attribure rel = $type. If no attribute $type given, returns all link tags.
Returns all rss objects for this page
Returns raw header object
Andrey Kostenko, <andrey@kostenko.name>
Please report any bugs or feature requests to
bug-www-mechanize-meta at rt.cpan.org, or through the web interface at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Mechanize-Meta.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc WWW::Mechanize::Meta
You can also look for information at:
Copyright 2007 Andrey Kostenko, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| WWW-Mechanize-Meta documentation | Contained in the WWW-Mechanize-Meta distribution. |
package WWW::Mechanize::Meta; use warnings; use strict; use Data::Dumper; use HTTP::Headers; use HTML::HeadParser; use base 'WWW::Mechanize';
our $VERSION = '0.07';
sub link { my $self = shift; my $type = shift; my @links; foreach my $link ( $self->{head}->header('link') ) { my @params = split '; ', $link; my ($src) = ( ( shift @params ) =~ m/\<(.*)\>/ ); my %params = map { m/(.*)=\"([^\"]*)\"/ } @params; $params{href} = $src; push @links, \%params if !$type || $params{rel} eq $type; } return @links; }
sub rss { my $self = shift; my @links = $self->link('alternate'); my @news; foreach (@links) { push @news, $_ if $_->{type} eq 'application/rss+xml' or $_->{type} eq 'application/atom+xml'; } return @news; }
sub headtag { my $self = shift; return $self->{head}; }
sub new { my $class = shift; my $self = $class->SUPER::new(@_); $self->{headparser} = HTML::HeadParser->new(); return $self; }
sub title { my $self = shift; return unless $self->is_html; my $title = $self->{head}->header('Title'); return $title; }
sub update_html { my $self = shift; my $html = shift; $self->SUPER::update_html($html); # warn $html; if ( $self->is_html ) { utf8::decode($html); $self->{headparser}{'header'} = HTTP::Headers->new(); $self->{headparser}->parse($html); $self->{head} = $self->{headparser}->header; } else { $self->{head} = undef; $self->{link} = undef; } return; }
sub _parse_head { my $self = shift; return unless $self->is_html; require HTML::HeadParser; my $p = HTML::HeadParser->new; $p->parse( $self->content ); }
1; # End of WWW::Mechanize::Meta