hola,
i'd highly recommend that you check out
http://mah.everybody.org/hacks/perl/getcomics.txt,
(core by Mark Hershberger, adapted by J.Stoffel)
a spritely wee script which downloads images intelligently;
it is almost directly applicable to your problem of finding new images.
the business end of how it determines newness is in the following snippet, which could pretty much directly be
copied & pasted to achieve what you want. rc is the request obtained from a lwp::useragent
# Get the MD5 fingerprint of the file.
open(IMAGE, "<$imagedir/$imagename") || die "Can't open $imagedir/$ima
+gename\n";
$context = new MD5;
$context->MD5::reset();
$context->MD5::add(<IMAGE>);
$filehash = $context->hexdigest();
close(IMAGE);
# Get the MD5 fingerprint of the new picture
open(TEMP, ">/tmp/getcomics.$$") || die "Can't open tempfile\n";
print TEMP $rc->content();
close(TEMP);
open(TEMP, "</tmp/getcomics.$$") || die "Can't open tempfile\n";
$context->MD5::reset();
$context->MD5::add(<TEMP>);
$newhash = $context->hexdigest();
close(TEMP);
unlink "/tmp/getcomics.$$";
# See if the old info is different from the new.
if( $newhash ne $filehash ) {
# strut your funky stuff *here*
}
hope that helps,
...wufnik
-- in the world of the mules there are no rules --
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.