|
By:
You'll find almost all languages have inbuilt JSON decoders so it's actually very simple to extract and use the info. I usually just use a bit of regex to grab any JSON code from the page then use the decoders to stick it into a standard array which you should then be able to use the info the same as you'd do for any other multidimensional array.
.NET and C++ are bound to have JSON decoders either built in or available as functions, just search if they're not in your manual |
|
By:
JSON makes getting Betfair data easy:
e.g. getting odds for the 17:05 at Newmarket today, there are two URLs: http://uk.site.sports.betfair.com/betting/api/json/getBootstrapData.do?mi=103519456 This gives you all the market data, rules, horse names and so on. To just refresh the odds, instead use: http://uk.site.sports.betfair.com/betting/api/json/getPartialMarketData.do?mi=103519456 Parsing the output is easy, as there are JSON decoders for every language out there: http://www.json.org/ It's even vaguely human-readable, unlike most XML. Oh, you will need to trim some of the output of those URLs, they start with a short line of javascript before the JSON follows. |
|
By:
BRILLIANT ! Just what I was looking for..... Thankyou
Knowing nada about JSON I had kind of assumed I would need to dynamically create a java script, and do an HTTP post/get and it would be a lot more faffing about than just posting a URL and parsing the result. can I ask how one acertains the URL ( not the "?mi=103519456" part as I realise that is the market query ) but http://uk.site.sports.betfair.com/betting/api/json/getPartialMarketData did you just glean it from manually ( visually ) examining betfairs web page source ? or is there an elegant way of say determining any acessible json on any web page ? Thanks again to you both for taking the time to help me out. |
|
By:
I just got the URL's from using an HTTP sniffer something like HTTP Watch that lets you see the url's the web pages are actually accessing within the framesets.
Like Mr Magoo states the only url's you need are the following http://uk.site.sports.betfair.com/betting/api/json/getBootstrapData.do?mi=103519456 http://uk.site.sports.betfair.com/betting/api/json/getFullMarketData.do?mi=103519456 http://uk.site.sports.betfair.com/betting/api/json/getPartialMarketData.do?mi=103519456 They basically populate the web page of all the info needed like runner name etc and once all fields are filled getPartialMarketData.do is then called to update price data only. Think the only thing you need to parse out of the page is the while(1) {}; as that's used by the javascript, all the remaining data in the page is the json data which is easily decoded |
|
By:
Thanks Joe, I've just gotta pop out for a few hours but will come back and maybe add a question or two later
thanks again |
|
By:
No problem.
A lot depends on what you want to do with the data as web scraping or using the API both have advantages and disadvantages. Remember if you're scraping you'll need to be logged in and sending the correct cookies etc as they do delay the data, plus all calls are charged doubled the api if you hit data request territory. If you want the x match prices it may turn out to be easier just to code it into your app using the algorithm available at http://bdp.betfair.com/index.php?option=com_content&task=view&id=237&Itemid=62 rather than trying to mix and match the API and web scrape. |