【发布时间】:2020-05-25 22:55:04
【问题描述】:
如何使用 Selenium 在 span 块中获取文本 (02/10/2020)?
<div class="unique_class_date">
<span>02/10/2020</span>
</div>
我试过了
driver.find_element_by_class_name("unique_class_date")
但它返回空。
编辑:这是代码,我正在尝试从 Bloomberg 获取数据:
import selenium.webdriver
from selenium.webdriver.firefox.options import Options as FirefoxOptions
options = FirefoxOptions()
options.headless = True
driver = selenium.webdriver.Firefox(options=options)
dateclass = "time__245ca7bb"
url = "https://www.bloomberg.com/quote/TSLA:US"
driver.get(url)
last_update = driver.find_element_by_class_name(dateclass).text # sadly, this returns empty
...
【问题讨论】:
标签: python selenium selenium-webdriver