Php解析表不返回完整的元素列表

时间:2022-10-30 00:22:56

I tried to parse a web page with php, but does not return the integer result of a table, only a part. the last player returns RAMSEY, Aron ... The other name are loaded after the web page. Who can help me? I want all the list of players...

我试图用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;

The wrong result:

错误的结果:

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

1 个解决方案

#1


0  

Actually your data is right. But there is jquery sorting on page loaded. Just different player row places.

实际上你的数据是对的。但是在页面上加载了jquery排序。只是不同的球员排名。

I copied HTML codes and removed js files, last player was RAMSEY, Aaron

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

#1


0  

Actually your data is right. But there is jquery sorting on page loaded. Just different player row places.

实际上你的数据是对的。但是在页面上加载了jquery排序。只是不同的球员排名。

I copied HTML codes and removed js files, last player was RAMSEY, Aaron

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