<?php
$page = file_get_contents('http://localhost/pim/station.php');
preg_match_all('/<td.*?>(.*?)<\/td>/si', $page, $agent_name);
echo json_encode($agent_name);
?>
这是我试图解析的HTML
<form name="maforme" method="post" action="">
<center class="p2Text">
<div id='table'>
<table id="tablex" width="99%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#111111" style="font-family: Arial; font-size: 10px; border-collapse: collapse; height: 53px" name="table">
<thead>
<tr align="center" >
<th height="30" colspan="7" align="center" valign="middle" bgcolor="#F2FAE7" class="sous_TITRE" >
TUNIS =====>
SIDI AHMED </th>
</tr>
<tr align="center">
<th width="110" height="24" colspan="1" valign="middle" bgcolor="#F2FAE7" class="titre_tableau">Ligne</th>
<th width="72" height="24" colspan="1" valign="middle" bgcolor="#F2FAE7" class="titre_tableau">Station départ</th>
<th width="50" height="24" valign="middle" bgcolor="#F2FAE7" class="titre_tableau">Heure départ </th>
<th width="68" height="24" colspan="1" valign="middle" bgcolor="#F2FAE7" class="titre_tableau">Station arrivée</th>
<th width="52" height="24" valign="middle" bgcolor="#F2FAE7" class="titre_tableau">Heure arrivée</th>
<th width="51" height="24" valign="middle" bgcolor="#F2FAE7" class="titre_tableau">Distance</th>
<th width="47" valign="middle" bgcolor="#F2FAE7" class="titre_tableau">Tarif (DT) </th>
</tr>
</thead>
<tbody id="offTblBdy">
<tr class="tabnormal" onMouseOver="this.className='tabover'" onMouseOut="this.className='tabnormal'">
<td height="30" align="left" valign="middle" class="text_normal_colore">TUNIS - TABARKA <span class="unnamed1">(N)</span></td>
<td height="30" align="center" valign="middle" class="bluetext" > TUNIS <input type="hidden" value="7"> </td>
<td height="30" align="center" valign="middle" > 06:30 </td>
<td height="30" align="center" valign="middle" class="bluetext"> SIDI AHMED </td>
<td height="30" align="center" valign="middle" > 07:40 </td>
<td height="30" align="center" valign="middle" class="style10"> 70 </td>
<td height="30" align="center" valign="middle" class="text_normal_colore">4.190</td>
</tr>
实际上我正在尝试用id offTblBdy 来解析表格的td内的值.PLZ可以有人帮忙