-2

hi i am working on a project . in this project i need another websites meta content. here is an example

this is remote websites meta content

<meta content="Kültür Sanat Edebiyat Portalı. Geniş Türkçe şiir ve şair arşivi. Yarışmalar, şiir etkinlikleri, sanat haberleri. Kitaplar ile ilgili geniş ve detaylı tanıtımlar. Resim tiyatro sergi." name="description">

i tried php file_get_contents

<?php
$homepage = file_get_contents('http://antoloji.com/');
echo $homepage;
?>

but coulnot find a way how to take only meta content (description part) thank you for your advice

synan54
  • 658
  • 6
  • 16

1 Answers1

4

PHP has a really useful function for this, get_meta_tags which allows you to parse the meta tags of a websites source.

<?php
// Assuming the above tags are at www.example.com
$tags = get_meta_tags('http://www.example.com/');

// Notice how the keys are all lowercase now, and
// how . was replaced by _ in the key.
echo $tags['author'];       // name
echo $tags['keywords'];     // php documentation
echo $tags['description'];  // a php manual
echo $tags['geo_position']; // 49.33;-86.59
?>
James
  • 5,137
  • 5
  • 40
  • 80