PHP 正则表达式匹配和获取网站信息(标题,关键词,简介)

<?php
$file=file("http://www.liuxq.cn");
$count=count($file);
for($i=0;$i<$count;$i++){
if(eregi("<title>(.*)</title>",$file[$i],$out)){
$title=$out[0];
}
}
$title=substr($title,7,-8);
echo $title;
?>

preg_match("/<meta[^>]*?name=[\'\"]?description[\'\"]?[^>]*?>/is",$file[$i],$description);
//$description[0] 就是描述

preg_match("/<meta[^>]*?name=[\'\"]?keywords[\'\"]?[^>]*?>/is",$file[$i],$keywords);
//$keywords[0] 就是关键字


liuxq原创文章,转载需注明出处 http://www.liuxq.cn/2009/10/402/

评论暂缺

Comments are closed.