User:Inge Hoonte/shippingnews: Difference between revisions
Inge Hoonte (talk | contribs) No edit summary |
Inge Hoonte (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
CODE: | CODE: currently linked to the marinetraffic log. Want to improve and specify location to traffic map to other sources. What else happened in this location? Pull from web, and perhaps shipping logs. | ||
#!/usr/bin/env python | #!/usr/bin/env python |
Revision as of 13:37, 17 February 2011
CODE: currently linked to the marinetraffic log. Want to improve and specify location to traffic map to other sources. What else happened in this location? Pull from web, and perhaps shipping logs.
#!/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>
"Data is provided for informational reasons only and is not related by any means to the safety of navigation. All rights reserved. No part of MarineTraffic may be copied, reproduced or retransmitted in any material and form or by any other means, without the prior written permission of the Scientific Head of MarineTraffic project."
For now I'm not putting the cgi script link here, because I might want to work with MarineTraffic to get to data better.