<html><body><tr id="ASPxGridView1_DXDataRow0" class="dxgvDataRow_Soft_Orange"> <td class="dxgv">53</td> <td class="dxgv"><a class="dxeHyperlink" href="onest.aspx?stnm=外海&startm=&endtm=" target="_blank">1</a></td> <td class="dxgv">2</td> <td class="dxgv">3</td> <td class="dxgv">4</td> <td class="dxgv">6</td> <td class="dxgv">7</td> <td class="dxgv">8</td> <td class="dxgv">9</td> <td class="dxgv" style="border-right-width:0px;">10</td> </tr> <tr id="ASPxGridView1_DXDataRow1" class="dxgvDataRow_Soft_Orange"> <td class="dxgv">11</td> <td class="dxgv"><a class="dxeHyperlink" href="onest.aspx?stnm=j江苏&startm=&endtm=" target="_blank">12</a></td> <td class="dxgv">13</td> <td class="dxgv">14</td> <td class="dxgv">15</td> <td class="dxgv">16</td> <td class="dxgv">17</td> <td class="dxgv">18</td> <td class="dxgv">19</td> <td class="dxgv" style="border-right-width:0px;">20</td> </tr> <tr id="ASPxGridView1_DXDataRow1" class="dxgvDataRow_Soft_Orange"> <td class="dxgv">21</td> <td class="dxgv"><a class="dxeHyperlink" href="onest.aspx?stnm=上海&startm=&endtm=" target="_blank">22</a></td> <td class="dxgv">23</td> <td class="dxgv">24</td> <td class="dxgv">25</td> <td class="dxgv">26</td> <td class="dxgv">27</td> <td class="dxgv">28</td> <td class="dxgv">29</td> <td class="dxgv" style="border-right-width:0px;">30</td> </tr></tr></body></html>
$s=<<(\d+)()?
loadHTML($html);$tr = $dom->getElementsByTagName('tr');$str ='';foreach ($tr as $key => $value) { $value = trim(str_replace(PHP_EOL, '', $value->nodeValue)); $value = preg_replace('/\s\s+/', '|', $value); $value = substr($value, strrpos($value, '|')+1); var_dump($value); $str.=$value;}var_dump($str);?>
$dom = new DOMDocument ;$dom->loadHTML($html);$tr = $dom->getElementsByTagName('tr');$str ='';foreach ($tr as $key => $value) { $value = trim(str_replace(PHP_EOL, '', $value->nodeValue)); $value = preg_replace('/\s\s+/', ',', $value); $str.=$value.',';}$str = substr($str, 0,-1);var_dump($str);
$s =<<< HTML<html><body><tr id="ASPxGridView1_DXDataRow0" class="dxgvDataRow_Soft_Orange"> <td class="dxgv">53</td> <td class="dxgv"><a class="dxeHyperlink" href="onest.aspx?stnm=外海&startm=&endtm=" target="_blank">1</a></td> <td class="dxgv">2</td> <td class="dxgv">3</td> <td class="dxgv">4</td> <td class="dxgv">6</td> <td class="dxgv">7</td> <td class="dxgv">8</td> <td class="dxgv">9</td> <td class="dxgv" style="border-right-width:0px;">10</td> </tr> <tr id="ASPxGridView1_DXDataRow1" class="dxgvDataRow_Soft_Orange"> <td class="dxgv">11</td> <td class="dxgv"><a class="dxeHyperlink" href="onest.aspx?stnm=j江苏&startm=&endtm=" target="_blank">12</a></td> <td class="dxgv">13</td> <td class="dxgv">14</td> <td class="dxgv">15</td> <td class="dxgv">16</td> <td class="dxgv">17</td> <td class="dxgv">18</td> <td class="dxgv">19</td> <td class="dxgv" style="border-right-width:0px;">20</td> </tr> <tr id="ASPxGridView1_DXDataRow1" class="dxgvDataRow_Soft_Orange"> <td class="dxgv">21</td> <td class="dxgv"><a class="dxeHyperlink" href="onest.aspx?stnm=上海&startm=&endtm=" target="_blank">22</a></td> <td class="dxgv">23</td> <td class="dxgv">24</td> <td class="dxgv">25</td> <td class="dxgv">26</td> <td class="dxgv">27</td> <td class="dxgv">28</td> <td class="dxgv">29</td> <td class="dxgv" style="border-right-width:0px;">30</td> </tr></tr></body></html>HTML;include 'simple_html_dom.php';$p = str_get_html($s);foreach($p->find('td') as $i=>$r) { if($i) echo $r->text(), PHP_EOL;}1
$s =<<< HTML<html><body><tr id="ASPxGridView1_DXDataRow0" class="dxgvDataRow_Soft_Orange"> <td class="dxgv">53</td> <td class="dxgv"><a class="dxeHyperlink" href="onest.aspx?stnm=外海&startm=&endtm=" target="_blank">1</a></td> <td class="dxgv">2</td> <td class="dxgv">3</td> <td class="dxgv">4</td> <td class="dxgv">6</td> <td class="dxgv">7</td> <td class="dxgv">8</td> <td class="dxgv">9</td> <td class="dxgv" style="border-right-width:0px;">10</td> </tr> <tr id="ASPxGridView1_DXDataRow1" class="dxgvDataRow_Soft_Orange"> <td class="dxgv">11</td> <td class="dxgv"><a class="dxeHyperlink" href="onest.aspx?stnm=j江苏&startm=&endtm=" target="_blank">12</a></td> <td class="dxgv">13</td> <td class="dxgv">14</td> <td class="dxgv">15</td> <td class="dxgv">16</td> <td class="dxgv">17</td> <td class="dxgv">18</td> <td class="dxgv">19</td> <td class="dxgv" style="border-right-width:0px;">20</td> </tr> <tr id="ASPxGridView1_DXDataRow1" class="dxgvDataRow_Soft_Orange"> <td class="dxgv">21</td> <td class="dxgv"><a class="dxeHyperlink" href="onest.aspx?stnm=上海&startm=&endtm=" target="_blank">22</a></td> <td class="dxgv">23</td> <td class="dxgv">24</td> <td class="dxgv">25</td> <td class="dxgv">26</td> <td class="dxgv">27</td> <td class="dxgv">28</td> <td class="dxgv">29</td> <td class="dxgv" style="border-right-width:0px;">30</td> </tr></tr></body></html>HTML;include 'simple_html_dom.php';$p = str_get_html($s);foreach($p->find('td') as $i=>$r) { if($i) echo $r->text(), PHP_EOL;}1