程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> 抓你沒商量

抓你沒商量

編輯:關於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:[email protected].

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved