国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

PHP下載google相冊到本地-PHP實例

2024-05-04 21:54:35
字體:
來源:轉載
供稿:網友

 PHP下載google相冊到本地,調用方式xxx.

調用方式 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.1/r/n";

    $out .= "Host: $host/r/n";

    $out .= "P3P: CP=/"CAO PSA OUR/"/r/n";

    $out .= "User-Agent: Baiduspider+(+[url]http://www.baidu.com/search/spider.htm[/url])/r/n";

    $out .= "Connection: Close/r/n/r/n";

    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("//r/n/r/n(.+)/is", $return, $out);

$return = $out[1];

return mb_convert_encoding($return, "GB2312", "UTF-8");;

}

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.1/r/n";

    $out .= "Host: $host/r/n";

    $out .= "User-Agent: Baiduspider+(+[url]http://www.baidu.com/search/spider.htm[/url])/r/n";

    $out .= "Connection: Close/r/n/r/n";

    fwrite($fp, $out);

    while (!feof($fp)) {

        $return .= fgets($fp,1024);

    }

    fclose($fp);

}

preg_match("/HTTP//1.0 (.*?) /",$return,$output);

$header = $output[1];

}

preg_match("//r/n/r/n(.+)/is", $return, $out);

$return = $out[1];

if($header=='404') $return='';

return $return;

}

function img($host,$file,$dir,$name){

$data = openimg($host,$file);

// echo $dir;

$blankimg = '../images/blank.jpg';

$filename = $dir.'/'.$name;

// echo $filename;

if(!is_dir($dir)){

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

}

// echo $data;

    if (!$handle = fopen($filename, 'w+')) {

         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>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 金华市| 永定县| 精河县| 尼玛县| 西乡县| 毕节市| 高安市| 景东| 宜春市| 中宁县| 平定县| 涿鹿县| 阜新市| 湖口县| 南召县| 广宁县| 水富县| 万宁市| 松原市| 米林县| 平南县| 武川县| 汕尾市| 余干县| 墨江| 新沂市| 北流市| 合川市| 琼中| 林口县| 盐城市| 香港| 天台县| 牡丹江市| 措美县| 当雄县| 米林县| 林西县| 营口市| 凤台县| 老河口市|