1 回答
TA贡献1936条经验 获得超6个赞
您的数据框只有一列,但columns=[['match', 'result', 'data']]您传递了三列名称,这会给您带来错误。
df=[[] for x in range(3)]
matches=driver.find_elements_by_xpath("//a[@class='in-match']")
for match in range(len(matches)):
df[0].append(matches[match].text)
results=driver.find_elements_by_xpath("//td[@class='h-text-center']")
for result in range(len(results)):
df[1].append(results[result].text)
date=driver.find_elements_by_xpath("//td[contains(@class, 'h-text-right')]")
for data in range(len(date)):
df[2].append(date[data].text)
data_frame = pd.DataFrame()
data_frame['match'] = df[0]
data_frame['result'] = df[1]
data_frame['data'] = df[2]
添加回答
举报