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
| Sub tableau()
Dim i As Long, Ie1, url(4), supp, tablo1, tablo2
url(1) = "http://www.pronostics-turf.info/fg-pronostics-presse.php"
Set dico = CreateObject("Scripting.Dictionary")
Set Ie1 = CreateObject("internetexplorer.application")
Ie1.Visible = False
Ie1.navigate url(1)
Do: DoEvents: Loop While Ie1.readystate = False Or Ie1.busy
codehtml = Ie1.document.body.innerhtml
Set fauxdoc = CreateObject("htmlfile")
For p = 1 To 5
'Debug.Print Ie1.locationurl
With fauxdoc
.write codehtml
Set mestables = .getelementsbytagname("TR")
For i = 0 To mestables.Length - 1
If mestables(i).innertext Like "*" & "PRONOSTICS EN DÉTAIL:" & "*" Then Exit For
For Each elem In mestables(i).all
If IsNumeric(Trim(elem.innertext)) Then elem.innertext = "|" & Trim(elem.innertext)
Next
If Not dico.exists(mestables(i).innertext) Then
dico(mestables(i).innertext) = ""
ligne = Replace(Replace(mestables(i).innertext, vbCrLf, " "), " ", " ")
If ligne Like "*" & "[1-9]" & "*" Then codi = codi & ligne & vbCrLf
End If
Next
End With
passe = Ie1.locationurl = "http://www.pronostics-turf.info/suite3-pronostics-presse-hippique.php"
On Error Resume Next
For Each elem In Ie1.document.all
Select Case passe
Case True
If elem.tagname = "A" And elem.outerhtml Like "*" & "liste-synthese" & "*" Then elem.Click: Exit For
Case False
If elem.tagname = "A" And elem.outerhtml Like "*" & "suite" & "*" Then elem.Click: Exit For
End Select
Next
Err.Clear
Do: DoEvents: Loop While Ie1.readystate = False Or Ie1.busy
codehtml = Ie1.document.body.innerhtml
Next
Ie1.Quit
codi1 = Replace(Replace(Split(codi, "Places")(0), "|", ","), vbCrLf, ";")
codi2 = Replace("Places" & Replace(Split(codi, "Places")(1), "|", ","), vbCrLf, ";")
Debug.Print codi1
Debug.Print "suite page "
Debug.Print codi2
tablo1 = Evaluate("{" & codi1 & "}")
tablo2 = Evaluate("{" & codi2 & "}")
Cells(Rows.Count, 1).End(xlUp).Resize(UBound(tablo1), 9) = tablo1
Cells(Rows.Count, 1).End(xlUp).Offset(2, 0).Resize(UBound(tablo2), 16) = tablo2
End Sub |