如何使用VBA代码从HTTP对Excel的响应中获取值

如何使用VBA代码从HTTP对Excel的响应中获取值,excel,vba,http,web-scraping,Excel,Vba,Http,Web Scraping,我需要您的帮助,从我得到的HTTP响应中获取股票价值(对应于股票名称)。收到的响应是HTML格式的,因为代码太长,所以我添加了部分内容。下面我提到了我正在使用的VBA代码,但它显示了错误。请任何人帮帮我。。!! 注:股票名称和价值出现在“输入类型”中(从下到下的第5行) 您可以使用css选择器以td元素为目标 Dim nodeList As Object, i As Long Set nodeList = html.querySelectorAll("#data_table tr.tinside

我需要您的帮助,从我得到的HTTP响应中获取股票价值(对应于股票名称)。收到的响应是HTML格式的,因为代码太长,所以我添加了部分内容。下面我提到了我正在使用的VBA代码,但它显示了错误。请任何人帮帮我。。!! 注:股票名称和价值出现在“输入类型”中(从下到下的第5行)


您可以使用css选择器以td元素为目标

Dim nodeList As Object, i As Long
Set nodeList = html.querySelectorAll("#data_table tr.tinside td")
For i = 0 To nodeList.Length -1
    Debug.Print nodeList.item(i).innerText
Next
整个表可以使用id选择器

Dim ele As Object
Set ele  = html.getElementById("data_table")
' then loop the tr tags and then the td tags

错误消息是什么?在哪一行?(请不要参考行号)感谢您的回复,但代码可以获取属性值,如名称、值、id等。。我无法抓取属于类的文本值。例如(在上面给定的HTML代码中),我试图获取的内容类似于。阿波罗提尔,NSE,163,看涨,均衡器,0.00201.00,0.00299.501990,199.20。。。。。。。。。等。是否有可能抓取每一个股票数据,因为它属于课堂。非常感谢QHarr。。!!我想这正是我所需要的。。。再次感谢你。。!!
Dim nodeList As Object, i As Long
Set nodeList = html.querySelectorAll("#data_table tr.tinside td")
For i = 0 To nodeList.Length -1
    Debug.Print nodeList.item(i).innerText
Next
Dim ele As Object
Set ele  = html.getElementById("data_table")
' then loop the tr tags and then the td tags