All pastes #2093711 Raw Edit

Unnamed

public python v1 · immutable
#2093711 ·published 2011-11-11 02:43 UTC
rendered paste body
import http.clientimport datetimeimport timegameIdList = []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()