我已经编写了我的第一个python代码,以从网络上抓取股息历史记录表,但是soup.select语句似乎没有选择任何内容,并导致了索引错误。请问如何解决的任何建议?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:列表索引超出范围
添加回答
举报
0/150
提交
取消