0

我一直在使用我为从某些站点抓取一些数据而制作的代码,现在我尝试将一个新站点添加到列表中,我收到此错误:对象不支持此属性或方法。我可以使用与其他人完全相同的代码,但这次我收到此消息,有人知道为什么吗?当我尝试获取 elementbyclassname 时出现错误消息。

Sub Zelo()
    Dim dia As String
    Dim mes As String
    Dim ano As String

    dia = "14"
    mes = "09"
    ano = "13"

    Dim cont As Integer
    Dim i As Integer
    Dim URL As String
    Dim IE As Object
    IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True

    URL = "http://www2.zelo.com.br/weddingListSearch.aspx?dsName=&dsLocation=&dtWedding=" & dia & "/" & mes & "/" & ano & "&idproduct=&qty="

    IE.Navigate(URL)

    Do
        DoEvents()
    Loop Until IE.READYSTATE = 4

    cont = 0

    With IE
        For Each ele In .document.getelementsbyclassname("name") ' Here I have the error message
            If ele.classname = "place" Then
                cont = cont + 1
            End If
        Next ele
    End With

    Sheets("Plan2").Range("A2") = cont

    IE.Quit()
End Sub
4

1 回答 1

4

没有getelementsbyclassnameInternet Explorer/WebBrowser 控件中的方法。

我假设您想使用GetElementsByTagName它来获取具有指定标签名称的所有元素。

编辑 :

更新的代码示例:

With IE
    For Each ele In .document.GetElementsByTagName("td")
        If ele.classname = "place" Then
            cont = cont + 1
        End If
    Next ele
End With
于 2013-09-12T12:09:06.137 回答