<?php
@set_time_limit(
//貼吧名稱
$tbname = "mugen";
//相冊ID
$tid = "
//圖冊頁url模版
$galleryurltpl = "%s&tid=%s";
//本地的目錄
$savepath = "R:/images/";
//帖子子文件夾
$filedir = $savepath
//圖片文件
$filenametpl = $filedir
//圖冊頁url
$galleryurl = sprintf($galleryurltpl
//返回的json數據
$retjson = file_get_contents($galleryurl);
$retarray = json_decode($retjson
//圖片列表
$piclist = $retarray[
//目錄是否存在
if(!is_dir($filedir))
mkdir($filedir);
foreach($piclist as $pic){
$pic_id = $pic[
$url = "$pic_id
$filename = sprintf($filenametpl
//下載圖片
$imagebin = file_get_contents($url);
//保存圖片
file_put_contents($filename
}
?>
From:http://tw.wingwit.com/Article/program/PHP/201311/21067.html