Skip to content

Instantly share code, notes, and snippets.

@cuevasclemente
Created May 7, 2015 17:04
Show Gist options
  • Save cuevasclemente/c93fffd6cdaa62be0f85 to your computer and use it in GitHub Desktop.
Save cuevasclemente/c93fffd6cdaa62be0f85 to your computer and use it in GitHub Desktop.
Weather App in Clisp
(require :drakma)
(require :cl-ppcre)
(defvar *weather-url* "http://forecast.weather.gov/MapClick.php?zoneid=NYZ075&TextType=1"
"The url we'll be going to, to get the weather information")
(defun starts-with (regexp string)
"Checks to see if a string starts
with the given regexp"
(eq (search regexp string) 0))
; Gets the weather
; from nws
; and parses away the HTML
; in the hackiest way possible
(defun get-weather ()
(let ((response (drakma:http-request *weather-url*)))
(let ((input-stream (make-string-input-stream response)))
; We
(loop for line = (read-line input-stream nil)
while line do (if
(or
(starts-with "<b>" line) (starts-with "</table>" line))
(format t "~a ~%" (progn (dolist (x (list "<\/table>" "<\/b>" "<b>" "<br>"))
(setq line (cl-ppcre:regex-replace-all "\<.*?\>" line "")))
(eval line))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment