当前位置:Gxlcms > PHP教程 > 抓你没商量_PHP教程

抓你没商量_PHP教程

时间:2021-07-01 10:21:17 帮助过:17人阅读

做网站资料少了可是不得了的事情。在别的网站用webzip等抓下来的网页没有经过处理应该是不能用的。我们想要的文章就在其中,怎么样想一个解决的法子呢?由于本人比较懒,一个一个手工处理压根我就没有想过。但是网还得做,逼得没办法,编了一个php的程序,也许能完成这个任务吧。:)
以下是源码,供大家参考:
//php 多层文件自动文件转换系统。
//适用于连续文件。
//参数说明
//$site 需要处理的目录
$site="d:/update";
insert($site);
function cchange($path1,$path2){
$lastchar="";
$temp=file($path1);
for ($i=0;$i$temp[$i]=str_replace("
","#br#",$temp[$i]);
$temp[$i]=str_replace("
","#br#",$temp[$i]);
$lastchar.=$temp[$i];
}
$lastchar=strip_tags($lastchar);
$handle=fopen($path2,"w");
fwrite($handle,$lastchar);
fclose($handle);
$ctemp=file($path2);
$max=0;
$pos=0;
$end="";
for ($i=0;$i//文章抓取核心处理字段
//有待完善
$ctemp[$i]=str_replace("#br#","
",$ctemp[$i]);
$ctemp[$i]=ltrim($ctemp[$i]);
$ctemp[$i]=ereg_replace("[ f ]{0,}","",$ctemp[$i]);

while (substr(trim($ctemp[$i]),0,4)=="
"){
$ctemp[$i]=trim(substr(trim($ctemp[$i]),4));
}
if (strlen($ctemp[$i])>20)
$end.=$ctemp[$i];
}
$handle=fopen($path2,"w");
fwrite($handle,$end);
fclose($handle);
}

function insert($path){
$d=dir($path);
while($entry=$d->read()) {
if ($entry!="."&&$entry!=".."){
if (is_dir($path."/".$entry)){
insert($path."/".$entry);
echo $path."
";
}
if (!is_dir($path."/".$entry)){
cchange($path."/".$entry,$path."/".$entry);
}
}
}
}

?>
注:这个程序不是万能的,一些讨厌的用网页它也奈何不了。不过我统计了一下,准确率可以达到90%。如果哪位大侠有兴趣,可以帮我改一下,或和我探讨一下怎么改才尽善尽美。我的联系方式:oicq:7750988,email:cairway@263.net.

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/532126.htmlTechArticle做网站资料少了可是不得了的事情。在别的网站用webzip等抓下来的网页没有经过处理应该是不能用的。我们想要的文章就在其中,怎么样想...

人气教程排行