使用vba从span中提取内部文本
我想使用vba从网页中的一些数据到Excel。
html代码是
<span id="lastPrice">300.21</span>
我想要的数字是300.21
我试过这个,但没有工作(在ST中没有返回)
Dim st As String st = htmldoc.getElementById("lastPrice").getElementsByTagName("span")(5).innerText
我怎样才能得到所需的输出?
尝试这个:
Dim element as Object Set element = htmldoc.getElementById("lastPrice") Dim price as String If Not element Is Nothing Then price = element.innerText