Ejemplo n.º 1
0
def get_plays(year):
    """
    Scrape the standard plays for given year
    :param year: year to scrape
    :return: yields dicts for each play
    """
    for week in range(1, 18):
        w = Week(year, week)
        for game_id in w.get_game_ids():
            p = PlayByPlay(game_id)
            for play_datum in p.get_play_data():
                yield play_datum
        logger.info("Completed week {0}".format(week))
Ejemplo n.º 2
0
    def _parse_plays(self, html):
        """
        Parses the plays for this drive
        :param html: html for the drive
        :return: yields the plays in the drive
        """
        for play in html.find_all('li'):
            header = play.find('h3').text.strip()
            text = play.find('p').text.strip()

            if _should_skip(header):
                continue

            try:
                yield parse_play(header, text, self._offense)
            except Exception as e:
                logger.info("Error parsing: {header} {text} because {error}"
                            .format(header=header, text=text, error=e.message))
                yield None