PHP Crawl Web Image _php Tutorial

Source: Internet
Author: User
PHP Crawling Web Images

PHP is a very easy-to-learn web programming language. PHP has a very low learning cost and can quickly develop various web applications, which is an excellent tool.
Although many people find PHP a lot of drawbacks, quick and dirty, but "there are only two programming languages in the world, one is controversial, one is not used", right? As long as you can do things well tools, is a good tool. PHP is such a good language tool.

 ';  Get_name1 ($arr _src1);  Get_name1 ($arr _src2);  Get_name1 ($arr _src3);  Get_name1 ($arr _SRC4);  Get_name2 ($arr _src1);  Get_name2 ($arr _src2);  Get_name2 ($arr _src3);   Get_name2 ($arr _SRC4); Echo ' ============================================= crawl end =============================================
'; return 0; } function get_name1 ($pic _arr) {//Picture number and type $pattern _type = '/.*\/(. *?) $/'; foreach ($pic _arr as $pic _item) {//loops out the address of each image $num = Preg_match_all ($pattern _type, $pic _item, $match _type); Save the picture as a stream $write _fd = @fopen ($match _type[1][0], "WB"); echo "Image URL: http://blog.csdn.net/phpfenghuo/article/details/". $pic _item. "
"; @fwrite ($write _fd, Curlget ($pic _item)); @fclose ($write _fd); } return 0; } function Get_name2 ($pic _arr) {//Picture number and type $pattern _type = '/.*\/(. *?) $/'; foreach ($pic _arr as $pic _item) {//loops out the address of each image $num = Preg_match_all ($pattern _type, $pic _item, $match _type); Save the picture as a stream $write _fd = @fopen ($match _type[1][0], "WB"); echo "Image URL: http://blog.csdn.net/phpfenghuo/article/details/". $_post[' link '. $pic _item. "
"; @fwrite ($write _fd, curlget ($_post[' link '). $pic _item)); @fclose ($write _fd); } return 0; }//Crawl Web content function Curlget ($url) {$url =str_replace (' & ', ' & ', $url); $curl = Curl_init (); curl_setopt ($curl, Curlopt_url, $url); curl_setopt ($curl, Curlopt_header, false); curl_setopt ($curl, Curlopt_referer, $url); curl_setopt ($curl, Curlopt_useragent, "mozilla/4.0 (compatible; MSIE 6.0; seaport/1.2; Windows NT 5.1; SV1; infopath.2) "); curl_setopt ($curl, Curlopt_cookiejar, ' cookie.txt '); curl_setopt ($curl, Curlopt_cookiefile, ' cookie.txt '); curl_setopt ($curl, Curlopt_returntransfer, 1); curl_setopt ($curl, curlopt_followlocation, 0); $values = curl_exec ($curl); Curl_close ($curl); return $values; }?> <title>Web Image Crawl</title>


http://www.bkjia.com/PHPjc/735897.html www.bkjia.com true http://www.bkjia.com/PHPjc/735897.html techarticle php crawling Web images PHP is a very easy-to-learn web programming language. PHP has a very low learning cost and can quickly develop various web applications, which is an excellent tool. Although many people feel that ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.