List index out of range error after scraping with Selenium
up vote
0
down vote
favorite
1
Code: team1 = team2 = url = "https://www.basketball-reference.com/leagues/NBA_2019_games.html" driver = webdriver.Chrome(executable_path=r"chromedriver.exe") driver.implicitly_wait(30) driver.get(url) soup1 = BeautifulSoup(driver.page_source, 'lxml') for i in range(len(soup1.find_all('a', href=True, text='Box Score'))): driver.find_elements_by_link_text('Box Score')[i].click() driver.implicitly_wait(10) soup2 = BeautifulSoup(driver.page_source, 'lxml') scorebox = soup2.find_all('div',{'class':'scorebox'})[0] team1.append(scorebox.find_all('a', itemprop='name')[0].text.strip()) team2.append(scorebox.find_all('a', itemprop='name')[1].text.strip(