星期四, 五月 19, 2005
抓檔 和 更改檔名
老師說過~ 程式設計師就是要 "懶"~..
只要做一次的事情就不做第二次.
需要重覆做的事情就交給電腦去做就好了~~
也就因此.. 為了 抓圖片 & 改檔名 等等~ 寫了隻小程式..
只要是連續數字要做任何命令的. 就靠它了~ :p
<?php $url = <<<EOF <br><img src=http://url/filename011.jpg> ..... 這邊放要抓的整批 url 位址 <br><img src=http://url/filename020.jpg> EOF; // 先把上面的資料轉成 array. $url = explode("n", $url); // 取出 url, 準備使用 wget 抓取~ foreach($url as $key => $value) { preg_match('/.*[^http](http.*[^jpg]jpg*).*/', $value, $real_url); if(preg_match('/^http/', $real_url[1])) $wget_url[] = $real_url[1]; } $num = count($wget_url); for($i = 0; $i < $num; $i++) { $comm = "wget ".$wget_url[$i]; `$comm`; // 若有需要更改檔名的話. //$comm = "mv *".sprintf("%03s", $i).".jpg ".sprintf("%03s", $i).".jpg"; //`$comm`; } ?>
改名可以直接用wget裡的參數
-O file
--output-document=file
The documents will not be written to the appropriate files, but all
will be concatenated together and written to file. If file already
exists, it will be overwritten. If the file is -, the documents
will be written to standard output. Including this option
automatically sets the number of tries to 1.
Comment by
喵
(05/19/2005 23:31)
發表迴響
PS: 若無法留言, 請先確認是否有打開 JavaScript, 造成您的困擾, 實在萬分對不起 Orz...(如果無法留言, 勞煩可以發信給我好嗎? 謝謝.)
PS2: 若您的留言被誤判, 我都會再自行看過, 不需要一直重覆張貼~
PS2: 若您的留言被誤判, 我都會再自行看過, 不需要一直重覆張貼~





