Condividi:        

Estrarre Dati in Automatico

Vuoi potenziare i tuoi documenti Word? Non sai come si fa una macro in Excel? Devi creare una presentazione in PowerPoint?
Oppure sei passato a OpenOffice e non sei sicuro di come lavorare al meglio?

Moderatori: Anthony47, Flash30005

Re: Estrarre Dati in Automatico

Postdi Anthony47 » 13/12/23 20:31

spero di aver fatto tutto bene
Se hai usato con successo il file allegato alla discussione "Selenium" allora hai la conferma di aver fatto tutto bene.

Per quanto riguarda la pagina betexplorer, la nuova macro:
Codice: Seleziona tutto
Sub TabsCaller()
Dim WPage As Object
Dim myUrl As String, I As Long
Dim AllTabs
'
'Crea Driver:
If WPage Is Nothing Then
    Set WPage = CreateObject("Selenium.EdgeDriver")
    WPage.Start "edge"
End If
'
Application.Goto (Sheets("Foglio1").Range("A1"))            '<<<<<  -Foglio esistente
Cells.Clear
myUrl = "https://www.betexplorer.com/football/italy/serie-a/results/"     '<<<<
'
AllTabs = GimmeTablesArr(WPage, myUrl)      'Ottieni la matrice delle tabelle

For I = 1 To UBound(AllTabs)
    Cells(Rows.Count, "A").End(xlUp).Offset(2, 0).Value = "Tabella_" & I
    Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Resize(UBound(AllTabs(I)), UBound(AllTabs(I), 2)).Value = _
      AllTabs(I)
Next I
'
'Quit Selenium
WPage.Quit
Set WPage = Nothing
MsgBox ("Informazioni raccolte...")
End Sub



Function GimmeTablesArr(lDriver As Object, myUrl As String) As Variant
Dim I As Long, myTim As Single
Dim TArr(), TBColl As Object
'
lDriver.Get myUrl
myTim = Timer
'
Set TBColl = lDriver.FindElementsByTag("table")
ReDim TArr(1 To TBColl.Count)
'
For I = 1 To TBColl.Count
    TArr(I) = TBColl(I).AsTable.Data
Next I
GimmeTablesArr = TArr
Debug.Print "GTArr:", "Tables: " & I - 1, Format(Timer - myTim, "0.00"), myUrl
End Function

Dovrebbe importare le tabelle presenti, caricandole sul foglio indicato

Fai sapere...
Avatar utente
Anthony47
Moderatore
 
Post: 19228
Iscritto il: 21/03/06 16:03
Località: Ivrea

Sponsor
 

Precedente

Torna a Applicazioni Office Windows


Topic correlati a "Estrarre Dati in Automatico":


Chi c’è in linea

Visitano il forum: Ricky0185 e 15 ospiti

cron