0
是否有一种常规方法来检查是否为URL启用了AMP?如何检查带有Php的网站Amp是否启用
我目前使用Curl来获取HTML。 我该怎么办?
$html;
if(AMP is Enabled)
echo "You are using AMP in Mobile Version";
else
echo "You are not using AMP in Mobile Version";
是否有一种常规方法来检查是否为URL启用了AMP?如何检查带有Php的网站Amp是否启用
我目前使用Curl来获取HTML。 我该怎么办?
$html;
if(AMP is Enabled)
echo "You are using AMP in Mobile Version";
else
echo "You are not using AMP in Mobile Version";
是的,你可以像这样
非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 */
}
}