PHP头条
热点:

抓你没商量


做网站资料少了可是不得了的事情。在别的网站用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.phpzy.comtrue/phprm/38972.htmlTechArticle抓你没商量 做网站资料少了可是不得了的事情。在别的网站用webzip等抓下来的网页没有经过处理应该是不能用的。我们想要的文章就在其中,怎么样想一个解决的法子呢?由于本人比较...

相关文章

    暂无相关文章

PHP之友评论

今天推荐