Created
April 10, 2013 06:03
-
-
Save logie17/5352170 to your computer and use it in GitHub Desktop.
Weather Proxy via Python
This file contains hidden or 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
| #! /usr/bin/env python | |
| import urllib, cgi, random, string | |
| cgi_params = cgi.FieldStorage() | |
| lat = cgi_params.getvalue('lat') or '42.3265152' | |
| lon = cgi_params.getvalue('lon') or '-122.87559490000001' | |
| unit = cgi_params.getvalue('unit') or 0 | |
| lg = cgi_params.getvalue('lg') or 'english' | |
| fcst = cgi_params.getvalue('fcsttype') or 'dwml' | |
| #nocache = "".join( [random.choice(string.digits) for i in xrange(8)] ) | |
| nocache = 123 | |
| params = urllib.urlencode({'lat': lat, 'lon':lon, 'unit':unit, 'lg': lg, 'FcstType': fcst, 'nocache': nocache}) | |
| response = urllib.urlopen("http://forecast.weather.gov/MapClick.php?%s" % params) | |
| print "Content-Type: application/xml" | |
| print response.read() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment