PYTHON - JSON format HTML table data

Asked

Viewed 112 times

-1

I have the following doubt:

Using Python it is possible to convert data from a table html in a format json ?

HTML tablet:


<div class="contentInternoSemMenu">
                <table width="98%">
                    <tbody><tr>
                        <td>
                        <h1 class="tit"><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0299">Pesquisa de débitos e restrições de veículos de terceiros - Laudo</span></h1>
                        </td>
                    </tr>
                </tbody></table>
                    <table width="98%">
                        <tbody><tr>
                            <td width="100%"><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b02f2"></span></td>
                        </tr>
                    </tbody></table>
                <table width="100%" class="tabela">
                    <tbody><tr>
                        <td align="center" colspan="2" style="background-color: rgb(238, 238, 238)"><strong>Dados do veículo</strong></td>
                    </tr>
                    <tr>
                        <td width="50%"><strong>Placa: </strong><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b02c5">DMR7147</span></td>
                        <td width="50%"><strong>Renavam: </strong><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b02d8">825630932</span></td>
                    </tr>
                </tbody></table>
                <br>
                <table width="100%" class="tabela">
                    <tbody><tr>
                        <td align="center" style="background-color: rgb(238, 238, 238)"><strong>IPVA</strong></td>
                    </tr>
                    <tr>
                        <td>
                            <strong>IPVA: </strong><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b032b">NADA CONSTA                     - </span><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b033e">PAGO - </span>
                            Em caso de dúvidas, consulte <a href="https://www.ipva.fazenda.sp.gov.br/IPVANET_Consulta/Consulta.aspx" target="_blank" style="color: #3a87ad">www.ipva.fazenda.sp.gov.br</a>
                        </td>
                    </tr>
                </tbody></table>
                <br>
                <table width="100%" class="tabela">
                    <tbody><tr>
                    <td align="center" colspan="2" style="background-color: rgb(238, 238, 238)"><strong>Multas</strong></td>
                    </tr>
                    <tr>
                        <td width="50%" colspan="2"><strong>Total: </strong><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0331">NADA CONSTA</span></td>
                    </tr>
                </tbody></table>
                <br>
                <table width="100%" class="tabela">
                    <tbody><tr>
                        <td colspan="2" align="center" style="background-color: rgb(238, 238, 238)"><strong>Restrições</strong></td>
                    </tr>
                    <tr>
                        <td width="50%"><strong>Restrição por bloqueio de furto/roubo: </strong><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0304">NADA CONSTA                                         </span></td>
                        <td width="50%"><strong>Restrição administrativa: </strong><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0317">NADA CONSTA                   </span>
                        </td>
                    </tr>
                    <tr>
                        <td width="50%"><strong>Restrição tributária: </strong><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b037d">NADA CONSTA                   </span></td>
                        <td width="50%"><strong>Restrição judiciária: </strong><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0370">BLOQ. RENAJUD - TRANSFERENCIA </span></td>
                    </tr>
                    <tr>
                        <td width="50%"><strong>Restrição financeira: </strong><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0343">NADA CONSTA              </span></td>
                        <td width="50%"><strong>Restrição por veículo guinchado: </strong><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0356">NADA CONSTA                               </span></td>
                    </tr>
                </tbody></table>
                <br>
                <table width="100%" class="tabela">
                    <tbody><tr>
                        <td align="center" style="background-color: rgb(238, 238, 238);"><strong>Inspeção veicular</strong></td>
                    </tr>
                    <tr>
                        <td>
                            <strong>Inspeção GNV: </strong><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0382">NADA CONSTA</span>
                        </td>
                    </tr>
                </tbody></table>

                <br>
                <table width="100%" class="tabela">
                    <tbody><tr>
                        <td align="center" style="background-color: rgb(238, 238, 238)"><strong>Licenciamento</strong></td>
                    </tr>
                    <tr>
                        <td>
                            <strong>Último licenciamento efetuado: </strong>exercício<span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0395"> 2019</span>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <strong>Status do licenciamento: </strong><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b03e8">em dia (prazo para licenciamento vencerá no próximo ano).</span>
                        </td>
                    </tr>
                </tbody></table>
                <br>

                <table width="100%" class="tabela">
                    <tbody><tr>
                        <td align="center" style="background-color: rgb(238, 238, 238)"><strong>Laudo de vistoria em Empresa Credenciada de Vistoria (ECV)</strong></td>
                    </tr>
                </tbody></table>
