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

Topic attachments
I Attachment Action Size Date Who Comment
Compressed Zip archivetar autopost.tar.tar manage 80.0 K 14 Jan 2002 - 19:24 MattWalsh Perl AutoPost script from James Marshall
Topic revision: r3 - 30 Apr 2002 - MattWalsh
 
This site is powered by the TWiki collaboration platformCopyright © 2008-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback