Ciao, vorrei approfittare della tua disponibilità, il suggerimento da te proposto va benissimo ma, il sito dove importo i dati non aggiorna le tabelle molto velocemente e cercando su internet ho trovato qualcosa che potrebbe fare al caso mio;
Si tratta di un modulo VBA, ho trovato questa discussione aperta, che ha un problema il modulo ma, nonostante credo lo abbiano risolto, non avendo conoscenze al riguardo, non riesco a trovare la soluzione, se puoi aiutarmi, sto cercando di allegare il file ma sto trovando problemi, e quindi trascrivo il codice così come sta nel modulo;
In sostanza, vorrei creare un foglio, dove spero, cambiando il campionato di riferimento del codice, posso trascrivere i risultati, non appena le partite terminano;
ovviamente penso che dovrei creare tanti moduli quanti sono i campionati di mio interesse, cmq posto il codice e ti ringrazio in anticipo:
'--------------------------------------------------------------------------------------- ' Module : Modulo1 ' Author : scossa ' Date : 20/01/2020 ' Purpose : ' Attenzione: mettere i riferimenti a Selenium Type Library da ' C:\Users..xxx..\AppData\Local\SeleniumBasic\Selenium32.tlb ' per usare la Early Binding '--------------------------------------------------------------------------------------- Option Explicit Public Sub prova() Call diretta("https://www.diretta.it/calcio/argentina/primera-nacional/risultati/") End Sub Public Sub diretta(ByVal sUrl As String) Dim rng As Range, j As Long, sStatus As String '--------------- late binding ---------------- Dim bot As Object, soccerDivs As Object Dim divElement As Object, divSoccer As Object '--------------------------------------------- '------------------- early binding ------------------- 'Dim bot As WebDriver, soccerDivs As WebElements 'Dim divElement As WebElement, divSoccer As WebElement '----------------------------------------------------- Set rng = Range("A2") Foglio1.UsedRange.Offset(1, 0).ClearContents rng.Value = "... attendere ..." On Error GoTo safety_exit_ '--------------- late binding ----------------- Set bot = CreateObject("Selenium.ChromeDriver") '---------------------------------------------- '---------------- early binding ---------------- 'Set bot = New WebDriver '----------------------------------------------- bot.Start "chrome", sUrl bot.Get "/" Set divSoccer = bot.FindElementById("live-table", timeout:=4000).FindElementByClass("soccer") Set soccerDivs = divSoccer.FindElementsByTag("div") With Application VBA.AppActivate .Name .ScreenUpdating = False .Cursor = xlWait End With For Each divElement In soccerDivs DoEvents 'Debug.Print divElement.Attribute("class") & "; " & divElement.Text If InStr(divElement.Attribute("class"), "event__titleBox") > 0 Then rng.Offset(j, 0).Value = Replace(divElement.Text, vbLf, ": ") j = j + 1 ElseIf InStr(divElement.Attribute("class"), "event__round") > 0 Then rng.Offset(j, 1).Value = divElement.Text sStatus = rng.Offset(j, 1).Value & ": " ElseIf InStr(divElement.Attribute("class"), "event__time") > 0 Then If divElement.Text <> "" Then rng.Offset(j, 2).Value = divElement.Text End If ElseIf InStr(divElement.Attribute("class"), "event__participant--home") > 0 Then If divElement.Text <> "" Then rng.Offset(j, 3).Value = divElement.Text End If ElseIf InStr(divElement.Attribute("class"), "event__scores") > 0 Then If divElement.Text <> "" Then rng.Offset(j, 4).NumberFormat = "@" rng.Offset(j, 4).Value = Replace(divElement.Text, vbLf, "") End If ElseIf InStr(divElement.Attribute("class"), "event__participant--away") > 0 Then If divElement.Text <> "" Then rng.Offset(j, 5).Value = divElement.Text 'Replace(divElement.Text, vbLf, "; ") Application.StatusBar = sStatus & rng.Offset(j, 3).Value & " - " & rng.Offset(j, 5).Value & ": " & rng.Offset(j, 4).Value End If ElseIf InStr(divElement.Attribute("class"), "event__part") > 0 Then If divElement.Text <> "" Then rng.Offset(j, 6).Value = divElement.Text 'Replace(divElement.Text, vbLf, "; ") End If j = j + 1 Else End If Next With bot .Wait 1000 .Close .Quit End With safety_exit_: With Application .StatusBar = False .ScreenUpdating = True .Cursor = xlDefault End With If Err.Number <> 0 Then MsgBox "si è verificato un errore!", vbCritical, "ATTENZIONE" Else MsgBox "estrazione terminata", vbInformation, "FINITO" End If End Sub