Download photoshop software code to download images in css files using php

WBOY
Release: 2016-07-29 08:41:47
Original
889 people have browsed it

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.

Copy code The code is as follows:


< ?php
/*
More & Original PHP Framwork
Copyright (c) 2007 - 2008 IsMole Inc.
Author: kimi
Documentation: Download style file in Picture, Shuishui's special peeling tool
*/
//note Set the PHP timeout
set_time_limit(0);
//note Get the style file content
$styleFileContent = file_get_contents('images/style.css');
// note Match the URL addresses that need to be downloaded
preg_match_all("/url((.*))/", $styleFileContent, $imagesURLArray);
//note Loop through the addresses that need 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));
}


The above is the original text reprinted, the following is the modified version, please reprint it Leave a link.

Copy code 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 directory
createDir($dir);
}
$imagesURL='http://www.jb51.net/'.$ 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 ;
}
?>

The above introduces the code for downloading photoshop software using PHP to download pictures in css files, including the content of downloading photoshop software. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template