Подскажите пожалуйста как указать границу регулярками в php
.
Необходимо спарсить 12
ячеек начиная со слова bet365
.
<table cellspacing="1" cellpadding="0" width="95%" align="center" border="0" class="oddstable">
<tbody>
<tr align="center" class="scoretitle">
<td height="25" colspan="16">[International Club Friendly]
<script>
showDate(2019, 01 - 1, 16, 00, 00, 00);
</script>01-16 02:00 Zamora Barinas(H)
<font color="yellow">VS</font> Deportivo Metropolitano <a href="javascript:dataFeedBack(2,1657616)" style="color:blue;">[Data Feedback]</a></td>
</tr>
<tr align="center" class="Leaguestitle" height="25">
<td width="15%" rowspan="2"><b>Company</b></td>
<td colspan="5"><b>1x2 Odds</b></td>
<td rowspan="15" width="2%" class="b1"> </td>
<td colspan="4"><b>Handicap Odds</b></td>
<td rowspan="15" width="2%" class="b1"> </td>
<td colspan="4"><b>Over/Under Odds</b></td>
</tr>
<tr align="center" class="Leaguestitle" height="25">
<td>HW</td>
<td>D</td>
<td>AW</td>
<td>Return</td>
<td>Data</td>
<td>Home</td>
<td>Odds</td>
<td>Away</td>
<td>Data</td>
<td>Over</td>
<td>Odds</td>
<td>Under</td>
<td>Data</td>
</tr>
<tr align="center" class="b1">
<td width="12%" height="25">Sbobet
<font color="red">Live</font>
</td>
<td width="7%"></td>
<td width="7%"></td>
<td width="7%"></td>
<td width="7%"></td>
<td width="5%"></td>
<td width="6%">0.75<br><span class="">0.75</span></td>
<td width="6%">0.5/1<br><span class="">0.5/1</span></td>
<td width="6%">1.05<br><span class="">1.05</span></td>
<td width="6%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/31_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/1_31_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
<td width="6%">0.75<br><span class="">0.75</span></td>
<td width="6%">2/2.5<br><span class="">2/2.5</span></td>
<td width="6%">1.05<br><span class="">1.05</span></td>
<td width="6%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/31_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/3_31_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr align="center" class="b2">
<td width="12%" height="25">12bet
<font color="red">Live</font>
</td>
<td width="7%">1.51<br><span class="">1.51</span></td>
<td width="7%">3.65<br><span class="">3.65</span></td>
<td width="7%">5.40<br><span class="">5.40</span></td>
<td width="7%">89.2%</td>
<td width="5%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/24_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/5_24_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
<td width="6%">1.02<br><span class="">1.02</span></td>
<td width="6%">1<br><span class="">1</span></td>
<td width="6%">0.78<br><span class="">0.78</span></td>
<td width="6%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/24_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/1_24_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
<td width="6%">1.04<br><span class="">1.04</span></td>
<td width="6%">2.5<br><span class="">2.5</span></td>
<td width="6%">0.76<br><span class="">0.76</span></td>
<td width="6%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/24_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/3_24_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr align="center" class="b1">
<td width="12%" height="25">188bet
<font color="red">Live</font>
</td>
<td width="7%">1.48<br><span class="up">1.57</span></td>
<td width="7%">3.75<br><span class="up">3.85</span></td>
<td width="7%">4.75<br><span class="down">4.45</span></td>
<td width="7%">89.2%</td>
<td width="5%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/23_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/5_23_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
<td width="6%">0.91<br><span class="up">1.08</span></td>
<td width="6%">1<br><span class="">1</span></td>
<td width="6%">0.79<br><span class="down">0.76</span></td>
<td width="6%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/23_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/1_23_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
<td width="6%">0.81<br><span class="up">0.98</span></td>
<td width="6%">2.5<br><span class="">2.5</span></td>
<td width="6%">0.89<br><span class="down">0.84</span></td>
<td width="6%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/23_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/3_23_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr align="center" class="b2">
<td width="12%" height="25">10BET
<font color="red">Live</font>
</td>
<td width="7%">1.58<br><span class="down">1.55</span></td>
<td width="7%">3.70<br><span class="down">3.55</span></td>
<td width="7%">5.10<br><span class="up">5.40</span></td>
<td width="7%">89.9%</td>
<td width="5%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/22_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/5_22_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
<td width="6%">0.78<br><span class="">0.78</span></td>
<td width="6%">0.5/1<br><span class="">0.5/1</span></td>
<td width="6%">1.04<br><span class="">1.04</span></td>
<td width="6%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/22_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/1_22_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
<td width="6%">0.99<br><span class="">0.99</span></td>
<td width="6%">2.5<br><span class="">2.5</span></td>
<td width="6%">0.83<br><span class="">0.83</span></td>
<td width="6%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/22_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/3_22_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr align="center" class="b1">
<td width="12%" height="25">M88
<font color="red">Live</font>
</td>
<td width="7%">1.52<br><span class="">1.52</span></td>
<td width="7%">3.65<br><span class="">3.65</span></td>
<td width="7%">5.40<br><span class="">5.40</span></td>
<td width="7%">89.5%</td>
<td width="5%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/17_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/5_17_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
<td width="6%">1.02<br><span class="">1.02</span></td>
<td width="6%">1<br><span class="">1</span></td>
<td width="6%">0.78<br><span class="">0.78</span></td>
<td width="6%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/17_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/1_17_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
<td width="6%">1.04<br><span class="">1.04</span></td>
<td width="6%">2.5<br><span class="">2.5</span></td>
<td width="6%">0.76<br><span class="">0.76</span></td>
<td width="6%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/17_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/3_17_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr align="center" class="b2">
<td width="12%" height="25">Vcbet</td>
<td width="7%">1.50<br><span class="up">1.53</span></td>
<td width="7%">3.75<br><span class="down">3.60</span></td>
<td width="7%">5.40<br><span class="down">5.25</span></td>
<td width="7%">89.1%</td>
<td width="5%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/14_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/5_14_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
<td width="6%">0.97<br><span class="up">1.05</span></td>
<td width="6%">1<br><span class="">1</span></td>
<td width="6%">0.84<br><span class="down">0.77</span></td>
<td width="6%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/14_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/1_14_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
<td width="6%">0.83<br><span class="up">0.92</span></td>
<td width="6%">2.5<br><span class="">2.5</span></td>
<td width="6%">0.91<br><span class="down">0.80</span></td>
<td width="6%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/14_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/3_14_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr align="center" class="b1">
<td width="12%" height="25">Easybet</td>
<td width="7%"></td>
<td width="7%"></td>
<td width="7%"></td>
<td width="7%"></td>
<td width="5%"></td>
<td width="6%"></td>
<td width="6%"></td>
<td width="6%"></td>
<td width="6%"></td>
<td width="6%"></td>
<td width="6%"></td>
<td width="6%"></td>
<td width="6%"></td>
</tr>
<tr align="center" class="b2">
<td width="12%" height="25">Bet365
<font color="red">Live</font>
</td>
<td width="7%">1.57<br><span class="">1.57</span></td>
<td width="7%">3.60<br><span class="">3.60</span></td>
<td width="7%">5.50<br><span class="">5.50</span></td>
<td width="7%">91.2%</td>
<td width="5%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/8_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/5_8_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
<td width="6%">1.05<br><span class="down">0.77</span></td>
<td width="6%">1<br><span class="down">0.5/1</span></td>
<td width="6%">0.75<br><span class="up">1.02</span></td>
<td width="6%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/8_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/1_8_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
<td width="6%">1.00<br><span class="down">0.97</span></td>
<td width="6%">2.5<br><span class="">2.5</span></td>
<td width="6%">0.80<br><span class="up">0.82</span></td>
<td width="6%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/8_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/3_8_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr align="center" class="b1">
<td width="12%" height="25">Ladbrokes</td>
<td width="7%"></td>
<td width="7%"></td>
<td width="7%"></td>
<td width="7%"></td>
<td width="5%"></td>
<td width="6%"></td>
<td width="6%"></td>
<td width="6%"></td>
<td width="6%"></td>
<td width="6%"></td>
<td width="6%"></td>
<td width="6%"></td>
<td width="6%"></td>
</tr>
<tr align="center" class="b2">
<td width="12%" height="25">Crown
<font color="red">Live</font>
</td>
<td width="7%">1.48<br><span class="up">1.57</span></td>
<td width="7%">3.75<br><span class="up">3.85</span></td>
<td width="7%">4.75<br><span class="down">4.45</span></td>
<td width="7%">89.2%</td>
<td width="5%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/3_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/5_3_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
<td width="6%">0.90<br><span class="up">1.07</span></td>
<td width="6%">1<br><span class="">1</span></td>
<td width="6%">0.80<br><span class="down">0.75</span></td>
<td width="6%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/3_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/1_3_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
<td width="6%">0.80<br><span class="up">1.00</span></td>
<td width="6%">2.5<br><span class="">2.5</span></td>
<td width="6%">0.90<br><span class="down">0.80</span></td>
<td width="6%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/3_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/3_3_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr align="center" class="b1">
<td width="12%" height="25">Macauslot</td>
<td width="7%"></td>
<td width="7%"></td>
<td width="7%"></td>
<td width="7%"></td>
<td width="5%"></td>
<td width="6%"></td>
<td width="6%"></td>
<td width="6%"></td>
<td width="6%"></td>
<td width="6%"></td>
<td width="6%"></td>
<td width="6%"></td>
<td width="6%"></td>
</tr>
<tr align="center" class="b2">
<td width="12%" height="25">18Bet
<font color="red">Live</font>
</td>
<td width="7%">1.48<br><span class="up">1.57</span></td>
<td width="7%">3.80<br><span class="up">3.90</span></td>
<td width="7%">4.80<br><span class="down">4.50</span></td>
<td width="7%">89.6%</td>
<td width="5%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/42_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/5_42_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
<td width="6%">0.91<br><span class="up">1.08</span></td>
<td width="6%">1<br><span class="">1</span></td>
<td width="6%">0.81<br><span class="down">0.76</span></td>
<td width="6%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/42_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/1_42_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
<td width="6%">0.81<br><span class="up">1.00</span></td>
<td width="6%">2.5<br><span class="">2.5</span></td>
<td width="6%">0.91<br><span class="down">0.83</span></td>
<td width="6%">
<table>
<tbody>
<tr>
<td style="padding-left:5px;cursor:pointer;">
<a href="http://data.nowgoal.com/3in1odds/42_1657616.html" target="_blank" title="3in1 Runningball"><img src="/images/t1.gif"></a>
</td>
<td style="cursor:pointer;">
<a href="http://data.nowgoal.com/oddshistory/3_42_1657616.html" target="_blank" title="Historical Odds Stats"><img src="/images/ss.gif"></a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
Парсить HTML с помощью регулярок не самый удобный способ. Есть специальные парсеры XML/HTML документов и лучше использовать их.
$doc = new DOMDocument();
$doc->loadHTML($html);
$xpath = new DOMXPath($doc);
$tds = $xpath->query('(//*[contains(text(),"Bet365")])[1]/../*'); // все потомки родителя элемента содержащего текст Bet365
foreach ($tds as $td) {
echo trim($td->textContent) . "\n";
}
Вот, например, как можно использовать DOMDocument. Самое интересное тут это XPath, который позволяет найти элементы по довольно сложному условию:
//*
-- любой элемент[contains(text(),"Bet365")]
-- содержащий текст Bet365(...)[1]
-- первый найденный (в XPath нумерация начинается с единицы)/..
-- его родитель/*
-- все вложенные элементыСоответственно мы получаем все td
в tr
, в котором есть td
с Bet365!
http://php.net/manual/ru/function.explode.php
Разбей по tr
Например:
explode('<tr', <tbody... )
и при помощи http://php.net/manual/ru/function.array-slice.php взять нужный срез массива.
Виртуальный выделенный сервер (VDS) становится отличным выбором
Как я могу подключить функцию в WordPress, из файла functionphp, таким образом, чтобы она работала только для одной страницы?
Недавно задался вопросом, можно ли взять к примеру текст из дивов на странице, которая частично подгружается из php? Сначала я написал небольшой...