Trouble making my parser scroll downward

后端 未结 1 1959
故里飘歌
故里飘歌 2020-12-21 17:31

I\'ve written a script in vba to parse some information from a webpage. The thing is before scraping any information from that webpage I need to make my scraper scroll downw

相关标签:
1条回答
  • 2020-12-21 18:38

    Take a look at the below example:

    Option Explicit
    
    Sub Test()
    
        ' Add references
        ' Microsoft XML, v6.0
        ' Microsoft HTML Object Library
    
        Dim sResponse As String
        Dim aResult() As String
        Dim i As Long
        Dim oElement As HTMLDivElement
    
        With New XMLHTTP
            .Open "POST", "http://catalogo.marmomac.it/ajax/getListEspositori.php", False
            .SetRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"
            .Send "start=0&count=5000"
            sResponse = .ResponseText
        End With
        With New HTMLDocument
            .body.innerHTML = sResponse
            i = 1
            For Each oElement In .getElementsByClassName("elemento")
                ThisWorkbook.Sheets(1).Cells(i, 1) = oElement.innerText
                i = i + 1
            Next
        End With
    
    End Sub
    

    The output for me as follows, there are 1669 items total:

    0 讨论(0)
提交回复
热议问题