|
|||||||
| Capping All handicapping, betting systems, spreadsheets, mathematics & quantitative technicapping. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Grabbing Pinnacle Lines with Excel and DOM
DOM (Document Object Model) is one of the many HTML/XML to programming language routines that use a common toolbox for which to call its properties. Fortunately for us, Visual Basic, Java, PHP, etc… all integrate these toolbox routines in order to grab and manipulate information given a particular XML/HTML source. For a general information scraper, its one of the more expansive and user-friendly, though with simplicity comes limitations. However, such limitations pose very little concern for extracting basic information from a website. DOM doesn’t necessarily promote dynamic streaming information parsing, because DOM typically requires the document source to be loaded in complete form into memory. If you think of DOM as a branching tree, with each element a branch, or “child”, or its root, or “parent”, then its obvious why the information must be in some way stored in memory before the various DOM elements can be called.
DOM can be more useful in extracting box scores or season statistics. Such data is in a complete state and does not require any other web and programming integration to grab information that is changing, as opposed to line movement or live game updates. Below is the code for extracting NCAA lines and matchups via Pinnacle’s XML feed using Excel. Excel’s VBA Modules allows these DOM properties to be implemented, after referencing the relevant toolbox routines. So before accessing the DOM methods, create a reference to Microsoft XML, v6.0 ![]() Pinnacle’s full XML feed is located at: Code:
http://xml.pinnaclesports.com/pinnacleFeed.aspx? ![]() The URL parameters are given above, so to access solely the lines for NCAA football, use the following parameters: Code:
http://xml.pinnaclesports.com/pinnaclefeed.aspx?sporttype=Football&sportsubtype=NCAA Code:
<game> <date>10/23</date> <hometeam>USC</hometeam> <roadeam>Oregon</roadteam> </game> Each element in the document is numbered sequentially from an initial value of zero. Therefore to grab just the home team from above, its DOM properties translate to the second child node, childnode(1), of the parent node “game”. The VB code is honestly rather self explanatory from there. Some trial and error and a google search or two is needed in order to find the right properties and naming conventions to fit the programming language. Excel is user-friendly enough to provide all the properties available for the particular function required. Code:
Sub XML_Pinny()
Dim xmlLoad As New MSXML2.DOMDocument
Dim allevents As IXMLDOMNode
Dim eventslen As Integer
Dim events As IXMLDOMNode
Dim XMLHttpRequest As MSXML2.xmlhttp
Dim i As Integer
Dim URL As String
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
On Error Resume Next
URL = "http://xml.pinnaclesports.com/pinnaclefeed.aspx?sporttype=Football&sportsubtype=NCAA"
Set XMLHttpRequest = New MSXML2.xmlhttp
XMLHttpRequest.Open "GET", URL, False
XMLHttpRequest.send
Set xmlLoad = New MSXML2.DOMDocument
Do Until xmlLoad.readyState = 4
Loop
xmlLoad.LoadXML (XMLHttpRequest.responseText)
Sheets("Sheet1").Range("A1").Value = xmlLoad.DocumentElement.ChildNodes(0).FirstChild.Text
Set allevents = xmlLoad.DocumentElement.ChildNodes(3)
eventslen = allevents.ChildNodes.Length
Sheets("Sheet1").Range("B1").Value = eventslen
i = 0
For i = 0 To (eventslen - 1) Step 1
Set events = allevents.ChildNodes(i)
Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp)(2, 1) = events.FirstChild.Text
Sheets("Sheet1").Cells(Rows.Count, 2).End(xlUp)(2, 1) = events.ChildNodes(5).ChildNodes(0).FirstChild.Text
Sheets("Sheet1").Cells(Rows.Count, 4).End(xlUp)(2, 1) = events.ChildNodes(5).ChildNodes(1).FirstChild.Text
Sheets("Sheet1").Cells(Rows.Count, 3).End(xlUp)(2, 1) = events.LastChild.FirstChild.SelectSingleNode("spread").FirstChild.Text & " " & events.LastChild.FirstChild.SelectSingleNode("spread").ChildNodes(1).Text
Sheets("Sheet1").Cells(Rows.Count, 5).End(xlUp)(2, 1) = events.LastChild.FirstChild.SelectSingleNode("spread").ChildNodes(2).Text & " " & events.LastChild.FirstChild.SelectSingleNode("spread").ChildNodes(3).Text
Next i
Set xmlLoad = Nothing
Set allevents = Nothing
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
'Application.OnTime Now + TimeValue("00:02:00"), "XML_Pinny"
End Sub
The lines: Code:
Do Until xmlLoad.readyState = 4
Loop
Remove the comment from the final line to run the program every two minutes. The final result should look something like this:
__________________
"Nobody goes there anymore, its too crowded." --Yogi Berra "Always tell the truth, that way you won't have to remember what you said." --Mark Twain *=$50,000 Last edited by uva3021; 10-27-2010 at 04:17 PM. |
|
#2
|
|||
|
|||
|
<tup>
__________________
The only bridge I've ever burned along this legacy I dance is the one that linked the cities of prosperity and chance Check out Technicapping for quantitative sport analysis |
|
#3
|
|||
|
|||
|
Been getting a lot of PMs over at sbr about this, bumperoo for relevance
Post here if you want the MLB version, though with the provided instructions you should be able to do it yourself
__________________
"Nobody goes there anymore, its too crowded." --Yogi Berra "Always tell the truth, that way you won't have to remember what you said." --Mark Twain *=$50,000 |
|
#4
|
|||
|
|||
|
Follow up on Offer for MLB
I will take you up on your offer, for the MLB version.
Thank you in advance Pancho |
|
#5
|
|||
|
|||
|
Unzip the file, enable macros, Click the "GET" button
__________________
"Nobody goes there anymore, its too crowded." --Yogi Berra "Always tell the truth, that way you won't have to remember what you said." --Mark Twain *=$50,000 |
|
#6
|
|||
|
|||
|
Thank you UV, works great
|
|
#7
|
|||
|
|||
|
When I click the button it says the macro can't run. Ideas?
|
|
#8
|
|||
|
|||
|
What exactly does the error message say? It may be a security issue, check your security options and make sure macros are enabled.
__________________
"Nobody goes there anymore, its too crowded." --Yogi Berra "Always tell the truth, that way you won't have to remember what you said." --Mark Twain *=$50,000 |
|
#9
|
|||
|
|||
|
I checked the security, it should be fine. "Cannot run the macro 'MLB_Pinnacle.xlsm!Button_3Click'." The macro may not be available in this workbook or all macros may be disabled (which they aren't).
But when I go to Macros and run XML_Pinny it works |
|
#10
|
|||
|
|||
|
Nevermind figured it out. Thanks!
|
|
#11
|
|||
|
|||
|
I'll take you up on your offer, for the MLB version.
Thanks foe advice |
|
#12
|
|||
|
|||
|
Any recommendations that are Mac friendly? Excel for Mac 2011 (with vba support) but no MS XML availability.
|
|
#13
|
|||
|
|||
|
i'll work on one for javascript
__________________
"Nobody goes there anymore, its too crowded." --Yogi Berra "Always tell the truth, that way you won't have to remember what you said." --Mark Twain *=$50,000 |
|
#14
|
|||
|
|||
|
hi, uva did you look into a mac friendly version? thanks
|
|
#15
|
|||
|
|||
|
here is a php version to screen scrape MLB odds, it outputs in a plain html style page with comma delimited fields
in order to run you need to have server space, or just download xampp and run a virtual server from your computer if you want to have server space, signing up for a quick blogspot page might actually be worth the trouble just to have the ability to run local php files PHP Code:
__________________
"Nobody goes there anymore, its too crowded." --Yogi Berra "Always tell the truth, that way you won't have to remember what you said." --Mark Twain *=$50,000 |
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
All times are GMT -5. The time now is 05:47 PM.










Linear Mode

