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;$iif(strpos($s[$i],".htm")==0){
unset($s[$i]);
}
}
//print_r($s);
//批处理网页
foreach($s as $value){
editfile("D:\\MYOA\\webroot\\web\\study\\".$value);
echo $value."已更新!
";
}
//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",'在线咨询:
',$result);
$result=str_replace('http://www.zonline.com.cn
',"",$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('橡树摄影俱乐部','岚视界摄影论坛',$result);
$result=str_replace('http://www.zonline.com.cn/photo/img/','http://www.lansj.com/study/',$result);
$result=str_replace('
如果你对数码器材和配件有什么问题可以发QQ:123709080问询,数码相机及相关配件专营:王婆数码
',"",$result);$result=str_replace("Untitled Document",substr(str_replace(chr(32),"",str_replace(chr(10),"",str_replace("","",str_replace(chr(13),"",get_body('
','
',$result))))),0,28)." - 岚视界摄影",$result);
$result=str_replace("摄影天地",substr(str_replace(chr(32),"",str_replace(chr(10),"",str_replace("
//echo $result;
//更新HTML
$file=@fopen($str,"w");
fwrite($file,$result);
fclose($file);
}
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.