#!/usr/bin/perl
# Retrieve all pics from
# http://peachyforum.com/t/real-home-imagevenue-sets-pls-do-not-use-ie-for-viewing-273028.aspx
sub getPage {
my $url = shift;
my $content = `curl -- '$url' 2>/dev/null`;
return $content;
}
sub extractImage {
my $url = shift;
my $content = getPage($url);
my $server = $url;
$server =~ m/(http:\/\/img[0-9]+\.imagevenue\.com)/;
$server = $1;
my @lines = split /\>/, $content;
for (my $l=0; $l<scalar(@lines); $l++) {
if (@lines[$l] =~ m/onLoad="scaleImg\(\);".+ SRC="(.+\.je?pg)".*alt=/) {
return "$server/$1";
}
}
return "notfound";
}
my $currentPost = 0;
my $baseDir = `pwd`;
chomp($baseDir);
for (my $p=1; $p<36; $p++) {
my $content = getPage("http://peachyforum.com/t/real-home-imagevenue-sets-pls-do-not-use-ie-for-viewing-273028/$p.aspx");
my @lines = split /\>/, $content;
my $currentPost = 0;
my $currentPhoto = 0;
mkdir($baseDir."/".$p);
for (my $l=0; $l<scalar(@lines); $l++) {
if (@lines[$l] =~ m/ForumPostContentText/) {
$currentPost++;
$currentPhoto=0;
mkdir($baseDir."/".$p."/".$currentPost);
next;
}
if (@lines[$l] =~ m/a href="(http:.+\.imagevenue\.com\/img\.php\?image=.+)".*target="_blank"/) {
my $imageUrl = extractImage($1);
if ($imageUrl ne "notfound") {
print "Image URL $imageUrl\n";
`wget -c --output-document=$baseDir/$p/$currentPost/img_$currentPhoto.jpg '$imageUrl'`;
$currentPhoto++;
}
}
}
}