User:Inge Hoonte/shippingnews
< User:Inge Hoonte
Revision as of 13:20, 17 February 2011 by Inge Hoonte (talk | contribs) (Created page with " #!/usr/bin/env python #-*- coding:utf-8 -*- print "Content-Type: text/html" print import urllib2, json, sys, cgi, urllib import cgitb; cgitb.enable() args = cgi.FieldSto...")
#!/usr/bin/env python #-*- coding:utf-8 -*- print "Content-Type: text/html" print import urllib2, json, sys, cgi, urllib import cgitb; cgitb.enable() args = cgi.FieldStorage() t = args.getvalue('a', ) #command line is with argv[0], cgi.FieldStorage() = for cgi url = 'http://maps.googleapis.com/maps/api/geocode/json?address='+urllib.quote(t)+'&sensor=true' #urllib.quote allows you to enter spaces and it interprets it as url code. eg space=%2C f = urllib2.urlopen(url) data = json.load(f) for r in data['results']: print "(%s, %s)" % (r['geometry']['location']['lat'], r['geometry']['location']['lng']) print <form action= method='get'> <input type='text' value='type location here' name='a' /> <input type='submit' value='submit'> </form> <script type="text/javascript"> width='80%'; height=400; border=1; notation=false; shownames=false; latitude= print r['geometry']['location']['lat'] print ; longitude= print r['geometry']['location']['lng'] print ; zoom=10; maptype=3; trackvessel=13; fleet=; remember=false; </script> <script type="text/javascript" src="http://www.marinetraffic.com/ais/embed.js"></script>