In particolare quali sono le informazioni da prelevare dalla pagina web; immagino che si debbano riprendere TUTTE le estrazioni presenti, ma sono tutte quelle della giornata? e a mezzanotte l'elenco si svuota? e sul file excel tu conservi del passato un riepilogo, o no tieni solo quelli della giornata?
Dai per scontato che con le query web non si fa piu' niente e dovremo aprire la pagina con IE per estrarre i dati; ad esempio questo codice compila su Foglio33 da Y2 in giu' con le estrazioni che trova:
- Codice: Seleziona tutto
#If VBA7 Then
Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr)
#Else
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
#End If
Sub Get10eLottoWeb()
Dim IE As Object
Dim AColl As Object, BColl As Object, trItm
Dim I As Long, J As Long, AllNum As String
Dim oArr(0 To 500, 0 To 20), oInd As Long, mySplit
Set IE = CreateObject("InternetExplorer.Application")
myURL = "https://www.lottologia.com/10elotto5minuti/past-draws-archive/?table_view_type=default"
With IE
.navigate myURL
.Visible = True
Do While .Busy: DoEvents: Loop 'Attesa not busy
Do While .readyState <> 4: DoEvents: Loop 'Attesa documento
End With
'
Sleep 300
Set AColl = IE.document.getElementsByTagName("TD")
For I = 0 To AColl.Length - 1
If AColl(I).className = "DATE" Then
oArr(oInd, 0) = AColl(I).innerText
Set trItm = AColl(I).parentElement
AllNum = Replace(trItm.getElementsByTagName("TD")(1).innerText, Chr(13), "#", , , vbTextCompare)
AllNum = Replace(AllNum, Chr(10), "#", , , vbTextCompare)
AllNum = Replace(AllNum, Chr(32), "", , , vbTextCompare)
AllNum = Replace(AllNum, "##", "#", , , vbTextCompare)
AllNum = Replace(AllNum, "##", "#", , , vbTextCompare)
AllNum = Replace(AllNum, "##", "#", , , vbTextCompare)
AllNum = Replace(AllNum, "##", "#", , , vbTextCompare)
Debug.Print oInd, AllNum
mySplit = Split(AllNum & "#", "#", , vbTextCompare)
If UBound(mySplit) > 5 Then
For J = 1 To UBound(mySplit)
oArr(oInd, J) = mySplit(J)
If J > 19 Then Exit For
Next J
oInd = oInd + 1
End If
End If
Next I
Sheets("Foglio33").Range("Y2").Resize(500, 22).ClearContents
Sheets("Foglio33").Range("Y2").Resize(oInd + 2, 21) = oArr
'
On Error Resume Next
IE.Quit
Set IE = Nothing
End Sub
Mettilo in un Modulo vba vuoto in modo che le dichiarazioni iniziali siano in testa; poi lancia la Sub Get10eLottoWeb
Se il risultato e' simile a cio' che ti aspetti allora possiamo lavorare per adeguare il codice
Tieni pero' presente che IE è "in scadenza", quindi portati avanti creando l'ambiente "Selenium": guarda qui viewtopic.php?f=26&t=112225
Ciao