我在这里有这个网站:http ://www.wdjc.de/euro/index.php 它不像我只寻找解决方案而不为自己做任何事情,但是我每次转身都会被端点卡住.
根据我的 2 个想法,我通常会像这样构建脚本:
<?
$ch = curl_init ("http://www.wdjc.de/euro/index.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$page = curl_exec($ch);
preg_match('#<table[^>]*>(.+?)</table>#is', $page, $matches);
foreach ($matches as &$match) {
$match = $match;
}
echo '<table>';
echo $matches[1];
echo '</table>';
?>
这根本不起作用,它只显示表头。所以我有了构建这个的想法:
<?
$handle = fopen('http://www.wdjc.de/euro/index.php', 'r');
while (!feof($handle))
{
$html .= fread($handle, 4096);
}
$begin = ' <table width="900" class="clean">';
$end = '</table>';
$beginloc = strpos($html, $begin) + strlen($begin);
$endloc = strpos($html, $end);
$html = substr($html, $beginloc, $endloc - $beginloc);
echo "<table width=100%>";
$html = str_replace("</tr>", "</tr>\n", $html);
$html = str_replace("</td>", "</td>\n", $html);
$html = str_replace("<td width", "<td nowrap ", $html);
echo $html;
echo "</table>";
?>
它也不起作用,因为终点在每列之后。但是这个页面的诀窍是他们使用双表:
<table width="900" class="clean"> <tr> <td align="center">
<br><br>
<table width="880">
<tr>
<td width="60" align="left">POSITION</td>
<td width="40"></td>
<td width="400" align="left">ARTIST<br>TITLE</td>
<td width="90" align="center">LAST<br>WEEK</td>
<td width="90" align="center">HIGHEST<br>POSITION</td>
<td width="90" align="center">WEEK</td>
<td width="40" align="center">COVER</td>
<td width="70" align="right">SHOP</td>
</tr>
</table>
<hr>
<table width="880" align="center">
...
有人有想法吗?