(client, url, _id)
Coroutine that parses yearly data for a team and saves it to the db
Coroutine that parses yearly data for a team and saves it to the db
Coroutine that parses yearly data for a team and saves it to the db
async def parse_year(client, url, _id):
    '''
    Coroutine that parses yearly data for a team and saves it to the db
    '''
    content = await get_page(client, url)
    soup = BeautifulSoup(content, 'lxml')
    tables = soup.find_all('table')
    for table in tables:
        rows = table.find_all('tr', class_='datarow')
        for row in rows:
            tds = row.find_all('td')
            date = tds[0].text.strip()
            against = tds[1].text.strip()
            try:
                against_id = re.search(r'\d+', tds[1].a.get('href'))
                against_id = against_id.group(0)
            except AttributeError:
                against_id = ''
            score = tds[2].text.strip()
            try:
                boxscore = tds[2].a.get('href')
            except AttributeError:
                boxscore = ''
            type_ = tds[3].text.strip()
            # TODO save to db
            s = '------------------\n{}\n{}\n{}\n{}\n-------------'.format(url, date, against_id, score)
            print(s)
async def parse_year ( client , url , _id ) : content = await get_page ( client , url ) soup = BeautifulSoup ( content , 'lxml' ) tables = soup . find_all ( 'table' ) for table in tables : rows = table . find_all ( 'tr' , class_ = 'datarow' ) for row in rows : tds = row . find_all ( 'td' ) date = tds [ 0 ] . text . strip ( ) against = tds [ 1 ] . text . strip ( ) try : against_id = re . search ( r'\d+' , tds [ 1 ] . a . get ( 'href' ) ) against_id = against_id . group ( 0 ) except AttributeError : against_id = '' score = tds [ 2 ] . text . strip ( ) try : boxscore = tds [ 2 ] . a . get ( 'href' ) except AttributeError : boxscore = '' type_ = tds [ 3 ] . text . strip ( ) # TODO save to db s = '------------------\n{}\n{}\n{}\n{}\n-------------' . format ( url , date , against_id , score ) print ( s )