PHP download Google album to local-php instance _php tutorial

Source: Internet
Author: User
Tags php download

PHP download Google albums to a local-php instance


PHP download Google album to local, call way XXX.PHP?USER=XXX Guarantee program put the current directory writable folder writable file default storage method is./username/album 1 description/Picture description-1. picture suffix lt; Phpfunctionopen$host, $file {$return =; $header = ";

Call Mode xxx.php?user=xxx

Guaranteed program to put the current directory writable folder writable file

The default storage mode is

./user Name/album 1 description/Picture description-1. Picture suffix

function open ($host, $file) {

$return = "";

$header = ";

while ($header! = ' 200 ') {

$fp = Fsockopen ($host, $errno, $errstr, 30);

if (! $fp) {

echo "$errstr ($errno)
\ 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, $errno, $errstr, 30);

if (! $fp) {

echo "$errstr ($errno)
\ 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. "
\ 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 is 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 ' ;

?>

Download Google albums

http://www.bkjia.com/PHPjc/950331.html www.bkjia.com true http://www.bkjia.com/PHPjc/950331.html techarticle php Download Google album to the local-php instance php download Google album to local, call way XXX.PHP?USER=XXX guarantee the program put the current directory writable folder writable file default storage method is.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.