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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
Sub ListeCourses()
Dim IE As InternetExplorer, IEP As InternetExplorer
Dim IEdoc As HTMLDocument
Dim O As Object, OI As Object
Dim ColReunions As New Collection, ColCourses As New Collection
Dim V As Variant
Dim vURL As String, vID As String, vReunion As String, vc As String
Dim L As Byte
'URL de départ
vURL = "http://www.pmu.fr/turf/" & Sheets("Accueil").Range("E2").Text & "/index.html"
'Ouvre la page web dans IE de façon invisible
Set IE = CreateObject("internetExplorer.Application")
Set IEP = CreateObject("internetExplorer.Application")
IE.Visible = False
Application.ScreenUpdating = False
'Ouvrir la page Web
IE.Navigate vURL
Do Until IE.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
Set IEdoc = IE.Document
'Mémoriser les liens des pages de Réunion
For Each O In IEdoc.links
If O.onclick Like "*afficheReunionCalendrier(*" Then
ColReunions.Add O.href & "|" & O.innerText
End If
Next O
'Pour chaque Réunion
For L = 1 To ColReunions.Count
'Ouvrir la page web
IEP.Visible = False
IEP.Navigate Split(ColReunions(L), "|")(0)
Do Until IEP.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
'Récupérer les numéros ID et nom de chaque course
'Set IEdoc = IE.Document
vReunion = Split(ColReunions(L), "|")(1)
On Error Resume Next
For Each OI In IEP.Document.links
vID = OI.onclick
If vID Like "*_chevaux.choix_*" Then '"*" & vReunion & "/course*" Then
vc = "C" & Replace(OI.innerText, " ", "")
vID = OI.href
'vID = Replace(vID, "/page-1-index.html", "")
vID = vID & "|" & vReunion & "|" & vc 'CStr(Val(vID))
ColCourses.Add vID, vID
End If
Next OI
Next L
'Quitter IE
Set IEdoc = Nothing
Set IE = Nothing
Set IEP = Nothing
IE.Quit
IEP.Quit
Application.ScreenUpdating = True
'Alimenter la liste ComboBox des éléments récoltés
With Sheets("Accueil").ComboBox1
.Clear
.ColumnCount = 3
.BoundValue = 3
.Text = "< choisir une course >"
For L = 1 To ColCourses.Count
V = Split(ColCourses(L), "|")
.AddItem V(0)
.List(.ListCount - 1, 1) = V(1)
.List(.ListCount - 1, 2) = V(2)
Next L
End With
MsgBox "Liste mise à jour ! ", vbInformation + vbOKOnly, "myDearFriend!"
End Sub |
Partager