我已經(jīng)編寫了我的第一個(gè)python代碼,以從網(wǎng)絡(luò)上抓取股息歷史記錄表,但是soup.select語句似乎沒有選擇任何內(nèi)容,并導(dǎo)致了索引錯(cuò)誤。請(qǐng)問如何解決的任何建議?from selenium import webdriverfrom bs4 import BeautifulSoupimport pandas as pddriver = webdriver.Chrome(executable_path='F:\PythonApps\ChromeDriver\ChromeDriver.exe')driver.get("https://www.dividendchannel.com/history/?symbol=ibm")soup = BeautifulSoup(driver.page_source,"lxml")driver.quit()table = soup.select("table#Dividend History")[0]print(table)list_row =[[tab_d.text.strip().replace("\n","") for tab_d in item.select('th,td')] for item in table.select('tr')]for data in list_row[:2]: print(' '.join(data))文件“F:/System/Python/dividend.py”,第 9 行,在 table = soup.select("table#Dividend History")[0]IndexError:列表索引超出范圍
添加回答
舉報(bào)
0/150
提交
取消