surfersparadise
New Member
- Joined
- Feb 23, 2014
- Messages
- 4
Hello,
I'm trying to extract a table Additional Info from the website that is in the code, but failing so far. There is mistake with wrong class name or other variable. Could anyone suggest how to make it work?
I'm trying to extract a table Additional Info from the website that is in the code, but failing so far. There is mistake with wrong class name or other variable. Could anyone suggest how to make it work?
Code:
Sub AdditionalInfo()
Dim oDom As Object: Set oDom = CreateObject("htmlFile")
Dim x As Long, y As Long
Dim oRow As Object, oCell As Object
Dim data, aTable As Object
y = 1: x = 1
With CreateObject("msxml2.xmlhttp")
.Open "GET", "http://uk.soccerway.com/matches/2014/02/23/england/premier-league/liverpool-fc/swansea-city-afc/1483721/?ICID=HP_MS_01_01", False
.send
oDom.body.innerhtml = .responsetext
End With
For Each aTable In oDom.getelementsbytagname("table")
If Trim(LCase(aTable.classname)) = "Additional info" Then
With aTable
ReDim data(1 To .Rows.Length, 1 To .Rows(1).Cells.Length)
For Each oRow In .Rows
For Each oCell In oRow.Cells
data(x, y) = oCell.innertext
y = y + 1
Next oCell
y = 1
x = x + 1
Next oRow
End With
Exit For
End If
Next aTable
With Sheets(2).Cells(1, 1)
.CurrentRegion.ClearContents
If IsArray(data) Then
.Resize(UBound(data), UBound(data, 2)).Value = data
Else: MsgBox "Table not found"
End If
End With
End Sub