Does anyone know of a programme for mass downloading of images from ImageShack?
I've tried Googling but given up.
Mart
Downloading from ImageShack.
Re: Downloading from ImageShack.
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.
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.
quis custodiet ipsos custodes
Re: Downloading from ImageShack.
Thank you.....even if you are taking the piss.
Mart
Mart
Re: Downloading from ImageShack.
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.
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.
quis custodiet ipsos custodes
-
Snake Diamond
- Posts: 1889
- Joined: Fri Jul 14, 2017 2:40 am
Re: Downloading from ImageShack.
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.
Snake Diamond,
Fangs that bite!
Fangs that bite!
-
Snake Diamond
- Posts: 1889
- Joined: Fri Jul 14, 2017 2:40 am
Re: Downloading from ImageShack.
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!
...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!
Snake Diamond,
Fangs that bite!
Fangs that bite!
Re: Downloading from ImageShack.
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.
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.
quis custodiet ipsos custodes
-
Snake Diamond
- Posts: 1889
- Joined: Fri Jul 14, 2017 2:40 am
Re: Downloading from ImageShack.
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.
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.
Snake Diamond,
Fangs that bite!
Fangs that bite!