map200uk Posted February 4, 2008 Share Posted February 4, 2008 Hi, I am trying to figure out how to extract the data i want from betfair-i figure using the lite version of betfair would be easier (lite.betfair.com) however i am a bit stuck on a couple of issues: http://lite.betfair.com/Market.do?s=00010920777112x1z Markets > Boxing > April Bouts > Bouts 19 April I would like each of those as their own variable - str_replace on > would solve that i believe However when we come to the table I am not sure quite how to handle it - the table as shown in the link has 4 rows, 3 columns I would like to extract each value from the table rows/columns as it's own variable, and then be able to use these at a later date. I'm not sure where to start, and how to extract data from the table and make sure that data in the third column is assigned to say 'lay1' 'lay2' on the lay side of things thanks Mark Quote Link to comment https://forums.phpfreaks.com/topic/89297-help-with-extracting-data/ Share on other sites More sharing options...
map200uk Posted February 4, 2008 Author Share Posted February 4, 2008 someone must be able to help? I'ts just the table... Quote Link to comment https://forums.phpfreaks.com/topic/89297-help-with-extracting-data/#findComment-457267 Share on other sites More sharing options...
mikefrederick Posted February 4, 2008 Share Posted February 4, 2008 you want to grab the data from betfair and extract it to your website and store it, correct? Quote Link to comment https://forums.phpfreaks.com/topic/89297-help-with-extracting-data/#findComment-457269 Share on other sites More sharing options...
map200uk Posted February 4, 2008 Author Share Posted February 4, 2008 yep, thats correct, the lite version-the normal version www.betfair.com would be way too hard the thing is , if you look at http://lite.betfair.com/Market.do?s=00010920777112x1z You see the table, that's what im not sure what to do with? How to extract the data from the table Thanks for replying mate - if you have any suggestions / help i do appreciate it Quote Link to comment https://forums.phpfreaks.com/topic/89297-help-with-extracting-data/#findComment-457272 Share on other sites More sharing options...
sasa Posted February 4, 2008 Share Posted February 4, 2008 try <?php $a = '<html lang="en"><head><title>Betfair Lite - Markets</title><meta http-equiv="content-type" content="text/html; charset=utf-8"/><meta http-equiv="expires" content="Thu, 16 Mar 2000 11:00:00 GMT"/><meta http-equiv="pragma" content="no-cache"/><style type="text/css">body,td,p, span{font-family: arial,verdana, tahoma;color: rgb(0,0,0);}div.backgroundwhite {background-color: white;padding:7px;border:1px black solid;}div.backgroundback {background-color: #CCCCFF;padding:7px;border:1px black solid;}div.backgroundlay {background-color: #FFFFCC;padding:7px;border:1px black solid;}span.red {color: #ff0000;}span.green {color: #4AA02C;}a:link { color: #003399;}a:visited { color: #003399;}a:active { color: #003399;}table.standard {border-width: 1px;border-spacing: 3px;border-style: outset;border-color: white;border-collapse: separate;background-color: white;width:100%}table.standard td,th {border-width: 1px;padding: 2px;border-style: inset;border-color: #CCCCCC;background-color: white;-moz-border-radius: ;}table.standard td.back,th.back {background-color: #CCCCFF;text-align: center;}table.standard td.lay,th.lay {background-color: #FFFFCC;text-align: center;}form {margin: 0px;padding: 0px;}}</style></head><body><div><a id="top"></a><img src=\'images/betfair_tiny.gif\' alt=\' Betfair Logo\'/><br/><a href="Default.do?s=000109x1z" accesskey="1">Home</a> | <strong><a href="Events.do?s=000109x1z" accesskey="2">Markets</a></strong> | <a href="Mybets.do?s=000109x1z" accesskey="3">My Bets</a> | <a href="Results.do?s=000109x1z" accesskey="4">Results</a> | <a href="Login.do?s=00010920777112x1z-redirectMarket" accesskey="5">Login</a> | <a href="Market.do?s=00010920777112x1z" accesskey="6">Refresh</a><hr/><a href="Events.do?s=000109x1z">Markets</a> > <a href=\'Events.do?s=0001096x1z\'>Boxing</a> > <a href=\'Events.do?s=00010910838843x1z\'>April Bouts</a> > <a href=\'Events.do?s=00010916938687x1z\'>Bouts 19 April</a><hr/><a href="#marketinfo">Market Information</a> <a href="Login.do?s=00010920777112x1z-redirectMarket"> <strong>Log in to bet</strong></a><hr/><strong>Hopkins v Calzaghe</strong><br/> <table class="standard" summary="The market view"><tr><th abbr="Selections"><strong>Selections</strong> (3)</th><th abbr="Back" class="back"><strong>Back</strong> (105.1%)</th><th abbr="Lay" class="lay"><strong>Lay</strong> (92.3%)<br/></th></tr><tr><td>Bernard Hopkins </td><td class="back"> <strong>3.3</strong> ($98)</td><td class="lay"> <strong>4.3</strong> ($88)<br/></td></tr><tr><td>Joe Calzaghe </td><td class="back"> <strong>1.42</strong> ($70)</td><td class="lay"> <strong>1.51</strong> ($199)<br/></td></tr><tr><td>Draw </td><td class="back"> <strong>23.0</strong> ($99)</td><td class="lay"> <strong>36.0</strong> ($4)<br/></td></tr></table><strong>Total Matched</strong>: $1,863.45<br/><a name="marketinfo"></a><strong>Market Information</strong>: 20 Apr - 2:00 BST <b>Market Information</b><br> Boxing. Who will win this fight? This market will be turned in play at the start of the first round with unmatched bets cancelled, thereafter unmatched bets will not be cancelled by Betfair at any time. For further information please see our <a href=http://content.betfair.com/aboutus/content.asp?sWhichKey=Rules%20and%20Regulations#undefined.do style=color:0163ad; text-decoration: underline; target=_blank>Rules & Regs.</a><br><br><b>Customers should be aware that:<br><br><li>Transmissions described as “live” by some broadcasters may actually be delayed</li><br><li>The extent of any such delay may vary between customers, depending on the set-up through which they are receiving pictures or data.</li></b><br/><strong>Commission</strong>: 5.0% (Minus your discount)<br/><br/><a href="#top">Top</a><hr/>© 2007 The Sporting Exchange Limited. All rights reserved. <br><a href="http://www.gamcare.org.uk/"><img border=0 src="/images/eighteenplus.gif" alt="18+"><img border=0 src="/images/gamcarelogo.gif" alt="Gamcare"></a><br>Licensed and regulated by the <a href="http://www.gamblingcommission.gov.uk">Gambling Commission (UK)</a></div></body></html>'; preg_match('/<th[^>]*>.*<\/th[^>]*>/',$a,$b); $th_row = $b[0]; $th_row = strip_tags($b[0],'<th>'); preg_match_all('/>([^<]+)</',$th_row, $b); $th_row = $b[0]; preg_match('/<td[^>]*>.*<\/td>/',$a,$b); $data = strip_tags($b[0],'<td>'); preg_match_all('/>([^<]+)</',$data, $c); $data = array_chunk($c[1],count($th_row)); print_r($th_row); print_r($data); ?> Quote Link to comment https://forums.phpfreaks.com/topic/89297-help-with-extracting-data/#findComment-457421 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.