<?php header('Content-Type:text/html;charset=utf-8'); /** * 一个用于抓去图片的类 */ class download_image { public $_save_path = NULL; //图片保存路劲 public $_limit_size = NULL; //图片限制大小 public static $_img_url_old = array(); //存储已抓取过的图片链接地址 public static $_a_page_url = array(); //存储抓取过的页面 public function __construct( $_save_path, $_limit_size) { $this->_save_path = $_save_path; $this->_limit_size = $_limit_size; } public function get_all_page_image( $site_url ) { if ( $site_url == '' ) { return false; } if ( ! in_array( $site_url, self::$_a_page_url ) ) { //判断当前页面是否抓取过 self::$_a_page_url[] = $site_url; //将超链接存入静态数组中 } else { return; //若抓取过则跳出 }
1. Find a page
2. Filter all img
3. Filter out all src attributes
4. Get link information, Write files file_get_contents(), file_put_contents()
5. Run the code in cli mode (the browser may run out of memory or run timeout)
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
21 Jul 2016
Implementation code for PHP to grab web images and save them as. The following is the source code and related explanations. Copy the code. The code is as follows: ?php //URL is the complete remote image address and cannot be empty. $filename is the name of the image saved as //By default, the image is placed in
24 Apr 2017
We now need to copy the content with pictures on other people's websites to our own website, so I have to download the pictures from other people's websites, then save them locally, and then replace the picture addresses in the content with our local ones. Here we need to use PHP Just use the three functions preg_match_all, file_get_contents, and str_replace.
25 Jul 2016
PHP code for remotely grabbing website images and saving them
01 Dec 2016
The gd library image download class implements the php code for downloading all images on the web page
13 Jul 2016
PHP downloads web page images in batches and replaces the path with the local one. We now need to copy the content with pictures on other people's websites to our own website, so I have to download the pictures from other people's websites, then save them locally, and then replace the picture addresses in the content with
29 Jul 2016
Software for processing images: Software for processing images PHP Class implementation code for processing images: Copy the code as follows: <?php /** * author:yagas * email:yagas60@21cn.com */ class Image { /** Class protection Variables*/ protected $th_width = 100; protected $th_height = 50; protected $quality = 85; //Image quality protected $transparen
Hot Tools
PHP library for dependency injection containers
PHP library for dependency injection containers
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
Small PHP library for optimizing images
Small PHP library for optimizing images