Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

function that gets the current temperature

import urllib # We need to import the URL library

def findTemperatureLive():
  #Just like opening, reading and then closing a file
  connection = urllib.urlopen("http://www.ajc.com/weather")
  weather = connection.read()
  connection.close()

  # Now that the contents of the web page are in a string, finding
  # the temperature is the same as it was for the version where the
  # string was read from a local HTML file.
  weather.find("Currently")
  if currentlyIndex <> -1:
    degreeIndex = weather.find("<b>&deg;", currentlyIndex)
    lessThanIndex = weather.rfind(">", 0, degreeIndex)
    return weather[lessThanIndex + 1:degreeIndex]
  if currentlyIndex == -1:
    return “Can't find the temp"



Link to this Page