#!/usr/bin/perl
#
# Image/Script Ninja by Pete
# Takes URLs and prints the locations of images (and optionally downloads the
# images) and the scripts found on the pages. 'isninja.pl --help' for more information.
# Use it while you can, for tomorrow it will be illegal.
print "Starting Image/Script Ninja...\n\n\n";
# Make sure the user supplied the correct arguments and didn't specify '--help'.
if (@ARGV < 1 || "@ARGV" =~ /--help/) {
print "Usage:\nisninja.pl [--getimages] url1 [url2, url3...]\n";
print "URL(s) must end in a filename (*.html, etc.) or a trailing slash.\n";
print "--getimages downloads the image instead of only printing its URL.\n";
exit;
}
# See if user wanted to save the images
if ("@ARGV" =~ /--getimages/) {
$getimages = 1;
}
else {
$getimages = 0;
}
# Go through each URL
for ($loop = 0; $loop < @ARGV; $loop++) {
# Make sure it's not the argument!
if ($ARGV[$loop] eq "--getimages") {
next;
}
# Grab the file
@file = `wget $ARGV[$loop] --output-document=-`;
# To keep everything seperate
print "\n\nResults from $ARGV[$loop]...\n";
$scrnum = 0;
$imgnum = 0;
# Check each line
for ($line = 0; $line < @file; $line++) {
# Is there an image?
if ($file[$line] =~ /]/, $file[$line]);
for ($loop2 = 0; $loop2 < @fs; $loop2++) {
if ($fs[$loop2] =~ /scr/i) {
@top = split(/\"/, $fs[$loop2]);
for ($loop3 = 1; $top[$loop3 - 1] !~ /src/i; $loop3++) {
;
}
$tmp = $ARGV[$loop];
$tmp2 = chop($tmp);
while ($tmp2 ne "/") {
$tmp2 = chop($tmp);
}
$imgurl = $tmp.'/'.$top[$loop3];
$imgnum++;
print "Image #$imgnum; $imgurl\n";
if ($getimages) {
system("wget $imgurl");
}
}
}
}
# Is there a script?
if ($file[$line] =~ /
$scrnum++;
print "===Script #$scrnum===\n";
# The nested stuff is here in case anyone uses a script
# to print otu another script or something.
$nested = 0;
while ($line < @file) {
print $file[$line];
if ($file[$line] =~ /