我試圖從css文件下載所有圖像。這些圖像是在url(https://www...image.png)
格式下載CSS文件中的圖像
<?php
$result = file_get_contents("global-61.css");
$path = 'found/';
preg_match_all('https:\/\/www.[^0-9]+.(png|jpg|jpeg|gif)', $result, $output, PREG_SET_ORDER);
foreach($output as $item)
{
copy($item, $path . basename($item));
}
?>
的鏈接是從不同的網站 - 但我想我的正則表達式是不正確的。當我嘗試運行腳本時,它不匹配任何圖像。如果正則表達式沒問題,這裏可能會出錯嗎?熱鏈接保護?
哇謝謝你這方面的知識瞭解正則表達式。正則表達式很混亂...... – Kyle 2012-03-20 02:42:57
你不需要'/ m',它隻影響不被使用的'^'和'$'。 – Qtax 2012-03-20 07:05:00
謝謝Qtax,會編輯 – 2012-03-20 07:07:17