可能重复:
Help getting meta title and description
我已经花了一整天的时间在这上面。在网上搜索。也看到了一些类似的问题。但我只有失望。
我想得到一些php代码,通过它我可以输出标题和大约4-5行描述任何使用php的网站。
发布于 2011-10-09 11:18:41
<?php
$url = "http://www.drquincy.com/";
$fp = fopen($url, 'r');
$content = "";
while(!feof($fp)) {
$buffer = trim(fgets($fp, 4096));
$content .= $buffer;
}
$start = '<title>';
$end = '</title>';
preg_match(" / $start( . * )$end / s", $content, $match);
$title = $match[1];
$metatagarray = get_meta_tags($url);
$keywords = $metatagarray["keywords"];
$description = $metatagarray["description"];
echo " <div><strong>URL: </strong >$url</div> \n";
echo " <div><strong>Title: </strong >$title</div> \n";
echo " <div><strong>Description: </strong >$description</div>\n";
echo " <div><strong>Keywords: </strong >$keywords</div>\n";
只需更改网址:)
https://stackoverflow.com/questions/7703105
复制相似问题