Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

UserFriendly.org Full Size version forwarder :)

by ash (Monk)
on Mar 30, 2000 at 11:46 UTC ( [id://6522]=sourcecode: print w/replies, xml ) Need Help??
Category: Fun/Entertainment
Author/Contact Info Ask Solem Hoel <ask@NOSPAM.trancescape.org>
Description: You hate having to load the small version of userfriendly for then to click on the link to the fullsize one? Well. This script forwards you directly to todays full size userfriendly strip :) But since userriendly doesn't update before 9 a.m in norway, i've inserted this little line: ($a[2]<9)&&$a[3]--; so that you'll be forwarded to yesterdays strip if it's not up yet. Change the 9 to your timezone :)
#!/usr/bin/perl
@a=localtime;
$a[4]++;$a[4]=~s/(\d)/0$1/;
$y=$a[5]+1900;
($Y=$y)=~s#(\d\d)(\d\d)#$2#;
($a[2]<9)&&$a[3]--;
(length($a[3])<2)&&($a[3]="0$a[3]");
($b=lc(localtime(time)))=~s/([\w]{3}\s){2}//;
($b=$1)=~s/\s//;
print("Location: http://www.userfriendly.org/cartoons/archives/${Y}${b
+}/${y}$a[4]$a[3].html\n\n");
Replies are listed 'Best First'.
RE: UserFriendly.org Full Size version forwarder :)
by btrott (Parson) on Mar 30, 2000 at 12:26 UTC
    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.)
RE: UserFriendly.org Full Size version forwarder :)
by ishamael (Beadle) on Apr 28, 2000 at 17:43 UTC

    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/
      I see a lot of lynx downloads of the gifs. Now I understand why we're getting them. Heh.
RE: UserFriendly.org Full Size version forwarder :)
by Anonymous Monk on Aug 08, 2000 at 04:39 UTC
    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....
      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?
      #!/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");
        #!/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");

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: sourcecode [id://6522]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-03-19 06:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found