I have this html table:
<tbody>
<tr class="r1">
<td class="l rbrd">
<img class="spr2 sport sp1" align="absmiddle" src="/s.gif">
</td>
<td class="l rbrd">19/4 18:30</td>
<td class="l rbrd">
<a title="CHELSEA FC - SUNDERLAND" href="/chelsea-fc-vs-sunderland/e/4509648/" target="_blank">CHELSEA FC - SUNDERLAND</a>
</td>
<td class="c w40">
<span class="o">1,21</span>
<span class="p">91,8%</span>
</td>
</tr>
There are more than one hundred <"tr"> structured at the same way, which contain lots of <"td">. How can i loop with xpath to store all data in a database?
This is my php code, but i can not go on.. help!
<?php
$curl = curl_init('http://www.oxybet.ro/pariu/external/betfair-volumes.htm');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.224 Safari/534.10');
$html = curl_exec($curl);
curl_close($curl);
if (!$html) {
die("something's wrong!");
}
$dom = new DOMDocument();
@$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$scores = array();
$tableRows = $xpath->query('//div//div//div[2]//div/div//table');
foreach ($tableRows->tr as $row) {
$td = $xpath->query('td', $row);
// we'll store information about each match in this array
$match = array();
...
}
Final result:
[0] => Array
(
[date] => 18:30 19/4
[teams] => CHELSEA FC - SUNDERLAND
[1] => 1,21
[1 volumes] => 91,8%
)