|
Wx - Exemplo de como ler um site de html |
Débuté par adrianoboller, 15 mar. 2016 18:55 - 2 réponses |
| |
| | | |
|
| |
Membre enregistré 3 657 messages Popularité : +175 (223 votes) |
|
Posté le 15 mars 2016 - 18:55 |
Prezados,
Segue exemplo de como ler um site de html
Procedure Importar()
Existe is boolean = False
Aspas, Inicial is int
Texto, NovoTexto, sArquivo is string = ""
HDeleteAll(T003_LinksForum)
TableDisplay(TABLE_T003_LinksForum,taReExecuteQuery)
TableDisplay(TABLE_T003_LinksForum,taInit)
IF sFile <> "" THEN sBuffer = fLoadBuffer(sFile) HourGlass(True) Multitask(1) nPosAtual, nPosIni, nPosFim are int = 0 nTotal is int = Length(sBuffer) LOOP (nTotal) nPosAtual += 1 Multitask(1) IF Middle(sBuffer,nPosAtual,8) = "<a href=" nPosIni = nPosAtual END IF Middle(sBuffer,nPosAtual,4) = "</a>" nPosFim = nPosAtual + 4 END IF nPosIni > 0 AND nPosFim > 0 AND nPosFim >= nPosIni THEN Texto = Middle(sBuffer,nPosIni,nPosFim-nPosIni) T003_LinksForum.T003_Extraido = Texto Aspas = PositionOccurrence(Texto,Charact(34),firstRank,FromBeginning) Aspas = PositionOccurrence(Texto,Charact(34),nextRank,FromBeginning) - 10 T003_LinksForum.T003_Link = Middle(Texto,10,Aspas) Inicial = PositionOccurrence(Texto,">",firstRank,FromBeginning) + 1 NovoTexto = Middle(Texto,Inicial,1024) NovoTexto = Replace(NovoTexto,"</a>","") T003_LinksForum.T003_Titulo = NoAccent( UTF8ToString( NovoTexto ) ) T003_LinksForum.T003_NovoArquivo = "<a href="+Charact(34)+T003_LinksForum.T003_Link+Charact(34)+">"+T003_LinksForum.T003_Titulo+"</a>" IF PositionOccurrence(NovoTexto,"[",firstRank,FromBeginning) > 0 AND... PositionOccurrence(NovoTexto,"]",firstRank,FromBeginning) > 0 Existe = True ELSE Existe = False END IF NovoTexto <> "Annuler l'abonnement" AND Existe = True HAdd(T003_LinksForum) END Multitask(1) nPosIni = 0 nPosFim = 0 END END FOR EACH T003_LinksForum IF T003_LinksForum.T003_Titulo = "" THEN HDelete(T003_LinksForum) END END
ELSE Info("Informe o arquivo html ou txt a ser importado") END
TableDisplay(TABLE_T003_LinksForum,taReExecuteQuery)
TableDisplay(TABLE_T003_LinksForum,taInit)
-- Adriano José Boller ______________________________________________ Consultor e Representante Oficial da PcSoft no Brasil +55 (41) 9949 1800 adrianoboller@gmail.com skype: adrianoboller http://wxinformatica.blogspot.com.br/ |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 3 657 messages Popularité : +175 (223 votes) |
|
Posté le 15 mars 2016 - 18:56 |
Para remover a acentuação na importação use:
NovoTexto = NoAccent( UTF8ToString( NovoTexto ) )
-- Adriano José Boller ______________________________________________ Consultor e Representante Oficial da PcSoft no Brasil +55 (41) 9949 1800 adrianoboller@gmail.com skype: adrianoboller http://wxinformatica.blogspot.com.br/ |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 3 657 messages Popularité : +175 (223 votes) |
|
Posté le 15 mars 2016 - 19:04 |
Prezados
E para gerar o txt do resultado obtido da lista de links de um site:
Procedure GerarTXT()
ok is boolean
Texto is string = "<html><head></head><body><br><br><br>"
FOR EACH T003_LinksForum Texto += T003_LinksForum.T003_NovoArquivo + "<br>" END
Texto += "</body></html>"
ok = fSaveText("c:\temp\links.txt",Texto)
ok = fSaveText("c:\temp\links.html",Texto)
IF ok = True THEN Info("Arquivos gerados com sucesso!") ELSE Info("Ocorreu um erro: "+ ErrorInfo()) END
Bons estudos!!!!
-- Adriano José Boller ______________________________________________ Consultor e Representante Oficial da PcSoft no Brasil +55 (41) 9949 1800 adrianoboller@gmail.com skype: adrianoboller http://wxinformatica.blogspot.com.br/ |
| |
| |
| | | |
|
| | | | |
| | |
|