I have a procedure that opens a web page and counts how many pages there are inside it. I would then need to click on a certain page, for example, number 3. Does anyone know how to do it? I detail below the code of the macro. Thank you very much!
Sub test()
Dim element As IHTMLElement
Dim elements As IHTMLElementCollection
Dim ie As InternetExplorer
Dim numberOfPages As Double
Dim html As HTMLDocument
Set ie = New InternetExplorer
ie.Visible = True
ie.navigate "https://cebra.com.ar/category/73/Juego-de-Construccion.html"
Do While ie.readyState <> READYSTATE_COMPLETE
Application.StatusBar = "Loading Web page …"
DoEvents
Loop
Set html = ie.document
Set elements = html.getElementsByClassName("container")
Set ElementCol = html.getElementsByTagName("a")
numberOfPages = ie.document.querySelectorAll(".setPage").Length
'Here I want to click on a certain page, for example, number 3
For Each ele In ie.document.getElementsByTagName("li")
For Each element In elements
If element.className = "container" Then
'Do something
End If
Next element
Next
MsgBox "Done"
End Sub
Aucun commentaire:
Enregistrer un commentaire