【发布时间】:2020-08-07 20:28:00
【问题描述】:
我有一个用于访问网站的宏,它从代码的特定部分从 A 列中提取一个值,例如 517167000,然后将该值返回到一个单元格。 html 源现在已经改变,我似乎无法让它工作。
我原来的代码是
Public Function UnitPerBox(searchTerm As String) As String
Static request As Object
If request Is Nothing Then Set request = CreateObject("msxml2.xmlhttp")
With request
.Open "GET", "https://larsonjuhl.co.uk/mouldings/larson-juhl-essentials/arq-essentials-moulding-" & searchTerm, False
.send
UnitPerBox = Trim(Split(Split(.responseText, "Units per box</td>")(1), "<tr")(0))
End With
End Function
所以网站的一个工作示例是
https://larsonjuhl.co.uk/mouldings/larson-juhl-essentials/arq-essentials-moulding-517167000
这样你就可以去网站查看源代码了。 新的 html 代码如下所示,但距离我做原始宏已经很久了,我认为我可以改变
"Units per box</td>")(1), "<tr"
到
"Units per pack</td> <td class="value">")(1), "<tr"
因为下面的新 html 代码是现在网站上的内容,例如我需要值 2.74,但它不起作用。
<tr>
<td class="name">Units per pack</td>
<td class="value">2.74</td>
</tr>
任何帮助将不胜感激。
一个例子 干杯
【问题讨论】:
标签: html excel vba internet-explorer extract