#!/usr/bin/perl # Autopr0n Download - Script to download images from autopr0n.com use LWP::Simple; use LWP::UserAgent; use HTTP::Request; use HTTP::Request::Common; use HTTP::Headers; # TODO: Set referer and user-agent { $|++; my $UA = LWP::UserAgent->new(agent => "Kill-O-Mat/1.0", timeout => 60); $UA->cookie_jar({file => "cookie.txt"}); print "Downloading AutoPr0n Page... "; my $AP = $UA->get("http://www.autopr0n.com/", referer => "http://www.autopr0n.com/"); die "Couldn't get autopr0n webpage: ".$AP->code."\n" unless $AP->code == 200; print "Done\n"; print "Extracting Links... "; my @PageLinks = $AP->content =~ m##g; print "Done\n"; foreach $PageLink (@PageLinks) { print "Downloading Page: $PageLink ... "; my $Page = $UA->get($PageLink, referer => "http://www.autopr0n.com/"); if ($Page->code == 200) { print "Done\n"; my @ImageLinks = $Page->content =~ m#href="([^"]*?\.jpg)"#gi; # TODO: Use URI to see if they are absolute, etc... for $ImageLink (@ImageLinks) { my $Source = URI->new_abs($ImageLink, $PageLink); print "Downloading Image: $Source ... "; my $Destination = $Source; $Destination =~ tr#/#\|#; if (-e $Destination) { print "File Already Exists\n"; } else { my $Image = $UA->request(GET($Source, referer => $PageLink), $Destination); if ($Image->code == 200) { print "Done\n" } else { print "Failed: ".$Image->code."\n"; unlink $Destination; } } } } else { print "Failed: ".$Page->code."\n"; } } }