import time import urllib now = time.time() localtime = time.localtime(now) year = localtime[0] month = localtime[1] date = localtime[2] # Search the USNO AAD (US Navel Observatory Astronomical Applications # Department) site to get Sun/Moon Data for current day. # First, encode the data. data = urllib.urlencode({"FFX" : "1", "ID" : "AA", "xxy" : year, "xxm" : month, "xxd" : date, "st" : "SC", "place" : "Charleston"}) # 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 s