In the spirit of TMTOWTDI, here's another way of doing it, which
only needs to make one localtime call. Of course, you
also have to store around a little extra data (the months), but it's probably worth it. More descriptive variable
names are always helpful too, of course. :)
my($hour, $mday, $mon, $year) = (localtime)[2..5];
my @months = qw/jan feb mar apr may jun
jul aug sep oct nov dec/;
$mday-- if $hour < 9;
printf "Location: http://www.userfriendly.org/cartoons/archives/%02d%s
+/%04d%02d%02d.html\n\n",
$year%100, $months[$mon], $year+1900, $mon+1, $mday;
(By the way: when posting code you should use the
<code> tags so that your code looks, well, like code.
Read more in Perl Monk Procedures.) | [reply] [Watch: Dir/Any] [d/l] |
while i presume this will work, i shall also assume you've
overlooked the fact that illiad likes to trip people up
with his cataloging system for the script. by my count
it has changed 4 times (maybe 3) since the start of UF,
therefore, while this code does make a nasty call to
lynx that could prolly be done better with lwp or something
it is a bit safer, less he change it again
$imagetag = 0;
open(INFILE, "lynx -source http://www.userfriendly.org/static/
+|");
while (<INFILE>) {
next if $image;
if (/.*(IMG ALT\=\"Latest Strip\" height\=219 width\=5
+76 BORDER\=0 SRC\=\"http:\/\/www.userfriendly.org\/cartoons\/archives
+\/.+<\/A>).*/) {
$imagetag = $1;
if ($imagetag =~ /.* ALT\s*=\s*"Latest Strip"
+.*/i) {
if ($imagetag =~ /.*(\/cartoons\/archi
+ves\/.+f).*/i) {
$image = $1;
$image =~ s/xuf/uf/;
`lynx -source http://www.userf
+riendly.org$image > ufieimage.gif`;
# i like jpgs, deal.
`convert ufieimage.gif ufieima
+ge.jpg`;
unlink("ufieimage.gif");
}
}
}
}
charlie schmidt
ishamael@themes.org
www.diablonet.net/~ishamael/
| [reply] [Watch: Dir/Any] [d/l] |
| [reply] [Watch: Dir/Any] |
I see a lot of lynx downloads of the gifs. Now I understand why we're getting them. Heh.
| [reply] [Watch: Dir/Any] |
Since I wrote all the UF systems, I've seen literally hundreds of these files go around.
There is a quite simple and complete view of the content:
wget http://www.userfriendly.org/cgi-bin/texhtml?form=uf/rdf&action=search&date=yyyymmdd
returns an rdf file. The date param is optional, and defaults to today. The action parameter is not optional nor is the form param.
There are other forms as well which change the output format. One of the output formats is "already parsed" but thats limited to our address blocks.
That file format is guaranteed not to change. The one mentioned here is scheduled to be deleted.
The only reason I have not done so already is because I'm lazy....
We'd of course ask that you use this for personal usage only.... | [reply] [Watch: Dir/Any] |
Duuh. Forgot to login.
The material from the Anonymous Monk above was mine.
Is there any way to "Take ownership" of a previous anon post?
| [reply] [Watch: Dir/Any] |
#!/usr/global/bin/perl
use File::Basename;
my $search_url = 'http://www.userfriendly.org/cgi-bin/texhtml?form=uf/
+rdf\&action=search';
my $comics_dir = '/home/user/.comics/';
my $url;
open(IN, "wget -q -O - $search_url |") or die $!;
while (<IN>) {
if (/Today\'s Strip/) {
<IN> =~ m|<link>(.*)</link>|;
$url = $1;
break;
}
}
my $gif = $comics_dir . basename($url);
system("wget -q -O $gif $url");
system("xv $gif");
| [reply] [Watch: Dir/Any] [d/l] |
#!/usr/global/bin/perl -w
use File::Basename;
my $search_url = 'http://www.userfriendly.org/cgi-bin/texhtml?form=uf/
+rdf\&action=search';
my $comics_dir = '/home/user/.comics/';
open(IN, "wget -q -O - $search_url |") or die $!;
while (<IN>) { last if /Today\'s Strip/; }
<IN> =~ m|<link>(.*)</link>|;
my $gif = $comics_dir . basename($1);
system("wget -q -O $gif $1");
system("xv $gif");
| [reply] [Watch: Dir/Any] [d/l] |