def get_data(html): soup = BeautifulSoup(html, 'html.parser') data = [] # data in all table rows inside div#allPlays>table for tr in soup.find(id='allPlays')('tr'): (period, team, eventName, eventDesc, vid) = [util.clean_str(td.text) for td in tr('td')] r = IceTrackerRow() if period == 'Shootout': r.period = 5 r.time = None eventName = 'Shootout ' + eventName else: period, time = period.split(' ') r.period = util.get_numeric_period(period) r.time = time if len(team) == 0: team = None r.team = team # period end should really have an event type if eventDesc in ('shootout complete', 'period end'): eventName = 'Period End' r.event_type = eventName r.event_description = eventDesc r.details = event_handlers.handler[eventName](eventDesc) data.append(r) return data
def get_faceoff_data(text): text = util.clean_str(text) if len(text) == 0: return [0,0] totals = text.split(' ')[0] return [int(i) for i in totals.split('-')[0:2]]