Nearly always busy, encountered a manual live, need to download some remote pictures, altogether more than 100 Zhang, if by hand a piece of Save, also too time-consuming, so the internet Google a handful, find php bulk Download image file method, The original article is about how to use PHP to bulk download images in CSS files. After the study has rewritten a bit can be used, convenient and much faster.
PHP Bulk Download image file code:
Set_time_limit (0);//Set PHP time-out
$imagesURLArray = Array_unique ($imagesURLArray);
foreach ($imagesURLArray as $imagesURL) {
Echo $imagesURL;
echo "
";
File_put_contents (basename ($imagesURL), file_get_contents ($imagesURL));
}
The principle is simple, a loop with an array of image addresses, and then use PHP's file_get_contents function to get the picture, using the File_put_contents function to save the picture.
P.S: Be sure to add the PHP time-out period Oh ~!
Attach the source code to download the images in CSS via PHP:
< PHP
/*
More & Original PHP framwork
Copyright (c) 2007-2008 Ismole Inc.
Author:kimi bkjia.com
Documentation: Download the picture in the style file, water special Mr Skinner tool
*/
Note Set PHP timeout time
Set_time_limit (0);
Note Get style file content
$styleFileContent = file_get_contents (' images/style.css ');
Note matches the URL address that needs to be downloaded
Preg_match_all ("/url\ (. *) \)/", $styleFileContent, $imagesURLArray);
Note loops need to download the address, download it individually
$imagesURLArray = Array_unique ($imagesURLArray [1]);
foreach ($imagesURLArray as $imagesURL) {
File_put_contents (basename ($imagesURL), file_get_contents ($imagesURL));
}
http://www.bkjia.com/PHPjc/364691.html www.bkjia.com true http://www.bkjia.com/PHPjc/364691.html techarticle nearly always busy, encountered a manual live, need to download some remote pictures, altogether more than 100 Zhang, if through a manual one sheet of the preservation, also too time-consuming, so the Internet goo ...