无为清净楼资源网 Design By www.qnjia.com
复制代码 代码如下:
<?php
$path=$DOCUMENT_ROOT;
$path=str_replace("/","\\",$path);


//指定文件夹
$path=$path."\\web\\study\\";

//得到所有文件
$s=explode("\n",trim(`dir/b/o:gn $path`));

//得到文件夹下的所有HTML文件名
$num=count($s);
for($i=0;$i<=$num;$i++){
if(strpos($s[$i],".htm")==0){
unset($s[$i]);
}
}
//print_r($s);



//批处理网页
foreach($s as $value){
editfile("D:\\MYOA\\webroot\\web\\study\\".$value);
echo $value."已更新!<br>";
}
//editfile("D:\\MYOA\\webroot\\web\\study\\0105_5.htm");
echo "THE END";


//自定义函数:截取标签之间的内容
function get_body($start_str,$end_str,$content){
$start_str_num=strlen($start_str);
$end_str_num=strlen($end_str);

$a=strpos($content,$start_str)+$start_str_num;
$b=strpos($content,$end_str)-strpos($content,$start_str)-$start_str_num;
return substr($content,$a,$b);
}

//编辑文件
function editfile($str){
//$str="D:\\MYOA\\webroot\\web\\study\\".$str
//取得HTML内容
$file=@fopen($str,"r");
while(!feof($file)){
$result.=fgets($file,9999);
}
fclose($file);


//替换内容
$result=str_replace("老王的数码配件店:王婆数码","岚视界 ",$result);
$result=str_replace("摄影网校","回到教程首页",$result);
$result=str_replace('width="407"','width="770"',$result);
$result=str_replace("http://shop1289309.taobao.com","http://www.lansj.com",$result);
$result=str_replace("老王用的ID有:pccity,joshwang,joshwanggg","",$result);
$result=str_replace("QQ:123709080 MSN:joshwanggg@hotmail.com",'在线咨询: <a target=blank href=tencent://message/?uin=35501547&Site=岚视界摄影&Menu=yes><img border="0" SRC=http://wpa.qq.com/pa?p=1:35501547:10 alt="点击开始咨询"></a> <a target=blank href=tencent://message/?uin=56025743&Site=岚视界摄影&Menu=yes><img border="0" SRC=http://wpa.qq.com/pa?p=1:56025743:10 alt="点击开始咨询"></a>',$result);
$result=str_replace('<a href="http://www.zonline.com.cn">http://www.zonline.com.cn</a><br>',"",$result);
$result=str_replace('http://www.zonline.com.cn/photo/school/scgs/',"http://www.lansj.com/study/",$result);
$result=str_replace('http://www.yimei.net/css/',"http://www.lansj.com/study/",$result);
$result=str_replace('http://www.zonline.com.cn/photo/school/img/',"http://www.lansj.com/study/",$result);
$result=str_replace('http://www.yimei.net/inc/',"http://www.lansj.com/study/",$result);
$result=str_replace('<a href="http://www.xiangshu.com">橡树摄影俱乐部</a>','<a href="http://bbs.lansj.com">岚视界摄影论坛</a>',$result);
$result=str_replace('http://www.zonline.com.cn/photo/img/','http://www.lansj.com/study/',$result);
$result=str_replace('<p>如果你对数码器材和配件有什么问题可以发QQ:123709080问询,数码相机及相关配件专营:<a href="http;//shop1289309.taobao.com">王婆数码</a></p>',"",$result);

$result=str_replace("Untitled Document",substr(str_replace(chr(32),"",str_replace(chr(10),"",str_replace("</p>","",str_replace(chr(13),"",get_body('<p align="center" class="h1"><br>','<p align="left">',$result))))),0,28)." - 岚视界摄影",$result);
$result=str_replace("摄影天地",substr(str_replace(chr(32),"",str_replace(chr(10),"",str_replace("</p>","",str_replace(chr(13),"",get_body('<span class="text">','</span>',$result))))),0,28)." - 岚视界摄影",$result);

//echo $result;

//更新HTML
$file=@fopen($str,"w");
fwrite($file,$result);
fclose($file);
}
?>
标签:
PHP,批量更新,网页内容

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com