Created
May 7, 2015 17:04
-
-
Save cuevasclemente/c93fffd6cdaa62be0f85 to your computer and use it in GitHub Desktop.
Weather App in Clisp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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