fork download
  1. <?php
  2.  
  3. $html = '<html><head><meta property="instapp:owner_user_id" content="3469066161" /> <meta property="al:ios:url" content="instagram://media?id=1329656989202933577" /></head><body><span/></body></html>';
  4. $dom = new DOMDocument('1.0', 'UTF-8');
  5. $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
  6.  
  7. $xpath = new DOMXPath($dom);
  8. $metas = $xpath->query('//meta[@content]');
  9. $res = array();
  10. foreach($metas as $m) {
  11. if (preg_match('~[?&]id=([^&#]+)~', $m->getAttribute('content'), $match)) {
  12. array_push($res, $match[1]);
  13. }
  14. }
  15.  
  16. print_r($res);
Success #stdin #stdout 0s 52488KB
stdin
Standard input is empty
stdout
Array
(
    [0] => 1329656989202933577
)