0

I have a problem with the HTML text I am trying to work with.

I would like to extract the name of the player with all the statistics associated with him.

Basically I am not sure if I can extract the numbers of the column due to the syntax of the code.

In the HTML I included only 2 players, but I would like to add all the players of this club and then continue to the next team.

<table data-toggle="table-estadisticas-clubes" data-fixed-columns="true" data-fixed-number="2" class="roboto">
    <thead>
        <tr class="cabecera_general">
            <th>&nbsp;</th>
            <th>&nbsp;</th>
            <th>PAR</th>
            <th>MIN</th>
            <th>&nbsp;</th>
            <th>PT</th>
            <th colspan="3">TIROS DE 3</th>
            <th colspan="3">TIROS DE 2</th>
            <th colspan="3">TIROS LIBRES</th>
            <th colspan="3">REBOTES</th>
            <th>ASI</th>
            <th colspan="2">BALONES</th>
            <th colspan="2">TAPONES</th>
            <th>&nbsp;</th>
            <th colspan="2">FALTAS</th>
            <th>&nbsp;</th>
            <th class="ultimo">VAL</th>
        </tr>
        <tr>
            <th class="situacion">&nbsp;</th>
            <th class="nombre jugador">&nbsp;</th>
            <th>Jug</th>
            <th>Jug</th>
            <th>5i</th>
            <th>&nbsp;</th>
            <th>Con</th>
            <th>Int</th>
            <th>%</th>
            <th>Con</th>
            <th>Int</th>
            <th>%</th>
            <th>Con</th>
            <th>Int</th>
            <th>%</th>
            <th>Def</th>
            <th>Ofe</th>
            <th>Tot</th>
            <th>Efe</th>
            <th>Rec</th>
            <th>Per</th>
            <th>Fav</th>
            <th>Con</th>
            <th>Mat</th>
            <th>Com</th>
            <th>Rec</th>
            <th>+/-</th>
            <th class="ultimo">&nbsp;</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td class="situacion"></td>
            <td class="nombre jugador ellipsis"><a href="/jugador/ver/30000024-William-Magarity"><span class="nombre_corto">William Magarity</span></a></td>
            <td class="borde_derecho">2</td>
            <td class="borde_derecho">23:57</td>
            <td class="borde_derecho"></td>
            <td class="borde_derecho">11,5</td>
            <td class="borde_derecho">3,0</td>
            <td class="borde_derecho">4,0</td>
            <td class="borde_derecho">75,0%</td>
            <td class="borde_derecho">0,5</td>
            <td class="borde_derecho">2,5</td>
            <td class="borde_derecho">20,0%</td>
            <td class="borde_derecho">1,5</td>
            <td class="borde_derecho">1,5</td>
            <td class="borde_derecho">100,0%</td>
            <td class="borde_derecho">3,5</td>
            <td class="borde_derecho">0,0</td>
            <td class="borde_derecho">3,5</td>
            <td class="borde_derecho">1,5</td>
            <td class="borde_derecho">1,5</td>
            <td class="borde_derecho">1,0</td>
            <td class="borde_derecho">0,5</td>
            <td class="borde_derecho">0,0</td>
            <td class="borde_derecho">0,5</td>
            <td class="borde_derecho">0,5</td>
            <td class="borde_derecho">2,0</td>
            <td class="borde_derecho">1,0</td>
            <td class="borde_derecho">16,0</td>
        </tr>
        <tr class="par">
            <td class="situacion"></td>
            <td class="nombre jugador ellipsis"><a href="/jugador/ver/30000283-Jaime-Echenique"><span class="nombre_corto">Jaime Echenique</span></a></td>
            <td class="borde_derecho">2</td>
            <td class="borde_derecho">23:34</td>
            <td class="borde_derecho"></td>
            <td class="borde_derecho">14,0</td>
            <td class="borde_derecho">0,5</td>
            <td class="borde_derecho">1,0</td>
            <td class="borde_derecho">50,0%</td>
            <td class="borde_derecho">3,5</td>
            <td class="borde_derecho">7,0</td>
            <td class="borde_derecho">50,0%</td>
            <td class="borde_derecho">5,5</td>
            <td class="borde_derecho">6,0</td>
            <td class="borde_derecho">91,7%</td>
            <td class="borde_derecho">0,0</td>
            <td class="borde_derecho">3,5</td>
            <td class="borde_derecho">3,5</td>
            <td class="borde_derecho">1,0</td>
            <td class="borde_derecho">0,5</td>
            <td class="borde_derecho">2,0</td>
            <td class="borde_derecho">2,0</td>
            <td class="borde_derecho">0,0</td>
            <td class="borde_derecho">0,5</td>
            <td class="borde_derecho">3,0</td>
            <td class="borde_derecho">4,0</td>
            <td class="borde_derecho">-1,5</td>
            <td class="borde_derecho">15,5</td>
        </tr>
    </tbody>
</table>

URL: https://www.acb.com/club/estadisticas/id/14

1
  • 2
    can you show us code that you've already tried, the problems you're running into? Commented Oct 5, 2020 at 18:25

1 Answer 1

1

Easiest way to parse the table is to use pandas:

import pandas as pd


url = 'https://www.acb.com/club/estadisticas/id/14'
df = pd.read_html(url)[0].iloc[:,1:]
df.to_csv('data.csv', index=False)

Will grab the table to dataframe and saves it as data.csv:

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

That's perfect @Andrej! Thank you very much for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.