使用PHP下載CSS文件中的圖片的代碼
<?php
//note 設置PHP超時時間
set_time_limit(0);//note 取得樣式文件內容 $styleFileContent = file_get_contents('images/style.css'); //note 匹配出需要下載的URL地址 preg_match_all("/url((.*))/", $styleFileContent, $imagesURLArray); //note 循環需要下載的地址,逐個下載 $imagesURLArray = array_unique($imagesURLArray[1]); foreach ($imagesURLArray as $imagesURL) { file_put_contents(basename($imagesURL), file_get_contents($imagesURL)); } ?> </pre>
本文由用戶 ef4w 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!