PHP meta tags reader

Hi ,
    I need a script in php which can read meta tage of a URL submited by user in text box on my web page then print them seprately to TITLE Description and Keywords in the shape of a web form ..please my english is not good...You can see example here http://directory.r-tt.com/Submit_URL/ i need the smillar script
thomas9999Asked:
Who is Participating?
 
tolgaongCommented:
<html>
<head>
<title>Your Site name</title>
</head>

<body>
<?php
if (!isset($_POST["url"])){
?>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<table width="500" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>Please enter URL:</td>
    </tr>
  <tr>
    <td><input name="url" type="text" value="http://" size="40" maxlength="100">
      <input type="submit" name="Submit" value="Submit"></td>
    </tr>
</table>
</form>
<?php
}
else {
$url=$_POST["url"];
$html=file_get_contents($url);
if (preg_match('/<title>([\\w\\W]+)<\/title>/', $html, $regs)) {
      $title= $regs[1];
} else {
      $title= "";
}
$tags = get_meta_tags($url);

?>
<table width="500" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>Enter Title:</td>
  </tr>
  <tr>
    <td><input name="title" type="text" id="title" size="50" value="<?php echo $title ?>"></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>Enter Description:</td>
  </tr>
  <tr>
    <td><textarea name="desc" cols="70" rows="6" id="desc"><?php echo $tags["description"] ?></textarea></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>Enter Keywords:</td>
  </tr>
  <tr>
    <td><textarea name="keyword" cols="70" rows="6" id="keyword"><?php echo $tags["keywords"]?></textarea></td>
  </tr>
</table>

<?php
}
?>
</body>
</html>
0
 
spotxCommented:
phpinfo();
will show you what information is available to your script in your particular version of php under its particular environment
the reuslts will be available via global arrays ie $_SERVER etc

that way you can find what you can get rather than what everyone else can get on thier srever that may not be available to you
0
 
spotxCommented:
sorry I just checked out the site you where talking about
the way this would be done is via
fopen(URL)
read the contents in then parse the meta tag info
check out
http://php.net/manual/en/function.fopen.php
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
tolgaongCommented:
$url='http://www.experts-exchange.com/Web/Web_Languages/PHP/Q_21828969.html';
$tags = get_meta_tags($url);

echo "<pre>";
print_r($tags); //$tags["keywords"];
echo "</pre>";
0
 
thomas9999Author Commented:
Hello tolgaong..
                      your example work but its only print the result i need the same thing as is on http://directory.r-tt.com/Submit_URL/  ... Please all paste the script in PHP if  u can thanksss
0
 
thomas9999Author Commented:
Thanks tolgaong
Its working ..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.