()
Scrapes the teams and adds them to the db
Scrapes the teams and adds them to the db
Scrapes the teams and adds them to the db
def scrape():
    '''
    Scrapes the teams and adds them to the db
    '''
    req = requests.get(BASE_URL+TEAM_URL)
    soup = BeautifulSoup(req.content, 'lxml')
    links = soup.find_all('a', href=re.compile(r'/data/ncb/teams/team\d+\.html'))
    rows = []
    for link in links:
        _id = re.search(r'\d+', link.get('href'))
        _id = _id.group(0)
        rows.append((_id, link.text, link.get('href')))
    with sqlite3.connect(DB) as conn:
        cursor = conn.cursor()
        cursor.executemany('insert into teams values (?,?,?);', rows)
        conn.commit()
def scrape ( ) : req = requests . get ( BASE_URL + TEAM_URL ) soup = BeautifulSoup ( req . content , 'lxml' ) links = soup . find_all ( 'a' , href = re . compile ( r'/data/ncb/teams/team\d+\.html' ) ) rows = [ ] for link in links : _id = re . search ( r'\d+' , link . get ( 'href' ) ) _id = _id . group ( 0 ) rows . append ( ( _id , link . text , link . get ( 'href' ) ) ) with sqlite3 . connect ( DB ) as conn : cursor = conn . cursor ( ) cursor . executemany ( 'insert into teams values (?,?,?);' , rows ) conn . commit ( )