【发布时间】:2021-10-28 01:55:56
【问题描述】:
我试图从下面的页面中抓取表格数据,但它给了我“消息:没有这样的元素:无法找到元素”的错误。
下面的代码昨天运行良好,但现在产生了错误。如果有任何帮助,谢谢。enter image description here
import time
import pandas as pd
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.headless = True
driver = webdriver.Chrome(options=options)
driver.get("https://www.binance.com/en/futures/funding-history/0")
time.sleep(5)
table = driver.find_element_by_xpath('//*[@class="rc-table-tbody"]')
data = []
for tr in table.find_elements_by_xpath('tr'):
columns = tr.find_elements_by_xpath('td')
data.append({
'Contract': columns[0].text,
'Funding Rate': columns[2].text
})
# Convert lits of dictionaries into a dataframe
df = pd.DataFrame(data)
【问题讨论】:
-
请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。
标签: python selenium web-scraping