import time import urllib now = time.time() localtime = time.localtime(now) year = localtime[0] month = localtime[1] date = localtime[2] state = "SC" city = "Charleston" # Search the USNO AAD (US Navel Observatory Astronomical Applications # Department) site to get Sun/Moon Data for current day. # * Need to email site and set up a different "ID" * # First, encode the data. data = urllib.urlencode({"FFX" : "1", "ID" : "AA", "xxy" : year, "xxm" : month, "xxd" : date, "st" : state, "place" : city}) # Now get that file-like object again, remembering to mention the data. f = urllib.urlopen("http://aa.usno.navy.mil/cgi-bin/aa_pap.pl", data) # Read the results back. s = f.read() f.close() # print page. print s