2017-08-10 32 views

回答

1

是的,你可以像这样

非AMP页面包含

<link rel="amphtml" href="https://www.example.com/url/to/amp/document.html"> 

假设你已经在$ HTML的内容;

PHP代码

$dom = new DOMDocument(); 
    @$dom->loadHTML($html); 

    $nodes = $dom->getElementsByTagName('link'); 
    foreach ($nodes as $node) 
    { 
     if ($node->getAttribute('rel') === 'amphtml') 
     { 
      echo($node->getAttribute('href')); 
      /* amp page found do your logic */ 
     } 
    }