# Based on recipe 82: Get the temperature off a life weather page

def findTemperatureLive():

  # Get the weather page
  import urllib #Could go above, too

  connection=urllib.urlopen("http://www.bom.gov.au/cgi-bin/wrap_fwo.pl?IDN10035.txt")
  weather = connection.read()
  connection.close()

  #weatherFile = getMediaPath("bom_act_forecast.htm")
  #file = open(weatherFile,"rt")
  #weather = file.read()
  #file.close()

  # Find the Temperature
  curloc = weather.find("Max Today: ")
  if curloc <> -1:

    # Now, find the new line "\n" following the temp
    tempstart = curloc+10  # Position after "Max Today: "
    tempend = weather.find("\n", tempstart)
    print "Current temperature:",weather[tempstart+1:tempend]

  if curloc == -1:
    print "They must have changed the page format -- can't find the temp"


