All pastes #737452 Raw Edit

imageshack.pl

public text v1 · immutable
·published 2007-10-15 13:14 UTC
rendered paste body

#!/usr/bin/perl
# Bsartek Imageshack

use WWW::Mechanize;
use Mac::Glue ':all';

my $glue = new Mac::Glue 'Finder';
our $mecha = WWW::Mechanize->new();

sub get_img_link
  {
  print STDERR "\n";
  my $iterator=1;
TRYAGAIN:
  eval
        {
        print STDERR "$_ -> attempt $iterator : uploading.\n";
        $mecha->get("http://www.imageshack.us/");
        $mecha->form_number(3);
        $mecha->field('fileupload' => $_);
        $mecha->submit();
        $mecha->follow_link( text => 'Show', n => 1 );
        my @im = $mecha->images();
        print STDERR "$_ -> attempt $iterator : successfully uploaded.\n";
        our $url = $im[1]->url();
        };
  if ($@)
        {  print STDERR "\n$_ -> attempt $iterator : failed.\n";
        return if( $iterator gt 3);
        $iterator++;
        goto TRYAGAIN;}
  return ($url."\n");
  }

my @links;
foreach (@ARGV)
  {
  push @links,get_img_link($_);
  }