Home >Backend Development >PHP Tutorial >Download images from CSS files with PHP_PHP tutorial

Download images from CSS files with PHP_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-21 14:54:061012browse

As a senior and professional scalper, I have accumulated rich experience in scalping since I started to invest in the great Internet in the third grade of junior high school. I believe that every web programmer will have similar experiences.

During the peeling process, it is essential to download the pictures in the style file. When encountering a relatively large style file, in which there may be hundreds of images that need to be downloaded, it is most appropriate to use the following small code.

< ?php
/*
More & Original PHP Framwork
Copyright (c) 2007 - 2008 IsMole Inc.
www.bkjia.com
Author: kimi
Documentation: Download the pictures in the style file, Shuishui special peeling tool
*/

//note Set PHP timeout
set_time_limit(0);

//note Get Style file content
$styleFileContent = file_get_contents('images/style.css');

//note Match the URL address that needs to be downloaded
preg_match_all("/url((.*)) /", $styleFileContent, $imagesURLArray);

//note Loop through the addresses to be downloaded and download them one by one
$imagesURLArray = array_unique($imagesURLArray[1]);
foreach($imagesURLArray as $imagesURL) {
file_put_contents(basename($imagesURL), file_get_contents($imagesURL));
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/364688.htmlTechArticleAs a senior and professional scalper, I have accumulated a lot of experience in the great Internet since I was in the third grade of junior high school. Rich peeling experience. I believe every web programmer will also have...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn