Page 1 of 1

Downloading from ImageShack.

Posted: Thu Aug 17, 2006 5:12 pm
by mart
Does anyone know of a programme for mass downloading of images from ImageShack?
I've tried Googling but given up.

Mart

Re: Downloading from ImageShack.

Posted: Thu Aug 17, 2006 6:15 pm
by Jacques
You need Perl with the mechanize module.

Then run this script in Perl:


#!/usr/bin/perl -w
use strict;
use WWW::Mechanize;

#Create an Object
my $mech = WWW::Mechanize->new();


foreach my $number ("0" .. "100") {
#Url to search images on.
my $url = "http://img301.imageshack.us/my.php?image=$number.jpg";

#Request webpage
$mech->get( $url );

#Search for links containing .jpg or .jpeg extensions
#in the url.
#Everything in between qr/ / is what to search for
#The . means any character usually but we use \ to escape it
# and make it literal. Then we did (jpe?g) which means to search for
#the text jpg or jpeg.
# The $ character means the end of the line/string.
# The i at the end means make everything case insensitive

my $link;
if ($link = $mech->find_link(tag => "a", url_regex => qr/\.(jpe?g)$/i)) {
$mech->get($link);

my $lurl = $link->url;

#Take done.php?l=img301 out of the URL and replace with img301/
$lurl =~ s/done\.php\?l\=img301\//img301\//;

#Save image to file
$mech->get( $lurl, ":content_file" => "$number.jpg");
}
else {
print "Image $number.jpg not found\n";
}
}


The server number on imageshack goes from 1-351


Oh and don't forget to say thank you.

Re: Downloading from ImageShack.

Posted: Fri Aug 18, 2006 4:59 am
by mart
Thank you.....even if you are taking the piss.

Mart

Re: Downloading from ImageShack.

Posted: Fri Aug 18, 2006 5:35 am
by Jacques
Taking the piss? Probably but there is a reason behind it - I help quite a few folks round here. Not many say 'thank you' and that is taking the piss. You'll find that they no longer get any help from me even if I can solve their problem at the click of a finger.

People like randyandy for instance will always get my help, others won't even get the time of day.

Incidentally don't use ActiveState use PXPerl if using windows, otherwise the script throws errors.

Re: Downloading from ImageShack.

Posted: Fri Aug 18, 2006 9:03 pm
by Snake Diamond
Jacques, I have Perl pre-Installed, as default, on my Web Server. How/where/what do I use to tell if I have the mechanize module? I've never used Pearl before, so I have no idea how to use it yet, LOL.


Re: Downloading from ImageShack.

Posted: Fri Aug 18, 2006 9:07 pm
by Snake Diamond
Oops, make that:

...I've never used Perl before, so I have no idea how to use it yet, LOL.

P.S. If I can figure out how to do/use Perl, thanks for that Script, (at present, I'm trying to extend my knowledge of Programming Languages) !grin!


Re: Downloading from ImageShack.

Posted: Sat Aug 19, 2006 5:41 am
by Jacques
To find out if you have it

If you don't, you can get it from here

And this explains how to install

The full Perl FAQ is here and of course the is

If you are OK with DOS and Linux you should pick it up fairly easily.


Re: Downloading from ImageShack.

Posted: Sat Aug 19, 2006 5:52 am
by Jacques
There is a nice tutorial on perl.com

Re: Downloading from ImageShack.

Posted: Sat Aug 19, 2006 8:38 pm
by Snake Diamond
Thanks Jacques, I will do a proper review of these tomorrow.

I did a quick look at this site, read the info on how to check, found the file listed... Shit, it has pages upon pages of text about what was installed, but I didn't find Mechanize, so I will see about that tomorrow.

Thanks again for the Info. I think I will continue learning PHP & MySQL for the moment, before starting with Perl. But yes, I do know DOS, I grew up on DOS, LOL.