Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

perl : batch image get for 4chan

Name: kumo 2012-05-17 20:55

#!/usr/bin/perl
#2012-0517-2030
use WWW::Mechanize;
sub bash {my @args = ( "bash", "-c", shift); system(@args);}

my $url = $ARGV[0];
my $prefix = "(.*)//images.4chan.org/(.*)/src/(.*)";

my $mech = WWW::Mechanize->new();
$mech->get( $url );
my @links = $mech->links();

foreach my $link (@links) {
        my $_ = $link->url();
        if ($_ =~ (m/$prefix/)) {
                s!//!http://!;
                if ($_ ne $last_url) {bash("wget -nc $_");}
                $last_url = $_;
}       }

Name: kumo 2012-05-17 22:58

how about:

#!/usr/bin/perl
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
$mech->get( $ARGV[0] );
my @links = $mech->links();
foreach my $link (@links) {
        my $_ = $link->url();
        if ($_ =~ (m!(.*)//images.4chan.org/(.*)/src/(.*)!)) {
                s!//!http://!;
                if ($_ ne $last_url) {
                $output_filename = $_;
                $output_filename =~ s!(.*)/src/!!;
                unless (-e $output_filename) {$mech->get ( $_ );
                        $mech->save_content("$output_filename");}
                $last_url = $_;
}       }       }

?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List