如何使XMLHTTP在MAC上工作

时间:2018-10-20 06:58:33

标签: excel vba excel-vba web-scraping

我之前发布了一个主题,并且在此链接中以完美的方式解决了该问题 Scrape using XMLHTTP throws error at specific class name  这是工作代码

Sub GetProfileInfo()
Const URL$ = "https://www.zillow.com/detroit-mi/real-estate-agent-reviews/?page="
Dim Http As New XMLHTTP60, Html As New HTMLDocument
Dim post As HTMLDivElement, R&, P&

For p = 1 To 3 'put here the highest number you wanna traverse
    With Http
        .Open "GET", URL & p, False
        .send
        Html.body.innerHTML = .responseText
    End With

    For Each post In Html.getElementsByClassName("ldb-contact-summary")
        With post.querySelectorAll(".ldb-contact-name a")
            If .Length Then R = R + 1: Cells(R, 1) = .item(0).innerText
        End With

        With post.getElementsByClassName("ldb-phone-number")
            If .Length Then Cells(R, 2) = .item(0).innerText
        End With
    Next post
Next p
End Sub

但似乎仅在Windows上有效。如何在MAC上使用它?

0 个答案:

没有答案