How to transfer an HTML table into a Data Frame

Asked

Viewed 49 times

0

I’m trying to integrate a python script with an HTML table How can I do that

follows my schedule.

<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>
  • Start by parsing the HTML, extracting the desired information. Maybe the module beautifulsoup can help you with that.

1 answer

0


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

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

from bs4 import BeautifulSoup 
soup = BeautifulSoup(html_doc, 'html.parser')
titulo = soup.title.string

Browser other questions tagged

You are not signed in. Login or sign up in order to post.