- IMPORTANT WARNING
- COPYRIGHT & LICENSE
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.
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:
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:
LWP::UserAgent->new( agent => "Mozilla", timeout => 30, max_size => 2000, )
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
http:// will be prepended to it.
$t->get_title("http://zoffix.com/") or die $t->error;
Takes no arguments, returns a human parsable error message explaining why
$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.
$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
$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.
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.
You can find documentation for this module with the perldoc command.
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
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.