Ability to process a file of the specified type under a pinned folder
<?PHPHeader(' content-type:text/html; Charset=utf-8 '); include'./phpquery/phpquery.php '; $path= ' file '; if(Is_dir($path)) { if($DH=Opendir($path)) { while(($file=Readdir($DH)) !==false) { if($file= = '. ' | |$file= = ' ... '){ Continue; } if(!Is_dir($file)){ Echo $file.‘ <br/> '; Exchange ($path.‘ /‘.$file); } } Closedir($DH); }Else{ Echo111; } }Else{ Echo22222; } functionExchange$file){ $path=$file; $file=file_get_contents($path); Phpquery:: Newdocumenthtml ($file); $artlist= PQ ("a"); foreach($artlist as $li){ $str= PQ ($li)->attr (' href '); $str 2=$str; if(strstr($str, ' Javascrip ') | |strstr($str, ' # ') | |Empty($str)){Continue;} if(strstr($str, ' http ')){ $str= ' http://qhmoney.cn '.substr($str,Strrpos($str,‘/‘)); }Else{ $str= ' http://qhmoney.cn/'.$str; } //echo $str. ' <br/> '; $file=Str_replace($str 2,$str,$file); file_put_contents($path,$file); } }?>
Using Phpquery for batch file processing