1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| <?php set_time_limit(0); header("Content-Type:text/html;charset=UTF-8"); date_default_timezone_set("PRC");
$arr = array("你的百度图片JSON数据地址"); for ($j = 0; $j <= count($arr); $j++) { $hansdata = file_get_contents($arr[$j]); $hansjson = json_decode($hansdata, true); for ($i = 0; $i <= count($hansjson['data']); $i++) { $url = $hansjson['data'][$i]['thumbURL']; $state = @file_get_contents($url, 0, null, 0, 1); $hansj=md5(rand(0, 123562122).time()); $filename = "{$hansj}.jpg"; ob_start(); readfile($url); $img = ob_get_contents(); ob_end_clean(); $size = strlen($img); $fp2 = @fopen($filename, "a"); fwrite($fp2, $img); fclose($fp2); } }
|