I am trying to write a python script which uses the "urllib" and "re" libraries to extract weather forecast information off a html page, but I cannot seem to get any values returned, could anybody help me?
import urllib
import re
url = ('http://www.metoffice.gov.uk/public/weather/forecast/gcptz5sys')
htmlfile = urllib.urlopen(url)
htmltext = htmlfile.read()
regex =('<span title="Maximum daytime temperature" data-c="10" data-f="50">(.+?)<sup>°C</sup></span>')
pattern = re.compile(regex)
temp = re.findall(pattern,htmltext)
print (temp)
I am using Python 2.7 by the way...