Sub test()
url = "https://www.tennisbrain.com/"
t = getHTMLtable(url)
End Sub
Function getHTMLtable(url)
Dim TRS, TDS, DIVS, TD, TD2
With CreateObject("microsoft.xmlhttp")
.Open "get", url, False
.send
code = .responsetext
End With
With CreateObject("htmlfile")
.body.innerhtml = code
.body.innerhtml = .getelementsbytagname("TABLE")(1).outerhtml
Set TRS = .getelementsbytagname("TR")
For Each elem In TRS
If elem.innerhtml Like "*Profile*" Then elem.Parentelement.RemoveChild (elem)
'restructuration et replacement de la ligne des "%"
Set DIVS = elem.getelementsbytagname("DIV")
If DIVS.Length = 2 Then
Set TD = .createelement("TD"): TD.innerhtml = DIVS(0).innertext:
Set TD2 = .createelement("TD"): TD2.innerhtml = DIVS(1).innertext
For Each childs In elem.ChildNodes: elem.RemoveChild (childs): Next
elem.appendchild (TD): elem.appendchild (TD2)
End If
Next
'memorisation dans le clipborad au format html
.parentwindow.clipboardData.setData "Text", "<html>" & .body.innerhtml & "</html>"
End With
With ActiveSheet: .UsedRange.Clear: .Cells(1).Select: .Paste: .UsedRange.HorizontalAlignment = xlCenter: End With
End Function