HTML-RelExtor

 view release on metacpan or  search on metacpan

lib/HTML/RelExtor.pm  view on Meta::CPAN

  @links = grep $_->has_rel('alternate'), $parser->links;

=back

=head1 HTML::RelExtor::Link METHODS

=over 4

=item href

  my $href = $link->href;

Returns 'href' attribute of links.

=item tag

  my $tag = $link->tag;

Returns tag name of links in lowercase, either 'a' or 'link';

=item attr

  my $attr = $link->attr;

Returns a hash reference of attributes of the tag.

=item rel

  my @rel = $link->rel;

Returns list of 'rel' attributes. If a link contains C<< <a href="tag nofollow">blahblah</a> >>, C<rel()> method returns a list that contains C<tag> and C<nofollow>.

=item rev

  my @rev = $link->rev;

Returns list of 'rev' attributes.

=item has_rel

  if ($link->has_rel('nofollow')) { }

A handy shortcut method to find out if a link contains specific relationship.

=item has_rev

  if ($link->has_rev('canonical')) { }

A handy shortcut method to find out if a link contains specific reverse relationship.

=item text

  my $text = $link->text;

Returns text inside tags, only avaiable with A tags. It returns undef value when called with LINK tags.

=back

=head1 EXAMPLES

Collect A links tagged with C<< rel="friend" >> used in XFN (XHTML Friend Network).

  my $p = HTML::RelExtor->new();
  $p->parse($html);

  my @links = map { $_->href }
      grep { $_->tag eq 'a' && $_->has_rel('friend') } $p->links;

=head1 TODO

=over 4

=item *

Accept callback parameter when creating a new instance.

=back

=head1 AUTHOR

Tatsuhiko Miyagawa E<lt>miyagawa at bulknews.netE<gt>

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=head1 SEE ALSO

L<HTML::LinkExtor>, L<HTML::Parser>

L<http://www.w3.org/TR/REC-html40/struct/links.html>

L<http://www.google.com/googleblog/2005/01/preventing-comment-spam.html>

L<http://developers.technorati.com/wiki/RelTag>

L<http://gmpg.org/xfn/11>

L<http://shiflett.org/blog/2009/apr/save-the-internet-with-rev-canonical>

=cut



( run in 1.895 second using v1.01-cache-2.11-cpan-119454b85a5 )