我是XMLHHTP的新手,我刚刚通过一些人的在线帮助制作了下面的代码,并意识到我需要使其异步,因为工作簿需要访问数百个URL。
如果有人可以调查并将其变成异步,我会非常感激。
Sub GetInfo()
Dim Http As New XMLHTTP60, Html As New HTMLDocument
Dim lastrow As Long, i As Long
Dim sdd As String
Dim add As Variant
Dim url As Range
i = 2
For Each url In Range(Cells(3, "J"), Cells(Rows.Count, "J").End(xlUp))
With Http
.Open "GET", url, False
.send
Html.body.innerHTML = .responseText
End With
On Error Resume Next
sdd = Html.querySelector("span[itemprop='price']").getAttribute("content")
i = i + 1
Sheet1.Cells(i, "K") = sdd
Next url
End Sub