/*#!rx ARexx script to download todays comic from a few places. ATM get User Friendly, Dilbert and Citizen Dog. Uses regex parsing, so should be really easy to add any comic you like. If you add some, send them back here and I'll post the parsing rules on this page for others to use. Near the bottom, hard:projects/pcommpalm/giftopalm.arexx needs to be changed to point to the giftopalm.arexx script. This script converts the gif to IMGV, and copies it to my install spool directory. - Nicholas NO PURPOSE. NO WARRANTY. NO OWNER. */ options results l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit l="regex.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit l="rexxtricks.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit /* User Friendly */ pointerpage = "http://www.userfriendly.org/static/" comicbit = '/cartoons/archives/99may/xuf[0-9]+[.]gif' firstre = '< *IMG [[:print:]]+SRC *= *"?[[:print:]]+'comicbit'"? *[[:print:]]+>' host = 'http://www.userfriendly.org' hint = "archives" if ~GrabThatComic() then call GrabThatComic() /* Dilbert */ pointerpage = "http://www.unitedmedia.com/comics/dilbert/" comicbit = '/comics/dilbert/archive/images/dilbert[0-9]+[.]gif' firstre = '< *A +HREF *= *"?[[:print:]]+'comicbit'"? *>' host = 'http://www.unitedmedia.com/' hint = "dilbert/archive/" if ~GrabThatComic() then call GrabThatComic() /* Citizen Dog */ pointerpage = "http://www.uexpress.com/ups/comics/cd/index.html" comicbit = '/ups/comics/cd/strips/cd[0-9]+[.]gif' firstre = '< *A +HREF *= *"?[[:print:]]+'comicbit'"? *>' host = 'http://www.uexpress.com' hint = "strips" if ~GrabThatComic() then call GrabThatComic() exit GrabThatComic: tmpfile = CreateTempFile() address command "wget "pointerpage" -O "||tmpfile||".html" if ~open(file,tmpfile||'.html',R) then exit do until eof(file) line = readln(file) if index(line,hint) = 0 then iterate match = rematch(firstre,line,'ICASE',pmatch) if match = 0 then do line = substr(line,pmatch.so+1,pmatch.eo-pmatch.so) say line match = rematch(comicbit,line,'ICASE',pmatch) url = host || substr(line,pmatch.so+1,pmatch.eo-pmatch.so) end if match = 0 then break end call close(file) say url if url = "URL" then return 0 "wget "||url" -O "||tmpfile||".gif" "rx hard:projects/pcommpalm/giftopalm.arexx "||tmpfile||".gif" "delete "||tmpfile||".gif" return 1