我是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
答案 0 :(得分:1)