;; I was annoyed at http://www.ChangeDetect.com, so I wrote this. Use ;; this script, and when you get sick of it in twenty minutes, write a ;; real program, with real threading, and a real UI, and then give me ;; a copy. Tested on XEmacs 21.4. ;; Usage: UTSL. Hackery needed. ;; (c) 2003 Art Taylor (require 'url) (require 'md5) (setq output-buffer-name "*url-updates*") (defun get-new-hash (url) "Hash the page found at the given url." (md5 (let ((url-multiple-p nil)) (save-excursion (save-window-excursion (url-retrieve url))) (buffer-string url-working-buffer)))) (defun save-url-alist () "Save my-url-alist to the file." (with-temp-buffer (insert "(setf my-url-alist '" ) (prin1 my-url-alist (current-buffer)) (insert ") ") (write-region (point-min) (point-max) (expand-file-name "~/.check-url.el")))) (defun check-url-for-update (x) "Check the page at the url in the car of the cons cell for an update, comparing its hash to that in the cdr." (let ((url (car x)) (oldhash (cdr x)) (newhash (get-new-hash (car x)))) (if (not (string= oldhash newhash)) (progn (princ (concat (current-time-string) ":" url "\n") (get-buffer-create output-buffer-name)) (setf (cdr x) newhash))))) (defun check-updates () "Check all of the urls in my-url-alist for updates." (load-file (expand-file-name "~/.check-url.el")) (mapcar #'check-url-for-update my-url-alist) (save-url-alist)) (defun add-url (url) "Add the given url to my-url-alist and save to file." (if (not (assoc url my-url-alist)) (progn (setf my-url-alist (cons `(,url . "1") my-url-alist)) (save-url-alist)))) (load-file (expand-file-name "~/.check-url.el")) (add-url "http://lambda.weblogs.com") (add-url "http://www.astrogoth.com/~reeses/musing/index.html") (add-url "http://www.slashdot.org") (check-updates)