问题
Currently i am able to extract values from webpage but facing issue json value extraction.
I am using following code for other values extraction.
On Error Resume Next
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", url1234, False
http.Send
html.body.innerHTML = http.ResponseText
brand = html.body.innerText
'MsgBox (brand)
Above code is not extracting following values of this url
"" : {"0":"B0037RYT96","1":"B0152VYOQ2","2":"B0152WOT70","3":"B003W0NYKS","4":"B0152WOT8Y","5":"B00C2O7M1M","6":"B0037RMS6W","7":"B0037RMI0S","8":"B0152VYPXY"},
回答1:
There isn't anything I can see in your code that attempts to extract this.
You could use regex to specify the appropriate pattern to extract that string. Below, the string you are after is stored in r
variable.
EDIT:
Given your edit to the required string you can change the regex to:
\"dimensionToAsinMap\" :(.*)[^\r\n].*
Try it here
Former answer:
Try regex here
Option Explicit
Public Sub GetData()
Dim s As String, r As String, re As Object
Set re = CreateObject("vbscript.regexp")
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", "https://www.yoursite.com?tag=stackoverfl08-20", False
.send
s = .responseText
End With
With re
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = "(""dimensionToAsinMap"" :.(.|\n)*)[;^\r\n].*return dataToReturn"
If .test(s) Then
r = .Execute(s)(0).SubMatches(0)
Else
r = "No match"
End If
End With
End Sub
Locals window check:

Regex explanation:

来源:https://stackoverflow.com/questions/56037729/json-values-extraction-from-webpage-using-msxml2-xmlhttp