ลิงก์ผู้สนับสนุน

วันพุธที่ 14 ธันวาคม พ.ศ. 2554

[Perl] Facebook photo album download with perl


#[Perl] Facebook photo album download with perl
#Pastebin : http://pastebin.com/MRx8fGuV

#Usage : ' perl filename.pl username password album_url '


use LWP::UserAgent;

use HTTP::Cookies;

$user=(shift or 'email@fb_download.com');
$pass=(shift or 'password');
$album=(shift or 'http://www.facebook.com/media/set/?set=a.529237716211.2047231.4&type=3');

$cookie_jar=HTTP::Cookies->new(autosave=>1, hide_cookie2=>1);
$agent=LWP::UserAgent->new(
agent => 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16',
timeout => 5,
max_redirect => 0,
cookie_jar => $cookie_jar
);
$login=$agent->get('http://www.facebook.com/login.php');
$login=$agent->post('https://www.facebook.com/login.php',
[
'locale' => 'en_US',
'email' => $user,
'pass' => $pass,
'persistent' => 1
]
)->content;

if ($login!~/Incorrect Email|Incorrect username|Please re-enter your password|Cookies Required/i) {
print "Login success...\n";
$album_content=$agent->get($album)->content;
while ($album_content=~/src=(http(.+?).jpg)&/ig) {
print url_decode($1),"\n";
save(url_decode($1));
}
}
else { print "Login failed!!\n"; }


sub url_decode {
my $str=shift;
$str=~s/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg;
return $str;
}
sub url_encode {
my $str=shift;
$str=~s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
return $str;
}
sub save {
$image=shift;
open TXT,">>FB_ablum_download.txt";
print TXT localtime." $image\n";
close TXT;

$saveimage=$agent->get($image)->content;
$image=~s/http:\/\/(.+)\///g;
open IMAGE,">$image";
binmode IMAGE;
print IMAGE $saveimage;
close IMAGE;
}

ฟู่วว ว์..

ไม่มีความคิดเห็น: