Sub webscraping()
Dim i As Long
Dim tbl As Variant
Dim doc As HTMLDocument
Dim ie As InternetExplorer
Dim table As HTMLTable
Set ie = New InternetExplorer
With ie
.Visible = True
.Navigate "http://www.gbgb.org.uk/RaceCard.aspx?dogName=Raparee%20Holly"
End With
Do While ie.ReadyState <> 4: DoEvents: Loop
Set doc = ie.Document
Set table = doc.getElementById("ctl00_ctl00_mainContent_cmscontent_DogRaceCard_lvDogRaceCard_ctl00")
With table
ReDim tbl(0 To .Rows.Length - 2, 0 To .Rows(1).Cells.Length)
For x = 0 To UBound(tbl, 1) - 1
For y = 0 To UBound(tbl, 2) - 1
tbl(x, y) = .Rows(x).Cells(y).innerText
Next
Next
End With
Range("A1").Resize(x, y) = tbl
ie.Quit
End Sub
Sub Ombir_04Dec2016()
Dim i As Long
Dim tbl As Variant
Dim doc As HTMLDocument
Dim ie As InternetExplorer
Dim table As HTMLTable
Dim pinput As HTMLInputTextElement
Set ie = New InternetExplorer
With ie
.Visible = True
.Navigate "http://www.gbgb.org.uk/RaceCard.aspx?dogName=Raparee%20Holly"
Do While ie.ReadyState <> 4: DoEvents: Loop
End With
Set doc = ie.Document
Set pinput = doc.getElementById("ctl00_ctl00_mainContent_cmscontent_DogRaceCard_lvDogRaceCard_ctl00_ctl03_ctl01_PageSizeComboBox_Input")
pinput.Focus
Application.SendKeys "100{RETURN}"
Application.Wait Now() + TimeValue("00:00:02")
Do While ie.Busy: DoEvents: Loop
Set table = doc.getElementById("ctl00_ctl00_mainContent_cmscontent_DogRaceCard_lvDogRaceCard_ctl00")
With table
ReDim tbl(0 To .Rows.Length - 1, 0 To .Rows(1).Cells.Length)
For x = 0 To UBound(tbl, 1)
For y = 0 To UBound(tbl, 2) - 1
On Error Resume Next
tbl(x, y) = .Rows(x).Cells(y).innerText
Next
Next
End With
Range("A1").Resize(x, y) = tbl
ie.Quit
End Sub