首页 > PHP

PHP下载google相册到本地

时间:2009-04-23 13:01:10  作者:chinaitlab  我要投稿
Linux初探欢迎您的投稿,投放方法请点击这里查看,我们会定期赠送精美小礼品给优秀的投稿作者。海纳百川 取则行远!LinuxGoo欢迎您的到来。
调用方式 xxx.php?user=xxx保证程序放的当前目录可写文件夹 可写文件默认存放方式为./用户名/相册1描述/图片描述-1.图片后缀<?phpfunction open($host,$file){$r......

echo "can't open $filename";

exit;

}

if (fwrite($handle, $data) === FALSE) {

echo "can't write $filename";

exit;

}

// echo "write to $filename done";

fclose($handle);

echo $filename."<br />\r\n";

}

$aid = ($_GET['aid']!='')?$_GET['aid']:0;

$user = $_GET['user'];

if(!is_dir($user)){

if(!mkdir($user)) die('create dir error');

}

if($user=='') die("user string can't be blank");

$userstr = '/'.$user.'/';

$html = str_replace("'",'',open('picasaweb.google.com',$userstr));

preg_match_all("/,access:public\n,title:(.*?)\n,url:(.*?)\n,src/s",$html,$album);

$all = count($album[1]);

if($aid>$all) die('OK');

$aurl = str_replace('\x2F','/',$album[2][$aid]);

$astr = './'.$user.'/'.$album[1][$aid];

$afile = str_replace('http://picasaweb.google.com','',$aurl);

$html = str_replace('$','',open('picasaweb.google.com',$afile));

preg_match_all("/\"summarytype\":\"text\",\"summary\":\"(.*?)\",\"contenttype\":\"(.*?)\",\"contentsrc\":\"(.*?)\",\"link\":/s",$html,$pics);

$allpic = count($pics[3]);

for($i=0;$i<$allpic;$i ){

$pic = $pics[3][$i];

$typetemp = explode('.',$pic);

$type = $typetemp[(count($typetemp)-1)];

$pname = $pics[1][$i].'-'.$i.'.'.$type;

$temp = explode('ggpht.com',$pic);

$imghost = str_replace('http://','',$temp[0].'ggpht.com');

$imgfile = $temp[1];

img($imghost,$imgfile,$astr,$pname);

}

$aid ;

echo '<meta http-equiv="refresh" content="2;url=?aid='.$aid.'&user='.$user.'">';

?>

<title>下载google相册</title>

<form>

<input name=user type=text>

<input type=submit>

</form>

作者:落伍 山贼

如果您需转载 PHP下载google相册到本地,请注明来自LinuxGoo.com,其版权归原作者所有。请广大网友留言时遵纪守法,使用文明用语。如果您在应用中有什么问题,请在下面留言,我们会尽快解答。
来顶一下
近回首页
返回首页
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
相关文章
栏目热门