0

我试图用php解析一个网页,但不返回表格的整数结果,只返回一部分。最后一个玩家返回 RAMSEY, Aron ... 另一个名字是在网页之后加载的。谁能帮我?我想要所有的球员名单...

$data1=file_get_contents('http://it.soccerwiki.org/squad.php?clubid=1');
$doc=new DOMDocument();
@$doc->loadHTML($data1);
$doc->preserveWhiteSpace=false;
$table=$doc->getElementsByTagName('table');
for($i=0;$i<$table->item(2)->childNodes->length;$i++)
echo $table->item(2)->childNodes->item($i)->textContent;

错误的结果:

Info   Naz Giocatore Pos Età Val - MARTÍNEZ, Damián1PO2175- VERMAELEN, Thomas2D(SC)2791- ROSICKÝ, Tomáš256C(C),CO(DSC)3288- BENDTNER, Nicklas16384A(C)2588- WALCOTT, Theo4096CO(D),A(DC)2491- GIBBS, Kieran2D,MD,C(S)2388- WILSHERE, Jack256C,CO(C)2190- OXLADE-CHAMBERLAIN, Alex1024CO(DSC),A(DS)2088- AFOBE, Benik16384A(C)2082- JENKINSON, Carl8D(D)2185- YENNARIS, Nicholas8D(D),MD(C)2075- JEFFREY, Anthony1024CO,A(S)1875- ARTETA, Mikel32MD,C(C)3191- CAZORLA, Santi256C(C),CO(DSC)2892- MONREAL, Nacho2D(S)2789- FLAMINI, Mathieu32MD,C(C)2988- SAGNA, Bacary8D(D)3091- KOSCIELNY, Laurent4D(C)2790- DIABY, Abou32MD,C,CO(C)2789- GIROUD, Olivier16384A(C)2690- SANOGO, Yaya16384A(C)2082- PODOLSKI, Lukas1024CO,A(SC)2891- MERTESACKER, Per4D(C)2891- ÖZIL, Mesut1024CO(DSC)2494- GNABRY, Serge1024CO(DSC)1877- EISFELD, Thomas256C,CO(C)2075- FRIMPONG, Emmanuel32MD,C(C)2183Prs VIVIANO, Emiliano1PO2789- MIYAICHI, Ryo1024CO,A(DS)2084- PARK, Chu-Young1024CO,A(DSC)2887- FABIAŃSKI, Lukasz1PO2886- SZCZĘSNY, Wojciech1PO2389- RAMSEY, Aaron256C,CO(DC)2288
4

1 回答 1

0

其实你的数据是对的。但是在加载的页面上有 jquery 排序。只是不同的玩家行位置。

我复制了 HTML 代码并删除了js文件,最后一个播放器是RAMSEY, Aaron

于 2013-09-04T10:55:44.013 回答