I am using the PHP Simple HTML DOM Parser and I am trying to get the table list of Top Goalscorers from this webpage: http://www.transfermarkt.co.uk/en/chinese-super-league/startseite/wettbewerb_CSL.html (it's the top 5...)
I am trying to parse the table Top Goal Scorers and that has the ID of "spieler". In doing so, I want to get each table row and list them on my own. The problem is... below Name / Club... there is a new <table> to make the image, name and club name easier to display on a webpage.
I am trying to figure out the DOM so I can see what I need to select and get the right player name, club name and the goals.
Here's what I have so far:
<textarea id='txt_out'>
<?php
echo "Player | Team | Goals\n:--|:--|:--:\n";
$url = "http://www.transfermarkt.co.uk/en/chinese-super-league/startseite/wettbewerb_CSL.html";
$html = file_get_html($url);
foreach($html->find('#spieler') as $row) {
if ($i > 0) {
$player = $row->find('table tr',3)->plaintext;
echo $player . "|TEST TEAM|0";
}
$i++;
}
?>
</textarea>
and this echo returns blank.
<textarea id="txt_out">Player | Team | Goals
:--|:--|:--:
</textarea>
$html->find('#spieler')return the table with the id ofspieler(ie: an array of one item)? Seems to me that something like#spieler>tbody>tr[class] table trwould get you all (and only all) the rows that have data. Probably won't affect the overall result, but it seems like it'd obviate the need for the counter and all that.