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/dilbert'''yyyymmdd'''.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*"] 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 [file join [lindex $argv 0] $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 ''(This has already been done; the [if 0 {] wrapper was added to make the version grabbed by [wish-reaper] operate correctly)'': 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]. [RLH] Why would you put "if 0" around the error message I was getting? ''[escargo] 3 Aug 2005'' - The reaping tools ([wiki-reaper], [wish-reaper], and [XotclIDE]) can extract what they think is '''code''' from the wiki pages. The definition of '''code''' is simple; too simple in several cases. One such case is the error message you copied into the page. When reaped, that error message becomes a line of code, the last one in the file. When wish tries to run the code, the error message causes wish to throw an error. By using the [if 0 {] wrapper, wish will ignore it. The text can stay on the page, somewhat distorted, but still there; the reaped page will still execute, though it has some dead code. It's a compromise. [RLH] Cool. I wasn't complaining just wondering and now the cat is satisfied. :) CJL 11 July 2006 - The presence (and validity) of the optional directory name argument determined whether a file was written, but didn't affect where it was written. Fixed. ---- ''See also:'' * [Web Scraping] ---- [Category Community] | [Category Example] | [Category Internet]