import http.client import datetime import time gameIdList = [] todayDate = time.strftime("%m/%d/%Y", time.strptime(str(datetime.date.today()), "%Y-%m-%d")) #Format m/d/Y #Request a connection from nhl.com and get body. conn = http.client.HTTPConnection("www.nhl.com") conn.request("GET", "/ice/schedulebyday.htm?date=" + str(todayDate)) requestForGames = conn.getresponse() #Tranform bytes to str and encode it. dataForGames = str(requestForGames.read(), encoding='utf8') #Find the first occurence. i = dataForGames.find("preview.htm?id=2011") while i != -1: #Append the game id to the list. gameIdList.append(dataForGames[i:i+25].replace("preview.htm?id=" + str(datetime.date.today().year), '')) #Find the next occurence. i = dataForGames.find("preview.htm?id=2011", i+30) print("end") conn.close()