我希望在 Excel VBA 中決議“WinHttpRequest”回應以從 HTML 回應中提取特定行。這是 HTTP 請求的代碼。
Function getSetName(ByVal setNUMBER As String) As String
Dim oRequest As Object
Dim xmlResponse As String
Dim setDescription As String
Dim setName As String
Set oRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
oRequest.Open "GET", "https://brickset.com/sets/75192" '& setNUMBER
oRequest.Send
xmlResponse = oRequest.ResponseText
'parse xml response here
getSetName = setName
End Function
我希望僅將帶有 HTML 標記 'meta name=""description""' 的行決議為一個字串,稍后我將從中提取資訊。
任何有關如何決議這一行的幫助或指導將不勝感激。
uj5u.com熱心網友回復:
嘗試
Sub Test_GetSetName()
Debug.Print GetSetName("75192")
End Sub
Function GetSetName(ByVal SetNUMBER As String) As String
Dim html As New MSHTML.HTMLDocument
With CreateObject("WinHttp.WinHttpRequest.5.1")
.Open "GET", "https://brickset.com/sets/" & SetNUMBER, False
.send
html.body.innerHTML = .responseText
End With
GetSetName = html.querySelector("[name='description']").Content
End Function
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/369553.html
上一篇:以increments_2將行值從一個作業表復制到另一個作業表
下一篇:VBA中日期格式的區別
