use zUtil;

sub arcamax
{
    my $html = shift;
    my $outname = shift;
    my $sitename = shift;
    my ( @rValue ) = ();
    my ( $title, $url, $blurb );

    print "---------------------------- arcamax --------------------------\n";
    print "html: $html\n";

    # $html =~ s/&amp;/&/gixs;
    # $html =~ s/&gt;/>/gixs;
    # $html =~ s/&lt;/</gixs;
    print "hmtl: $html\n";

    while( $html =~ s/<figure class="comic">.*?<img.*?src="(.*?)".*?\/>//s )
    {
        $date=$2;
        $image=$1;

        print "arcamax Found image: $image\n";

        push @rValue, {
            'date' => $date,
            'description'  => $image,
        };
    }

    $resultHash = $rValue[0];
    $fetch_img=$resultHash->{'description'};

    $fetch_imge =~ s/http:\/\/www.dilbert.com\/strip\///gisx;

    if ( !($sitename =~ /^$/) ) {
        $fetch_img =~ s/$sitename//gisx;
    }
    print "running: wget \"$fetch_img\" -O /usr/local/zeddweb/zii/scratch/$outname";

    system( "wget \"$fetch_img\" -O /usr/local/zeddweb/zii/scratch/$outname");
    system( "chmod", "ugo+rw", "/usr/local/zeddweb/zii/scratch/$outname");

    #exit 1;

    return @rValue;
}

return 1;

