1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| Public Sub RecupTableauFlashscore()
Dim robot As New WebDriver
Dim elem, maTable, colonnes, colonne, lignes, ligne As Object
Dim x, y As Integer
robot.Timeouts.ImplicitWait = 8000 ' temps max 8 secondes pour les commandes find avant exception
robot.Start "chrome", "https://www.flashscore.fr"
robot.Get "/match/0fZOvsc0/#player-statistics;0"
Set maTable = robot.FindElementById("player-statistics-basketball")
Set colonnes = maTable.FindElementsByClass("txt")
x = 1
y = 1
For Each colonne In colonnes
'Debug.Print colonne.Attribute("textContent")
Cells(x, y).Value = colonne.Attribute("textContent")
y = y + 1
Next
x = 2
Set lignes = maTable.FindElementsByXPath(".//tbody/tr")
'Debug.Print lignes.Count
For Each ligne In lignes
y = 1
Set colonnes = ligne.FindElementsByXPath(".//td")
For Each colonne In colonnes
'Debug.Print colonne.Attribute("textContent")
Cells(x, y).Value = colonne.Attribute("textContent")
y = y + 1
Next
x = x + 1
Next
robot.Wait (1000) ' temporisation de 1 seconde avant de sortir
robot.Quit
End Sub |