& Lt ;? Php @ set_time_limit (10); // Paste bar name $ tbname = & quot; mugen & quot; // album ID $ tid = & quot; 2124904411 & quot ;; // url template $ galleryurltpl = & quot; http://tieba.baidu.com/photo
@ Set_time_limit (10 );
// Paste the name
$ Tbname = "mugen ";
// Album ID
$ Tids = "2124904411 ";
// Url template of the image album page
$ Galleryurltpl = "http://tieba.baidu.com/photo/bw/picture/guide? Kw = % s & tid = % s ";
// Local Directory
$ Savepath = "R:/images /";
// Post subfolders
$ Filedir = $ savepath. $ tid;
// Image file
$ Filenametpl = $ filedir. "/%s.jpg ";
// Url of the image album
$ Galleryurl = sprintf ($ galleryurltpl, $ tbname, $ tid );
// Return json data
$ Retjson = file_get_contents ($ galleryurl );
$ Retarray = json_decode ($ retjson, true );
// Image list
$ Piclist = $ retarray ['data'] ['Pic _ list'];
// Check whether the directory exists
If (! Is_dir ($ filedir ))
Mkdir ($ filedir );
Foreach ($ piclist as $ pic ){
$ Pic_id = $ pic ['IMG '] ['original'] ['id'];
$ Url = "http://imgsrc.baidu.com/forum/pic/item/". $ pic_id. ". jpg ";
$ Filename = sprintf ($ filenametpl, $ pic_id );
// Download the image
$ Imagebin = file_get_contents ($ url );
// Save the image
File_put_contents ($ filename, $ imagebin );
}
?>