Search code examples
htmltagsmeta

How to get content of the meta tag of a webpage


I am trying to read the content of a meta tag of a secure web page. But finding it difficult as the properties are not the general one like name, author etc. If their is any way possible please tell.

Thanks in advance.


Solution

  • did you gone through these post in php.net ?

    <meta name="author" content="name">
    <meta name="keywords" content="php documentation">
    <meta name="DESCRIPTION" content="a php manual">
    <meta name="geo.position" content="49.33;-86.59">
    </head> <!-- parsing stops here -->
    

    read these meta tags using php code writte below

    <?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
    ?>
    

    these codes taken from http://php.net/manual/en/function.get-meta-tags.php