fredrerik84
Active Member
- Joined
- Feb 26, 2017
- Messages
- 383
Hi I would like to start this thread to thank the community here and especially Domenic for helping me together the code bellow:
but I have made some changes to this code as this page has also "all_games" link so the line in red above will be: IE.Navigate "http://www.xscores.com/soccer/all_games/24-05" but this gives following problem: as this is just as summerize page for Finished_games, Live_games and up_comming games so this site handles this with adding an Add in the middle of the list. , Is there an way/code I can try to jump over this without going into infinite loop Any help would be greatly appreciated , my sulltion is to run the code from 3 links but I relly hope there is an better way
Rich (BB code):
Rich (BB code):
Set HTMLDoc = IE.document
Sub testing2()
Dim IE As New SHDocVw.InternetExplorer
Dim HTMLDoc As New MSHTML.HTMLDocument
Dim HTMLRows As MSHTML.IHTMLElementCollection
Dim HTMLRow As MSHTML.IHTMLElement
Dim League As String
Dim sheet As Worksheet
Dim r As Long
Dim i As Long
Dim j As Long
Dim K As Long
Dim vMatch As Variant
Set sheet = ActiveWorkbook.Sheets("Conversion")
IE.Navigate "http://www.xscores.com/soccer/scheduled_games/24-05"
IE.Visible = True
With IE
Do While .Busy Or .readyState <> READYSTATE_COMPLETE
DoEvents
Loop
End With
Set HTMLDoc = IE.document
Set HTMLRows = HTMLDoc.getElementById("scoretable").getElementsByTagName("tr")
Columns("B:F").ClearContents
Columns("B:F").Borders.LineStyle = xlNone
r = 2
For i = 0 To HTMLRows.Length - 3
If HTMLRows(i).Cells.Length - 1 >= 10 Then
Cells(r, "B").Value = HTMLRows(i).Cells(0).innerText
Cells(r, "B").Borders(xlEdgeLeft).Color = RGB(91, 155, 213)
League = HTMLRows(i).Cells(IIf(i > 0, 4, 3)).innerText
Cells(r, "C").Value = League
vMatch = Application.VLookup(League, sheet.Range("V1:X62"), 3, False)
If Not IsError(vMatch) Then
Cells(r, "C").Value = vMatch
Else
Cells(r, "C").Value = League
End If
Cells(r, "D").Value = HTMLRows(i).Cells(IIf(i > 0, 5, 4)).innerText & " (" & HTMLRows(i).Cells(IIf(i > 0, 6, 5)).innerText & ")"
If i > 0 Then
Cells(r, "E").Value = GetCountry(HTMLRows(i).Cells(3).getElementsByTagName("a")(0).getAttribute("title"))
Else
Cells(r, "E").Value = "Country"
End If
Cells(r, "F").Value = HTMLRows(i).Cells(IIf(i > 0, 9, 7)).innerText & " (" & HTMLRows(i).Cells(IIf(i > 0, 10, 8)).innerText & ")"
Cells(r, "F").Borders(xlEdgeRight).Color = RGB(91, 155, 213)
r = r + 1
End If
Next i
Cells(r - 1, 2).Resize(, 5).Borders(xlEdgeBottom).Color = RGB(91, 155, 213)
MsgBox i - 4 & " Matches has been Loaded.", vbInformation
IE.Quit
Set HTMLDoc = Nothing
Set HTMLRows = Nothing
Set HTMLRow = Nothing
End Sub
but I have made some changes to this code as this page has also "all_games" link so the line in red above will be: IE.Navigate "http://www.xscores.com/soccer/all_games/24-05" but this gives following problem: as this is just as summerize page for Finished_games, Live_games and up_comming games so this site handles this with adding an Add in the middle of the list. , Is there an way/code I can try to jump over this without going into infinite loop Any help would be greatly appreciated , my sulltion is to run the code from 3 links but I relly hope there is an better way
Last edited: