Just for fun: Get your daily Dilbert comic and display it. If you provide a directory name as argument, it'll be saved to dirname/dilbertyyyymmdd.gif where yyyymmdd is todays date.
package require Tk package require http package require base64 set um [http::geturl http://www.dilbert.com/] set b [split [http::data $um] "\n"] #set ln [lsearch -inline -glob $b "*ALT=?Today's Dilbert Comic*"] if 0 { set ln [lsearch -inline -glob $b "*ALT=?Today's Comic*"] } regexp {^.*IMG SRC=\"([^"]+)\".*$} $ln --> picurl http::cleanup $um set um [http::geturl http://www.unitedmedia.com$picurl] if {$argc && [file isdirectory [lindex $argv 0]]} { set today [clock format [clock seconds] -format "dilbert%Y%m%d.gif"] set fd [open $today w] fconfigure $fd -translation binary -encoding binary puts $fd [http::data $um] close $fd } set pic [base64::encode [http::data $um]] http::cleanup $um image create photo dilbert -data $pic label .l -image dilbert pack .l
Michael Jacobson: Also see Comic Server for some code to get a bunch of comic strips from uComics. Or you can check out (on windows only ~ sorry) in a TclKit application that servers the comics and display them in a embededd MSIE frame using optcl. Get the application here ... http://mywebpages.comcast.net/jakeforce/COMon!ics.kit (96kb). (I use this code in NewzPoint)
02. Aug. 2005: The Text for the Daily Dilbert comic changed. Replace the lsearch line with the following:
if 0 { set ln [lsearch -inline -glob $b "*ALT=?Today's Comic*"] }
RLH 20050802: I get the error:
if 0 { "Can't read "picurl": no such variable while executing "http::geturl http://www.unitedmedia.com$picurl" }
RS Have you applied the fix above? It worked for me after I did it.
RLH I had read the post wrong and thought it was fixed above. Works now and I have commented out the old line above and added the one that works.
escargo 3 Aug 2005 - Touched up the previous included text to make compatible with wish-reaper.