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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
| Sub testesimple37()
Dim z As Long, pluss As Long, dicoseb, dicopat, mesTRREF
Sheets(1).Cells.ClearContents
Set dicoseb = CreateObject("Scripting.Dictionary")
Set dicopat = CreateObject("Scripting.Dictionary")
Set IE = CreateObject("internetexplorer.application")
With IE:
.navigate "http://www.pronostics-turf.info/fg-pronostics-presse.php"
'IE.Visible = True:
Do: DoEvents: Loop While .readystate <> 4 Or .busy
codeinnertext = .document.body.innertext: Codehtml = .document.body.innerhtml
texte1 = Replace("<div>" & Split(Split(Codehtml, "Résultat")(1), "PRONOSTICS")(0) & vbCrLf & "</div><BR>", "</strong>", "<p>")
Set mestables = .document.getelementsbytagname("table")
For i = 1 To mestables.Length - 4
texte2 = texte2 & mestables(i).outerhtml
Next
.Quit
End With
With CreateObject("htmlfile")
.body.innerhtml = texte1 & texte2
listPRnst = Array("Bilto :", "Agence TIP :", "Top Entraineurs : ", "Stato Turf : ", "Paris Turf : ")
Set mestr = .getelementsbytagname("TR")
For i = 0 To mestr.Length - 1
For t = 0 To UBound(listPRnst)
If InStr(mestr(i).outerhtml, listPRnst(t)) > 0 Then table1 = table1 & vbCrLf & mestr(i).outerhtml
Next
'pour la syntheze par points c'est un peu différent mais je la récupère c'est bon cela dit il y a 16 cellules les pronos il y en a que 8
If InStr(mestr(i).outerhtml, "Synthèse") > 0 Then
mestr(i).ID = "synthW"
mestr(i - 4).ID = "place"
nextcel = mestr(i - 4).Children(mestr(i - 4).Children.Length - 1).outerhtml
table2 = "<TABLE>" & Replace(mestr(i - 4).outerhtml, nextcel, "") & vbCrLf & mestr(i).outerhtml & "</TABLE>"
table3 = "<TABLE>" & Replace(Replace(Replace(mestr(i - 4).outerhtml, "Places", "Cheval"), nextcel, ""), place, "CHEVAL")
table3 = table3 & "<TR ID=fois><TH> X fois Cité</TH>" & Application.Rept("<TH>0</TH>", mestr(i - 4).Children.Length - 2) & "</TR>"
table3 = table3 & "<TR>" & "</TR>"
table3 = table3 & "<TR ID=synthP><TH>syntheze patrick</TH>" & Application.Rept("<TH></TH>", mestr(i - 4).Children.Length - 2) & "</TR>"
table3 = table3 & "<TR ID=synthS><TH>syntheze Sebphyto</TH>" & Application.Rept("<TH></TH>", mestr(i - 4).Children.Length - 2) & "</TR>" & "</TABLE>"
End If
Next
table1 = "<TABLE id=tableref>" & table1 & "</TABLE>"
.body.innerhtml = texte1 & table1 & "<BR>" & table2 & "<BR>" & table3
'on va s'ocuper des titres
'*******************************************
'dans ces 3 ligne il y a tout il nous reste a découper le texte de ces trois elements pour tout recupérer ce qui concerne les titres
oldg = .getelementsbytagname("p")(0).innertext
prix = .getelementsbytagname("h1")(0).innertext
newrun = .getelementsbytagname("h1")(1).innertext
'********************************************
' on découpe!!!
oldate = Split(Split(Replace(oldg, "hui", "hier"), "hier")(1), ":")(0)
oldate = Format(Replace(oldate, Split(oldate, " ")(1), ""), "dd/mm/yyyy")
OlDarrivée = Replace(Split(oldg, ": ")(1), " ", "")
prix = Split(prix, "Prix")(1)
HiPPo = Split(Split(newrun, "à ")(1), " ")(0)
newdate = Replace(Split(Split(newrun, "le ")(1), ",")(0), " - ", "/")
RC = Replace(Replace(Split(Split(newrun, ", ")(1), " Départ")(0), "Réunion", "R"), "Course", "C")
DsP = Split(newrun, ")")(1)
'************************************************************************************
'nombre de fois cité dans les sources choisies
Set mesthref = .getelementbyID("tableref").getelementsbytagname("TH")
Set fois = .getelementbyID("fois")
For i = 1 To 17
For a = 0 To mesthref.Length - 1
If Val(mesthref(a).innertext) = i Then fois.Children(i).innertext = Val(fois.Children(i).innertext) + 1
Next
Next
'***************************************************************************
'syntheze patric avec les sources choisies par points
Set mesTRREF = .getelementbyID("tableref").getelementsbytagname("TR")
Set synthP = .getelementbyID("synthP")
For i = 0 To mesTRREF.Length - 1
For z = 1 To mesTRREF(i).Children.Length - 1
dicopat(mesTRREF(i).Children(z).innertext) = dicopat(mesTRREF(i).Children(z).innertext) + (8 - (z - 1))
Next
Next
Do
num = num + 1: old = 0
For Each elem In dicopat
If dicopat(elem) > old Then old = dicopat(elem): items = elem
Next
'MsgBox items & " : " & dicopat(items)
dicopat(items) = 0
synthP.Children(num).innertext = items
Loop Until num = dicopat.Count
'****************************************************************************
Set synthS = .getelementbyID("synthS")
Set synthW = .getelementbyID("synthW")
Set mesthref = .getelementbyID("tableref").getelementsbytagname("TH")
' remplissage des chevauc de la ligne syntheze par point dans le dicoseb
For i = 1 To synthW.Children.Length - 1
If synthW.Children(i).innertext <> "" Then dicoseb(Val(synthW.Children(i).innertext)) = ""
Next
'remplissage des point dans le dicoseb par raport au nombre de fois cité dans la table de source choisies
For z = 0 To mesthref.Length - 1
If dicoseb.exists(Val(mesthref(z).innertext)) Then dicoseb(Val(mesthref(z).innertext)) = Val(dicoseb(Val(mesthref(z).innertext))) + 1
Next
'retranscription dans le meme ordre que la ligne syntheze par point dans la ligne syntheze sebphyto
z = 0
For lMax = 5 To 0 Step -1
For i = 1 To synthW.Children.Length - 1
If Val(dicoseb(Val(synthW.Children(i).innertext))) = lMax Then z = z + 1: synthS.Children(z).innertext = synthW.Children(i).innertext
Next
Next
'************************************************************************************
'************************************************************
'on suprime tout les image et le gif blanks
For Each elem In .all
If elem.tagname = "IMG" Then code = Replace(.body.innerhtml, elem.outerhtml, "")
Next
If .parentWindow.clipboardData.setData("Text", code) Then
Application.ScreenUpdating = False
With Sheets(1)
.Activate
'.Cells.Clear
Cells(Rows.Count, 1).End(xlUp).Offset(2, 0).Select
.Paste
End With
.parentWindow.clipboardData.clearData "Text"
End If
End With
End Sub |
Partager