我试图提取 url 的标题、描述和关键字。下面的代码适用于单行描述,但不适用于多行描述。任何人都可以帮助解决这个问题。如果我能像社交书签网站那样知道如何提取图像,那就太好了。
<?php
$url = "http://www.apnatimepass.com";
$fp = fopen($url, 'r');
$content = "";
while(!feof($fp)) {
$buffer = trim(fgets($fp, 4096));
$content .= $buffer;
}
$start = '<title>';
$end = '</title>';
preg_match('!<title>(.*?)</title>!i', $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";
?>