Gerhard: meta-tag auslesen

Beitrag lesen

natürlich gibt es eine perl möglichkeit das zu tun:

use LWP::Simple;

$string = get($URL);

$Title = "";
   $Description = "";
   $Keys = "";

## Get title ##
   if ($string =~ /<title>([^<]*)</title>/i) {
      $Title = $1;
      $string =~ s/<title>([^<]*)</title>/ /oi;
      for ($i=0; $i<$Title_Rank; $i++) {
         $string .= " " . $Title;
      }
   }
   else {
      $Title = $webname;
   }

## Get Keywords
   if ($string =~ /<meta\s+name="keywords"\s+content="([^"]*)">/i) {
      $Keys = $1;
      $Keys =~ s/, / /g;
      $Keys =~ s/,/ /g;
   }

## Get Description
   if ($string =~ /<meta\s+name="description"\s+content="([^"]*)">/i) {
      $Description = $1;
   }

$Title =~ s/\s+/ /g;
   if ($Title =~ /^ (.*)/) {
      $Title = $1;
   }

$Description =~ s/\s+/ /g;
   if ($Description =~ /^ (.*)/) {
      $Description = $1;
   }

$Keys =~ s/\s+/ /g;
   if ($Keys =~ /^ (.*)/) {
      $Keys = $1;
   }

$spidered{'Title'} = $Title;
   $spidered{'Keys'} = $Keys;
   $spidered{'Description'} = $Description;
   $spidered{'URL'} = $URL;

sorry for the style -> is copy and paste :-)

gerhard