Search code examples
phpgzipmeta-tags

get meta tags is not working in php


I am trying to get meta tags of a website. Here is my code

 $tags = get_meta_tags('https://www.wired.com/story/avengers-infinity-war-d23-footage'); 
   print_r($tags); exit;

this returns empty. Any idea?

Wesbite is using some compression like gzip.


Solution

  • You need to decompress it, which you can use a stream wrapper for. E.g.:

    $tags = get_meta_tags('compress.zlib://https://www.wired.com/story/avengers-infinity-war-d23-footage');
    print_r($tags);
    

    Outputs:

    Array
    (
        [viewport] => width=device-width, initial-scale=1
        [content-type] => article
        ...
    )