WWW::GetPageTitle - get titles of web pages
use strict; use warnings; use WWW::GetPageTitle; my $t = WWW::GetPageTitle->new; $t->get_title('http://zoffix.com') or die $t->error; printf "Title for %s is %s\n", $t->uri, $t->title;
The module doesn't do much, it was designed for an IRC bot, so flames > /dev/null.
The module simply accesses a website and gets its title.
After reviewing this module 5 years after writing it, I came across URI::Title, which seems to be much more robust and useful. If URI::Title does the job for you, please use it, as I might remove this module in the future, seeing as URI::Title does the same thing and MORE than this module.
new
my $t = WWW::GetPageTitle->new; my $t = WWW::GetPageTitle->new( ua => LWP::UserAgent->new( agent => "Mozilla", timeout => 30, max_size => 2000, ) );
Constructs and returns a fresh WWW::GetPageTitle object. So far takes one optional argument in key/value form:
ua
my $t = WWW::GetPageTitle->new( ua => LWP::UserAgent->new( agent => "Mozilla", timeout => 30, max_size => 2000, ) );
The value for the ua argument must be an object that has a get() method that returns an HTTP::Response object. By default the following is used:
get()
LWP::UserAgent->new( agent => "Mozilla", timeout => 30, max_size => 2000, )
get_title
my $title = $t->get_title("http://zoffix.com/") or die $t->error;
Instructs the object to fetch the title of the page. Takes one mandatory argument which is the web page of which you want the title. On failure returns either undef or an empty list, depending on the context, and the description of the error will be available via error() method. On success returns the title of the page. Note: if argument doesn't match m{^(?:https?|ftps?)://}i then http:// will be prepended to it.
undef
error()
m{^(?:https?|ftps?)://}i
http://
error
$t->get_title("http://zoffix.com/") or die $t->error;
Takes no arguments, returns a human parsable error message explaining why get_title() failed.
get_title()
title
$t->get_title("http://zoffix.com/") or die $t->error; my $title = $t->title;
Takes no arguments, must be called after a successful call to get_title(). Returns the exact same thing as the last call to get_title() returned, i.e. the title of the page.
uri
$t->get_title("http://zoffix.com/); my $uri = $->uri; # contains http://zoffix.com/
Takes no arguments, must be called after at least one call to get_title(). Returns the argument passed to the last call of get_title(), which may be modified (see the Note: in get_title() above).
$t->ua( LWP::UserAgent->new ); my $ua = $t->ua; $ua->proxy('http', 'http://foobar.com' );
Takes one optional argument which must satisfy the same criteria as the ua argument in constructor (new() method). Returns the object that is used to access pages.
new()
Zoffix Znet, <zoffix at cpan.org> (http://zoffix.com/, http://haslayout.net/, http://zofdesign.com/)
<zoffix at cpan.org>
Bug reports and fixes by: Geistteufel
Please report any bugs or feature requests to bug-www-getpagetitle at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-GetPageTitle. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-www-getpagetitle at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc WWW::GetPageTitle
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-GetPageTitle
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/WWW-GetPageTitle
CPAN Ratings
http://cpanratings.perl.org/d/WWW-GetPageTitle
Search CPAN
http://search.cpan.org/dist/WWW-GetPageTitle
Copyright 2008 Zoffix Znet, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install WWW::GetPageTitle, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::GetPageTitle
CPAN shell
perl -MCPAN -e shell install WWW::GetPageTitle
For more information on module installation, please visit the detailed CPAN module installation guide.