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 ...