PHP下载google相册到本地(2)
来源:互联网 责任编辑:栏目编辑 发表时间:2013-07-01 20:11 点击:次
}
function openimg($host,$file){
$return = "";
$header = '302';
while($header=='302'){
$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 .= "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.0 (.*?) /",$return,$output);
$header = $output[1];
}
preg_match("/rnrn(.+)/is", $return, $out);
$return = $out[1];
if($header=='404') $return='';
return $return;
}
function img($host,$file,$dir,$name){
$data = openimg($host,$file);
// echo $dir;
相关新闻>>
- 发表评论
-
- 最新评论 更多>>