Download the image code in the css file using php. As a senior and professional suede engineer, I have accumulated rich experience in the Internet since I started my junior year. I believe that every web programmer will also have a senior and professional hacker who has accumulated rich experience in the Internet since I started my junior year. I believe that every web programmer will have similar experiences.
You must download the images in the style file. If you encounter a large style file that may contain hundreds of images to be downloaded, the following small code is the most suitable.
The code is as follows:
<? Php
/*
More & Original PHP Framwork
Copyright (c) 2007-2008 IsMole Inc.
Author: kimi
Documentation
*/
// Note: Set the PHP timeout.
Set_time_limit (0 );
// Note: get the style file content
$ StyleFileContent = file_get_contents ('images/style.css ');
// The note matches the URL to be downloaded.
Preg_match_all ("/url \ (. *) \)/", $ styleFileContent, $ imagesURLArray );
// Download the addresses to be downloaded in the note loop one by one
$ ImagesURLArray = array_unique ($ imagesURLArray [1]);
Foreach ($ imagesURLArray as $ imagesURL ){
File_put_contents (basename ($ imagesURL), file_get_contents ($ imagesURL ));
}
The above is the original reprinted text, and the following is a modified version. if you reprint the text, please leave a link.
The code is as follows:
Set_time_limit (0 );
$ StyleFileContent = file_get_contents ('http: // img.jb51.net/skin/newblue/main.css ');
Preg_match_all ("/url \ (. *) \)/", $ styleFileContent, $ imagesURLArray );
$ ImagesURLArray = array_unique ($ imagesURLArray [1]);
Foreach ($ imagesURLArray as $ imagesURL ){
$ Dir = dirname ($ imagesURL );
If (! File_exists ($ dir ))
{
// Create a directory
CreateDir ($ dir );
}
$ ImagesURL = 'http: // www.jb51.net/'.w.imagesurl;
File_put_contents (basename ($ imagesURL), file_get_contents ($ imagesURL ));
}
Function createDir ($ path ){
$ Path = str_replace ('\', '/', $ path );
If (is_dir ($ path) return true;
If (file_exists ($ path) return false;
$ Parent = substr ($ path, 0, strrpos ($ path ,'/'));
If ($ parent = ''| $ parent = '.' | createDir ($ parent ))
Return @ mkdir ($ path );
Else return false;
}
?>
Bytes. I believe that every web programmer will also have...