How to transform an HTML table into a Data Frame

0

I'm trying to integrate a python script with an HTML table How can I do this?

Follow my table.

<table data-spy="scroll" class = "table-responsive-sm" id="table-prem"  >
                            <thead>
                            <tr style="background-color: #e8e8e8;">
                                <th scope="col"  >CPF</th>
                                <th scope="col" >Nome</th>
                                <th scope="col" >Premio Base</th>
                                <th scope="col" >Falta Just.</th>
                                <th scope="col" >Falta Injut.</th>
                                <th scope="col" >Premio Final</th>
                                <th scope="col" >Observação</th>
                                <th scope="col"></th>
                            </tr>
                            </thead>
                            <tbody >
                                <tr>
                                    <td><input type="text"  id="cpf" ></td>
                                    <td><input disabled type="text" class="" id="nome_i"></td>
                                    <td><input type="text" class="" id="premio_base"/></td>
                                    <td><input type="number" class="" id="falta_just" /></td>
                                    <td><input type="number" class="" id="falta_injus" /></td>
                                    <td><input type="text" class="" id="premio_final"/></td>
                                    <td><input type="text" class="" id="obs"/></td>
                                    <td>
                                        <button  type="button" class="btn btn-danger btn-sm">deleta</button>
                                    </td>
                                </tr>
                            </tbody>
                       </table>
    
asked by anonymous 22.11.2018 / 21:27

1 answer

0

It is possible to extract the data with the beautifulsoup module and attach these files to a DataFrame or to various variables.

The code below extracts the title from the file and stores it in the variable title:

from bs4 import BeautifulSoup 
soup = BeautifulSoup(html_doc, 'html.parser')
titulo = soup.title.string
    
23.11.2018 / 11:58