Tuesday, November 3, 2015

Trying to get source code of a webpage in PERL

use strict;
use warnings;
use LWP::Simple;

print "ExaCodigo\tEctCodigo\tExcCodigo\tTUSS\tSQL";

open(IN,'db')or die $!;

while(<IN>){
    chomp;
    my($ExaCodigo,$EctCodigo,$ExcCodigo)=split (/\t/,$_);
    my $link = "http\:\/\/conmedhsaude.com.br\/tuss.php\?c\=\&e\=$ExcCodigo\&p=\&q\=\&consultar\=";
    my $page = get($link) or die "cannot retrieve code\n";
    $page =~ s/\n//g;
    my $TUSS = $1 if ($page =~ /\sTUSS:\s(\d+)\<\/span\>\s+/);
    unless($TUSS) { $TUSS = 'null' }
    print "$ExaCodigo\t$EctCodigo\t$ExcCodigo\t$TUSS\tinsert into ExameCodigoTipo ExaCodigo      values ($TUSS) where ExaCodigo = $ExaCodigo and EctCodigo = $EctCodigo\n";

}
close(IN); _________________________________________________________________________________
DB 16 1 28061144 23 1 28040350 26 1 28061098 33 1 28050037 44 1 28150082 48 1 28060156 64 1 28061608 65 1 28061667 66 1 28061594 67 1 28061748 69 1 28050070 75 1 28060725 77 1 28060229 81 1 28061756 89 1 28060342 90 1 28100140 102 1 28060423
_________________________________________________________________________________ HTML

<input type="text" id="c" name="c" value="" style="margin-left:40px;" />                    Código AMB:<input type="text" id="e" name="e" value="28040481" style="margin-left:40px;" />                    Descrção TUSS: <input type="text" id="p" name="p" value="" style="margin-left:28px;" />                    Descrção AMB: <input type="text" id="q" name="q" value="" style="margin-left:25px;" />                 <input name="consultar" type="submit" class="botao" value="" style="border:none;" >                        </form>            </div> <div class='linhaguia'></div>             <div class="guiaitemsup">                        <div class="guiaitem">             <span class="nome">Código TUSS: 40304361</span>                <span class="esp"><span class="tit2">Descrição TUSS: HEMOGRAMA COM CONTAGEM DE PLAQUETAS OU FRACOES (ERITROGRAM</span></span>                <span class="end"><b>Código do grupo TUSS: </b>40308<br><b>Grupo TUSS: </b>MEDICINA LABORATORIAL  - IMUNOLOGIA<br><b>Código AMB: </b>28040481<br><b>Descrição AMB: </b>HEMOGRAMA COMPLETO (ERITOGRAMA+LEUCOGRAMA+AVALIACAO DE PLAQ<br></span>            </div>            </div>                                                     <div class="clear"></div> <div id='paginacao'><p class="MyriadCH"><span paginacaobot >1</span></p></div>                     </div>                        <div id="lateral">     <div class="clear"></div>    <!-- <a href="http://177.21.147.100:8086/mvautorizadorguias/" title="Autorizador" target="_blank" class="latitem latitemautorizador" ></a> -->    <a href="http://201.59.94.100:8086/mvautorizadorguias/" title="Autorizador" target="_blank" class="latitem latitemautorizador" ></a>    <a href="tuss.php" title="TUSS" class="latitem latitemtuss" ></a>    <a href="trabalheconosco.php" title="Trabalhe Conosco" class="latitem latitemtrabalhe" ></a>        <a href="perguntasfrequentes.php" title="Perguntas Frequentes" class="latitem latitemperguntas" ></a>    <a href="faleconosco.php" title="Central de Atendimento" class="latitem latitematend" ></a>    <a href="linksuteis.php" title="Links Úteis" class="latitem latitemtels" ></a> <a href="commaissaude.php" title="Com + Saúde" class="latitem latitemprevent" ></a>    <a href="imagens/redecredenciada.pdf" title="Rede Credenciada" target="_blank" class="latitem latitemrede" ></a>    <br><br>       <!-- <div id="abramgeans">        <a href="http://www.abramge.com.br/" target="_blank">        <img src="imagens/site/abramge.png" class="abramge">        </a>            <a href="http://www.ans.gov.br/" target="_blank">        <img src="imagens/site/ans.png" class="ans">        </a>    </div>-->    <div class="clear"></div></div>                        <div class="clear"></div>        </div> <div class="linha"></div> <div id="rodape"> <div class="central">     <a href="http://www.taticaweb.com.br/" class="taticaweb" target="_blank"></a>            <div id="abramgeans1" style="float: left;margin: -9px 0 0 0;">                <a href="http://www.abramge.com.br/" target="_blank">                <img src="imagens/site/abramge.png" class="abramge" width="58" height="41">                </a>                            <a href="http://www.ans.gov.br/" target="_blank">                <img src="imagens/site/ans.png" class="ans" width="" height="39">            </a>       </div>        <div class="rodapeatend">         <span class="cat">Central de Atendimento:</span><span class="tel">(24)4009-4545 | (24)4009-4519</span>         <span class="cat">Central de Vendas:</span><span class="tel">(24)4009-8803</span><br />            <span class="cat" style="padding-top:12px; margin-left:-98px;">SAC:</span><span class="tel">0800-0302015

_________________________________________________________________________________
OUTPUT
ExaCodigo EctCodigo ExcCodigo TUSS SQL

23 1 28040350 null insert into ExameCodigoTipo ExaCodigo values (null) where ExaCodigo = 23 and EctCodigo = 1
26 1 28061098 null insert into ExameCodigoTipo ExaCodigo values (null) where ExaCodigo = 26 and EctCodigo = 1
33 1 28050037 null insert into ExameCodigoTipo ExaCodigo values (null) where ExaCodigo = 33 and EctCodigo = 1
44 1 28150082 null insert into ExameCodigoTipo ExaCodigo values (null) where ExaCodigo = 44 and EctCodigo = 1
48 1 28060156 null insert into ExameCodigoTipo ExaCodigo values (null) where ExaCodigo = 48 and EctCodigo = 1
64 1 28061608 null insert into ExameCodigoTipo ExaCodigo values (null) where ExaCodigo = 64 and EctCodigo = 1
65 1 28061667 null insert into ExameCodigoTipo ExaCodigo values (null) where ExaCodigo = 65 and EctCodigo = 1
66 1 28061594 null insert into ExameCodigoTipo ExaCodigo values (null) where ExaCodigo = 66 and EctCodigo = 1
67 1 28061748 null insert into ExameCodigoTipo ExaCodigo values (null) where ExaCodigo = 67 and EctCodigo = 1
69 1 28050070 null insert into ExameCodigoTipo ExaCodigo values (null) where ExaCodigo = 69 and EctCodigo = 1
75 1 28060725 null insert into ExameCodigoTipo ExaCodigo values (null) where ExaCodigo = 75 and EctCodigo = 1
77 1 28060229 null insert into ExameCodigoTipo ExaCodigo values (null) where ExaCodigo = 77 and EctCodigo = 1
81 1 28061756 null insert into ExameCodigoTipo ExaCodigo values (null) where ExaCodigo = 81 and EctCodigo = 1
89 1 28060342 40306631 insert into ExameCodigoTipo ExaCodigo values (40306631) where ExaCodigo = 89 and EctCodigo = 1 

 

0 comentários:

Post a Comment