The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WWW::GetPageTitle - get titles of web pages

SYNOPSIS

    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;

DESCRIPTION

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.

IMPORTANT WARNING

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.

CONSTRUCTOR

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:

    LWP::UserAgent->new(
        agent    => "Mozilla",
        timeout  => 30,
        max_size => 2000,
    )

METHODS

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.

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.

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).

ua

    $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.

AUTHOR

Zoffix Znet, <zoffix at cpan.org> (http://zoffix.com/, http://haslayout.net/, http://zofdesign.com/)

Bug reports and fixes by: Geistteufel

BUGS

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.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc WWW::GetPageTitle

You can also look for information at:

COPYRIGHT & LICENSE

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.