?
Solved

PHP meta tags reader

Posted on 2006-04-26
6
Medium Priority
?
490 Views
Last Modified: 2012-08-14
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
0
Comment
Question by:thomas9999
  • 2
  • 2
  • 2
6 Comments
 
LVL 3

Expert Comment

by:spotx
ID: 16549830
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
 
LVL 3

Expert Comment

by:spotx
ID: 16549925
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
 
LVL 9

Expert Comment

by:tolgaong
ID: 16550434
$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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:thomas9999
ID: 16552361
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
 
LVL 9

Accepted Solution

by:
tolgaong earned 1000 total points
ID: 16553423
<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
 

Author Comment

by:thomas9999
ID: 16555105
Thanks tolgaong
Its working ..
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question