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