User:Inge Hoonte/shippingnews: Difference between revisions

From XPUB & Lens-Based wiki
(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...")
 
No edit summary
Line 1: Line 1:
CODE:
  #!/usr/bin/env python
  #!/usr/bin/env python
  #-*- coding:utf-8 -*-
  #-*- coding:utf-8 -*-
Line 52: Line 54:
   
   
  '''
  '''
web page: http://pzwart3.wdka.hro.nl/~ihoonte/cgi-bin/script.cgi?a=rotterdam%2C+nl

Revision as of 13:33, 17 February 2011

CODE:

#!/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>


web page: http://pzwart3.wdka.hro.nl/~ihoonte/cgi-bin/script.cgi?a=rotterdam%2C+nl