.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "URI::Title 3pm" .TH URI::Title 3pm "2023-02-12" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" URI::Title \- get the titles of things on the web in a sensible way .SH "VERSION" .IX Header "VERSION" version 1.904 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use URI::Title qw( title ); \& my $title = title(\*(Aqhttp://microsoft.com\*(Aq); \& print "Title is $title\en"; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" I keep having to find the title of things on the web. This seems like a really simple request, just \fBget()\fR the object, parse for a title tag, you're done. Ha, I wish. There are several problems with this approach: .IP "What if the resource is on a very slow server? Do we wait for ever or what?" 4 .IX Item "What if the resource is on a very slow server? Do we wait for ever or what?" .PD 0 .IP "What if the resource is a 900 gig file? You don't want to download that." 4 .IX Item "What if the resource is a 900 gig file? You don't want to download that." .IP "What if the page title isn't in a title tag, but is buried in the \s-1HTML\s0 somewhere?" 4 .IX Item "What if the page title isn't in a title tag, but is buried in the HTML somewhere?" .IP "What if the resource is an \s-1MP3\s0 file, or a word document or something?" 4 .IX Item "What if the resource is an MP3 file, or a word document or something?" .IP "..." 4 .PD .PP So, let's solve these issues once. .SH "METHODS" .IX Header "METHODS" only one, the title(url) method. Call it with an url, get the title if possible, undef if it wasn't. Very simple. .SH "SEE ALSO" .IX Header "SEE ALSO" WWW::GetPageTitle \- similar this module, but just handles web pages. The author of that module suggests you should use \f(CW\*(C`URI::Title\*(C'\fR. .SH "NOTES" .IX Header "NOTES" Embedded title metadata of png files can be extracted if you have installed either Image::ExifTool or Image::PNG::Libpng. .SH "TODO" .IX Header "TODO" Many, many, many things. Still unimplemented: .IP "Get titles of \s-1MP3\s0 files, Word Docs, PDFs, etc." 4 .IX Item "Get titles of MP3 files, Word Docs, PDFs, etc." .PD 0 .IP "Configurable.. well, anything, in fact. Timeout would be a good start." 4 .IX Item "Configurable.. well, anything, in fact. Timeout would be a good start." .IP "Better error reporting." 4 .IX Item "Better error reporting." .PD .SH "AUTHORS" .IX Header "AUTHORS" Tom Insam , original author, 2004\-2012. .PP Philippe Bruhat (BooK) , maintainer, 2014. .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2004 Tom Insam. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "CREDITS" .IX Header "CREDITS" Invented because of a conversation with rjp, who contributed some eyeball-melting and as-yet-unused code to get titles from MP3s and PDFs, and hex, who has also solved the problem, and got bits done in a nicer way than I did.