View Full Version : Can I log a web page by its TITLE, not its URL?
kbsbeme
02-19-2007, 12:55 AM
I want to track the performance of a group of files as a unit. I have given all the files within a unit the same, such as: <title>Unit Title</title>.
Is there a variable that returns the TITLE of a page?
DOCUMENT_NAME gives me the filename.
mlseim
02-21-2007, 02:58 PM
If you are lucky enough to have this module installed ...
http://search.cpan.org/dist/HTML-Parser/lib/HTML/HeadParser.pm
Otherwise ...
something like this?
#!/usr/bin/perl
$file="../index.php";
print "Content-type: text/html\n\n";
open(FILE, $file);
$title = "";
while (<FILE>)
{
#If there is a title, chop it and take the text between the two flags
if(/<title>/)
{
chop;
$title = $_;
$title =~ s/<title>//g;
$title =~ s/<\/title>//g;
}
#No title, then use the file name
}
if($title eq "")
{
$title = $file;
}
#Print the title
print "$title<br>";
close(FILE);
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.