# This code demonstrates how to load the index.html page from the
# AJC and find the current temp text. (Converting it to an INT).
# Using Python3
#
# Copyright Jay Summet
import urllib.request
response = urllib.request.urlopen("http://www.ajc.com/")
html = response.read()
text = str(html) #Convert the bytes to a string.
#The temp is followed by a degree sign, which is easy to search for!
endOfTemp = text.find("°")
#One we find the index of what is after the temp, we need to know
#the index of what is in front of it.
index = endOfTemp
ch = text[index]
while ch != ">":
index = index - 1
ch = text[index]
#Add one to get the first digit of the temp.
startOfTemp = index + 1
textTemp = text[startOfTemp:endOfTemp]
tempInt = int(textTemp)
print( "temp is:", textTemp)