More on Data Scraping using Excel/VBA


This is Data Scraping in its simplest form.  Since I still haven’t mastered PHP, Python, etc.., more dynamic programming languages, I have to resort to the user friendliness that Excel provides.  Whatever works.

Taking the Statfox Extraction post a step further.  Hesitant to share this but in all honesty its just programming logic, most of this stuff is turning rational statements into encoded properties that can be processed by Visual Basic.

Here is how to get average lines, using the statfox set up as the base.

Sub Averagelines()
Dim sht As String
Dim i As Integer
Dim c As Range
Dim avar As Long
Dim cnt As Integer
avar = 0
cnt = 0
 
i = 1
 
For i = 1 To Range("teams").Rows.Count
 
sht = Range("teams").Cells(i, 1).Value
For Each c In Sheets(sht).Range("c1:c50")
If IsNumber(c.value)  Then
avar = avar + c.Value
cnt = cnt + 1
 
End If
 
Next
Range("teams").Cells(i, 1).Offset(0, 'columnx').Value = avar / cnt
Range("teams").Cells(i, 1).Offset(0, 'columny').Value = cnt

cnt = 0
avar = 0
 
Next i
 
End Sub

Again this gets the average line for each team and outputs the number of lined games played next to each line, and to get the home (or away) lines

Sub Averagelines()
Dim sht As String
Dim i As Integer
Dim c As Range
Dim avar As Long
Dim cnt As Integer
avar = 0
cnt = 0
 
i = 1
 
For i = 1 To Range("teams").Rows.Count
 
sht = Range("teams").Cells(i, 1).Value
For Each c In Sheets(sht).Range("b1:b50")
If InStr(c.Value, "vs ") And IsNumber(c.offset(0,1).value) Then
 
avar = avar + c.Offset(0, 1).Value
cnt = cnt + 1
 
End If
 
Next
Range("teams").Cells(i, 1).Offset(0, 'columnx').Value = avar / cnt
Range("teams").Cells(i, 1).Offset(0, 'columny').Value = cnt

cnt = 0
avar = 0
 
Next i
 
End Sub

You can use the same concept to extract Wins, Losses, Totals, Stats, ATS W/L, opponents’ average line, among some other things.

Like I said I’m hesitant to share this for this entire process worked wonders for college basketball and the NBA, and I would like to think that I have an edge over the rest of the herd of degenerates, but I’m as big of a sucker/square/degenerate/mouthbreather as anybody else.

Do with it what you will.

  • Share/Bookmark

Related posts:

  1. Extracting Data/Stats from StatFox for College Football
  2. Updated NBA Playoffs Excel Sheet
  3. NCAAB Teams ATS and Final Four
  4. Lakers vs Boston Finals Breakdown
  1. No comments yet.

You must be logged in to post a comment.