PHP下载google相册到本地
调用方式 xxx.php?user=xxx
保证程序放的当前目录可写文件夹 可写文件
默认存放方式为
./用户名/相册1描述/图片描述-1.图片后缀
<?php
function open($host,$file){
$return = "";
$header = '';
while($header!='200'){
$fp = fsockopen($host, 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />n";
} else {
$out = "GET $file HTTP/1.1rn";
$out .= "Host: $hostrn";
$out .= "P3P: CP="CAO PSA OUR"rn";
$out .= "User-Agent: Baiduspider+(+[url]http://www.baidu.com/search/spider.htm[/url])rn";
$out .= "Connection: Closernrn";
fwrite($fp, $out);
while (!feof($fp)) {
$return .= fgets($fp,1024);
}
fclose($fp);
}
preg_match("/HTTP/1.1 (.*?) OK/",$return,$output);
$header = $output[1];
}
preg_match("/rnrn(.+)/is", $return, $out);
$return = $out[1];
return mb_convert_encoding($return, "GB2312", "UTF-8");;
相关新闻>>
- 发表评论
-
- 最新评论 更多>>