2017-08-10 63 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 */ 
     } 
    }