我正在尝试将此号码输入Excel单元格。
Avg. asking price in Bayswater Road: £1,828,502
有没有办法使用VBA或其他工具?无法使其与网络查询一起使用。
答案 0 :(得分:2)
以下是可能的解决方案之一:
Option Explicit
Sub RetrieveAvgPrice()
Dim sUrl, sContent, sPrice
sUrl = "http://www.zoopla.co.uk/home-values/london/bayswater-road/"
With CreateObject("MSXML2.XMLHttp")
.Open "GET", sUrl, False
.Send ""
sContent = .ResponseText
End With
With CreateObject("VBScript.RegExp")
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = "Avg\. asking price[\s\S]*?class=""price big"">([\s\S]*?)<"
sPrice = HtmlSpecialCharsDecode(.Execute(sContent).Item(0).SubMatches(0))
End With
MsgBox sPrice
End Sub
Function HtmlSpecialCharsDecode(sText)
With CreateObject("htmlfile")
.Open
With .createElement("textarea")
.innerHTML = sText
HtmlSpecialCharsDecode = .Value
End With
End With
End Function