Last updated on: January 17, 2018, 10:07:29
The weather status on the front page is periodically obtained via FTP from weather.noaa.gov. This is the code do retrieve it:
(defun get-weather (site) (let ((str (net.ftp.client:open-ftp-stream (format nil "data/observations/metar/decoded/~a.TXT" (string-upcase (string site))) :host "tgftp.nws.noaa.gov" ;;"weather.noaa.gov" :user "anonymous" :password "email@example.com" :mode :text :passive t))) (unwind-protect (let ((buffer (make-string 5000))) (let ((i 0)) (loop (let ((end (read-sequence buffer str :start i))) (if* (<= end i) then ;; end of file (return) else (setq i end)))) (subseq buffer 0 i))) ;; cleanup (close str))))Here is an example usage:
cl-user(3): (get-weather "koak") "Oakland, Metro Oakland International Airport, CA, United States (KOAK) 37-43-10N 122-14-07W 26M Jan 05, 2003 - 04:53 PM EST / 2003.01.05 2153 UTC Wind: from the WNW (290 degrees) at 8 MPH (7 KT):0 Visibility: 9 mile(s):0 Sky conditions: mostly clear Temperature: 57.9 F (14.4 C) Dew Point: 52.0 F (11.1 C) Relative Humidity: 80% Pressure (altimeter): 30.19 in. Hg (1022 hPa) ob: KOAK 052153Z 29007KT 9SM FEW010 14/11 A3019 RMK AO2 SLP223 T01440111 cycle: 22 "Sky conditions and Temperature are then parsed from the above and displayed on the main page.
Last updated on: Monday, August 02, 2004 14:20 GMT+8 by e40 (at) known [dot] net.