Last grabbed image:
Update Now!
Still To do:
- Have ImageMagick stick the time & date, maybe HMB on it, credit to heavens above site
- and maybe have ImageMagick scale it down to a thumbnail
- have the refresh script tag
- have the script return back the autorefresh
#!/usr/bin/python
import re
import urllib
# Looking for tags like this
# <A HREF="main.asp?Session=kebgchcjdmacblafibbkdpme">
# make sure we do a 'greedy' match (the '?' in .*?)
sessionMatcher = re.compile('^.*Session\=(.*?)(\"|\&).*$')
# Session=kebgchcjdmacblhaonpeehfm"
# Prepare the POST parameters
params = urllib.urlencode({'UserName' : 'some_user', 'Password':'blah'})
# Open a connection the POST parameters
f = urllib.urlopen("http://www.heavens-above.com/processlogon.asp", params)
# Read the page in one line at a time
for thisLine in f.readlines():
# Scan for our regular expression
matchResult = sessionMatcher.match(thisLine)
# If the expression matches, extract the part we want
if matchResult:
mySession = matchResult.group(1)
f.close()
if not mySession:
print "no session!"
exit(1)
else:
print "Ready with session %s" % mySession
# Trying to match... IMG SRC="wholeskychart.exe?Lat=37.464&Lng=-122.428&Date=37378.2360416667&BW=0&WIDTH=500&HEIGHT=500&SL=0&SN=0" WIDTH=500 HEIGHT=500
chartURLMatcher = re.compile('^.*\<.*\"(.*wholeskychart.exe.*Date.*?)\&.*\>.*$')
f = urllib.urlopen("http://www.heavens-above.com/skychart.asp?Session=%s" % mySession)
for thisLine in f.readlines():
# Scan for our regular expression
matchResult = chartURLMatcher.match(thisLine)
# If the expression matches, extract the part we want
if matchResult:
myChartURL = matchResult.group(1)
print "Match! %s" % myChartURL
f.close()
if not myChartURL:
print "no chart URL!"
exit(1)
else:
print "Ready with chart URL: %s" %myChartURL
f = urllib.urlopen("http://www.heavens-above.com/%s&%s" %(myChartURL, 'BW=0&WIDTH=1000&HEIGHT=1000&SL=1&SN=1'))
# Throw out the first few lines to get rid of the mime junk
f.readline()
f.readline()
f.readline()
theFile = f.read()
f.close()
f = open("/home/httpd/twiki/pub/Main/AutomatedPythonFormPosterPageGrabber/sky_image.gif", 'w')
f.write(theFile)
f.close()
--
MattWalsh - 12 Jan 2002