<table id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data" width="100%" class="tableResultadoLaudo">
<thead>
<tr><th class="tableResultadoLaudo-header" scope="col"><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0079">Data da vistoria</span></th><th class="tableResultadoLaudo-header" scope="col"><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0091">Empresa responsável</span></th><th class="tableResultadoLaudo-header" scope="col"><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0123">KM</span></th><th class="tableResultadoLaudo-header" scope="col"><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0175">Resultado da vistoria</span></th><th class="tableResultadoLaudo-header" scope="col"><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b063f">Motivo resultado</span></th><th class="tableResultadoLaudo-header" scope="col"><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0696">Situação</span></th><th class="tableResultadoLaudo-header" scope="col"><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0728">Imagem</span></th></tr></thead>
<tbody id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:tbody_element">
<tr class="tableResultadoLaudo-odd-row"><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:0:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b004c">14/11/2019</span></td><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:0:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b00e4">OLIVEIRA E CARVALHO VISTORIAS LTDA-EPP</span></td><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:0:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0136">116756</span></td><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:0:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b01a1"><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:0:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0187">APROVADO COM APONTAMENTO</span></span></td><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:0:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0632"><a href="#" onclick="return myfaces.oam.submitForm('viewns_Z7_419E11C0M0UL30QQMNV10N0045_:form','viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:0:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0618');" id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:0:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0618" title="Clique aqui para saber informações sobre este laudo" class="colorLink">Visualizar</a></span></td><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:0:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b06e9">REGULAR</span></td><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:0:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b073b"><a href="#" onclick="jsf.util.chain(document.getElementById('viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:0:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0701'), event,'jsf.ajax.request(\'viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:0:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0701\',event,{onevent:animate,\'javax.faces.behavior.event\':\'click\'})'); return false;" id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:0:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0701" name="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:0:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0701" title="Clique aqui para visualizar as imagens do laudo" class="colorLink">Imagens</a></span></td></tr>
<tr class="tableResultadoLaudo-even-row"><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:1:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b004c">10/05/2016</span></td><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:1:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b00e4">Authenticar Soluções Automotivas LTDA - EPP</span></td><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:1:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0136">105665</span></td><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:1:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0148"><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:1:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b01ae">APROVADO</span></span></td><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:1:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0671"><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:1:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0657">-</span></span></td><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:1:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b06e9">REGULAR</span></td><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:1:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b073b"><a href="#" onclick="jsf.util.chain(document.getElementById('viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:1:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0701'), event,'jsf.ajax.request(\'viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:1:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0701\',event,{onevent:animate,\'javax.faces.behavior.event\':\'click\'})'); return false;" id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:1:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0701" name="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:1:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0701" title="Clique aqui para visualizar as imagens do laudo" class="colorLink">Imagens</a></span></td></tr>
<tr class="tableResultadoLaudo-odd-row"><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:2:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b004c">02/02/2016</span></td><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:2:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b00e4">Authenticar Soluções Automotivas LTDA - EPP</span></td><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:2:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0136">105555</span></td><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:2:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0148"><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:2:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b01ae">APROVADO</span></span></td><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:2:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0671"><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:2:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0657">-</span></span></td><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:2:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b06e9">REGULAR</span></td><td><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:2:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b073b"><a href="#" onclick="jsf.util.chain(document.getElementById('viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:2:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0701'), event,'jsf.ajax.request(\'viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:2:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0701\',event,{onevent:animate,\'javax.faces.behavior.event\':\'click\'})'); return false;" id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:2:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0701" name="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:data:2:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b0701" title="Clique aqui para visualizar as imagens do laudo" class="colorLink">Imagens</a></span></td></tr>
</tbody></table>


                <table width="100%" align="center">
                    <tbody><tr>
                        <td>
                            <br><br>    
                            <p dir="ltr">Esta pesquisa tem caráter informativo.</p>
                            <br>
                            <p dir="ltr"><strong>Dúvidas sobre o pagamento</strong>:</p>
                            <p dir="ltr">Para pagar seu licenciamento, multas, IPVA e DPVAT, basta informar o número do Renavam na <a href="https://www.detran.sp.gov.br/wps/portal/portaldetran/cidadao/veiculos/fichaservico/formulariosSiglasTaxas/"><span style="color: rgb(0, 0, 255);">rede bancária credenciada</span></a>.</p>
                            <p dir="ltr">No Detran.SP não é gerado nenhum boleto e você não precisa levar nenhum papel para pagar seus débitos.</p>
                            <p dir="ltr"><strong>Dúvidas sobre débitos com a Secretaria da Fazenda do Estado de São Paulo</strong>, consulte <a href="http://www.ipva.fazenda.sp.gov.br" style="color: blue;">www.ipva.fazenda.sp.gov.br</a>.</p>
                            <p dir="ltr"><strong>Dúvidas sobre débitos do Seguro DPVAT</strong>, consulte <a href="https://www.seguradoralider.com.br/Pages/informacoes-gerais-sobre-o-pagamento.aspx" style="color: blue;">https://www.seguradoralider.com.br/Pages/informacoes-gerais-sobre-o-pagamento.aspx</a></p>
                        </td>               
                    </tr>                   
                    <tr>
                        <td>
                        <br>
                            <p></p>
                        </td>
                    </tr>
                </tbody></table><span id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b07b9">  
                    <div class="tableLink">
                        <div>
                                <a href="/wps/portal/portaldetran/cidadao/duvidasFrequentes/sa-veiculos/sa-outros/sa-detalhesoutros/c8907bfa-cd12-4bad-8ad0-bd1dd724e5d7/" target="_blank" style=" color: #0072BC;">Clique aqui para mais informações sobre o laudo de vistoria em ECV.</a>
                        </div>
                    </div></span>

                <br>
                <table width="100%">
                    <tbody><tr>                     
                        <td><input id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b07cb" name="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b07cb" type="submit" value="Voltar" title="Voltar" class="btn btn-primary">
                        </td>
                        <td align="right"><a href="#" onclick="jsf.util.chain(document.getElementById('viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b07de'), event,'jsf.ajax.request(\'viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b07de\',event,{\'javax.faces.behavior.event\':\'click\'})'); return false;" id="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b07de" name="viewns_Z7_419E11C0M0UL30QQMNV10N0045_:ns_Z7_419E11C0M0UL30QQMNV10N0045_j_id1967850031_754b07de" title="Imprimir" class="btn btn-primary btnAvanca">Imprimir</a>
                        </td>
                    </tr>
                </tbody></table>
                </div>

That is, the tags Strong would be the header of json and the tags span the text.

I’ve done some research, but since I don’t have much experience in PYTHON, I can’t find a solution that fits me.

  • 1

    https://stackoverflow.com/questions/18544634/convert-a-html-table-to-json

1 answer

0

Browser other questions tagged

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