Puedo invocar una WEB y llenar sus datos desde FWH

Puedo invocar una WEB y llenar sus datos desde FWH

Postby Enrrique Vertiz » Mon Dec 01, 2014 3:19 pm

Estimados, buenos dias

Mi consulta es la siguiente, si tengo que llamar desde FWH a una WEB y esta solicita 8 valores mas 1 capcha, puede mi programa cargar los valores y dejar al usuario solo el ingreso del capcha ??
Este es el link en mencion :

http://www.sunat.gob.pe/ol-ti-itconsvalicpe/ConsValiCpe.htm

Muchas gracias
Enrrique Vertiz Pitta
Lima-Peru
xHb 1.23.1026X, Fwh 23.04, MySQL 8.0.X, SQLLIB 1.9m, SQLRDD
Enrrique Vertiz
 
Posts: 514
Joined: Fri Oct 07, 2005 2:17 pm
Location: Lima - Peru

Re: Puedo invocar una WEB y llenar sus datos desde FWH

Postby Carlos Mora » Mon Dec 01, 2014 4:51 pm

¿Que tal se te da JavaScript?
La solución que se me ocurre es que crees una página, cargues la página dentro de un frame, y cuando ya esté cargada le asignas los valores a los correspondientes 'inputs' de esa web usando javascript.

Miré el código de la página, es bastante básico, (escrita con FrontPage 4.0), seguramente hay cosas para probar.
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Carlos Mora
 
Posts: 988
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: Puedo invocar una WEB y llenar sus datos desde FWH

Postby karinha » Mon Dec 01, 2014 5:57 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7254
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Puedo invocar una WEB y llenar sus datos desde FWH

Postby karinha » Mon Dec 01, 2014 6:15 pm

Code: Select all  Expand view

#include "FiveWin.ch"
#include "hbxml.ch"
#include "hbclass.ch"

/*

Puedes hacer algo asi tambien, mira se comprende:

http://www.republicavirtual.com.br/cep/exemplos.php


<webservicecep>
<resultado>2</resultado>
<resultado_txt>sucesso - cep único</resultado_txt>
<uf/>
<cidade/>
<bairro/>
<tipo_logradouro/>
<logradouro/>
</webservicecep>
*/


function main()

 //local cep := BuscaCEP():New("05171340")
 local cep := BuscaCEP():New("01330000") // Busca calle - Rua en portugues.

 ? cep:GetTipo() + " " + cep:GetLogradouro()

 ? cep:GetBairro()
 ? cep:GetCidade()
 ? cep:GetUF()

return nil

class BuscaCEP

 private:
 data cLogradouro init ""
 data cBairro init ""
 data cCidade init ""
 data cTipo init ""
 data cCep  init ""
 data cUF  init ""
 data cSrvResp init ""

 public:
 method new(cep) constructor
 method busca(cep)
 
 inline method GetLogradouro()
   return ::cLogradouro
 endmethod
 
 inline method GetBairro()
   return ::cBairro
 endmethod
 
 inline method GetCidade()
  return ::cCidade
 endmethod
 
 inline method GetTipo()
   return ::cTipo
 endmethod
 
 inline method GetUF()
   return ::cUF
 endmethod
 
 inline method GetSrvSts()
   return ::cSrvResp
 endmethod

endclass

method new(cep) class BuscaCEP

 if cep != nil
   ::cCep := cep
 else
   ::cCep := "99999999"
 endif

 ::busca()

return self

method busca(cep) class BuscaCEP

 local oHttp, cXML
 local oDoc, oIterator
 
 if cep != nil
   ::cCep := cep
 endif
 
 oHttp:= TIpClientHttp():new( "http://cep.republicavirtual.com.br/web_cep.php?cep="+::cCep+"&formato=xml" )
 oHttp:open()
 cXML := oHttp:readAll()
 oHttp:close()
 
 oDoc := TXmlDocument():New(cXML, HBXML_STYLE_NOESCAPE)

 if oDoc:nError != HBXML_ERROR_NONE

   ? "Erro ao ler o XML dos correios"

 endif

 oIterator := TXmlIterator():New( oDoc:findfirst( "webservicecep" ) )

 if oIterator:Next():cData == "1"

   ::cSrvResp  := oIterator:Next():cData
   ::cUF    := oIterator:Next():cData
   ::cCidade  := oIterator:Next():cData
   ::cBairro  := oIterator:Next():cData
   ::cTipo   := oIterator:Next():cData
   ::cLogradouro := oIterator:Next():cData

 else

   ? "ERRO :("

 endif
 
return nil
 


saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7254
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Puedo invocar una WEB y llenar sus datos desde FWH

Postby Enrrique Vertiz » Mon Dec 01, 2014 8:42 pm

Saludos Carlos, de Java solo conozco el nombre, gracias por la idea.

Saludos Karina, gracias por tu ejemplo !!! voy a probar ...
Enrrique Vertiz Pitta
Lima-Peru
xHb 1.23.1026X, Fwh 23.04, MySQL 8.0.X, SQLLIB 1.9m, SQLRDD
Enrrique Vertiz
 
Posts: 514
Joined: Fri Oct 07, 2005 2:17 pm
Location: Lima - Peru

Re: Puedo invocar una WEB y llenar sus datos desde FWH

Postby ruben Dario » Fri Dec 05, 2014 12:42 am

Gracias ,
Lo estoy compilando , pero no esta el archivo hbxml.ch , ni en (x)Harbour
Ruben Dario Gonzalez
Cali-Colombia
rubendariogd@hotmail.com - rubendariogd@gmail.com
User avatar
ruben Dario
 
Posts: 1061
Joined: Thu Sep 27, 2007 3:47 pm
Location: Colombia

Re: Puedo invocar una WEB y llenar sus datos desde FWH

Postby mastintin » Fri Dec 05, 2014 7:47 am

User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Puedo invocar una WEB y llenar sus datos desde FWH

Postby karinha » Fri Dec 05, 2014 11:05 am

C:\XHB061114\include

27/03/2014 13:07 4.053 hbxml.ch
27/03/2014 13:07 7.032 hbxml.h
27/03/2014 13:07 14.118 hbxvm.h

Code: Select all  Expand view

/*
 * $Id: hbxml.ch 9279 2011-02-14 18:06:32Z druzus $
 */


/*
 * xHarbour Project source code:
 * HBXML - XML DOM oriented routines
 * Define wrappers for xHarbour PRG.
 *
 * Copyright 2003 Giancarlo Niccolai <gian@niccolai.ws>
 *
 * www - http://www.harbour-project.org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this software; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
 *
 * As a special exception, the Harbour Project gives permission for
 * additional uses of the text contained in its release of Harbour.
 *
 * The exception is that, if you link the Harbour libraries with other
 * files to produce an executable, this does not by itself cause the
 * resulting executable to be covered by the GNU General Public License.
 * Your use of that executable is in no way restricted on account of
 * linking the Harbour library code into it.
 *
 * This exception does not however invalidate any other reasons why
 * the executable file might be covered by the GNU General Public License.
 *
 * This exception applies only to the code released by the Harbour
 * Project under the name Harbour.  If you copy code from other
 * Harbour Project or Free Software Foundation releases into a copy of
 * Harbour, as the General Public License permits, the exception does
 * not apply to the code that you add in this way.  To avoid misleading
 * anyone as to the status of such modified files, you must delete
 * this exception notice from them.
 *
 * If you write modifications of your own for Harbour, it is your choice
 * whether to permit this exception to apply to your modifications.
 * If you do not wish that, delete this exception notice.
 *
 */



#ifndef HB_XML_CH
#define HB_XML_CH

/* Styles */
#define HBXML_STYLE_NOINDENT      0  /* no indent nodes and insert new line after each node */
#define HBXML_STYLE_INDENT        1  /* indent nodes with 1 space and insert new line after each node  (default) */
#define HBXML_STYLE_TAB           2  /* indent nodes with tab spaces and insert new line after each node */
#define HBXML_STYLE_THREESPACES   4  /* indent nodes with 3 spaces and insert new line after each node */
#define HBXML_STYLE_NOESCAPE      8
#define HBXML_STYLE_NONEWLINE     16 /* no indent and no insert newline */

/* Status values */
#define HBXML_STATUS_ERROR        0
#define HBXML_STATUS_OK           1
#define HBXML_STATUS_MORE         2
#define HBXML_STATUS_DONE         3
#define HBXML_STATUS_UNDEFINED    4
#define HBXML_STATUS_MALFORMED    5

/* Error codes */
#define HBXML_ERROR_NONE          0
#define HBXML_ERROR_IO            1
#define HBXML_ERROR_NOMEM         2
#define HBXML_ERROR_OUTCHAR       3
#define HBXML_ERROR_INVNODE       4
#define HBXML_ERROR_INVATT        5
#define HBXML_ERROR_MALFATT       6
#define HBXML_ERROR_INVCHAR       7
#define HBXML_ERROR_NAMETOOLONG   8
#define HBXML_ERROR_ATTRIBTOOLONG 9
#define HBXML_ERROR_VALATTOOLONG  10
#define HBXML_ERROR_UNCLOSED      11
#define HBXML_ERROR_UNCLOSEDENTITY   12
#define HBXML_ERROR_WRONGENTITY      13

/* Node types */
#define HBXML_TYPE_TAG            0
#define HBXML_TYPE_COMMENT        1
#define HBXML_TYPE_PI             2
#define HBXML_TYPE_DIRECTIVE      3
#define HBXML_TYPE_DATA           4
#define HBXML_TYPE_CDATA          5
#define HBXML_TYPE_DOCUMENT       6

#endif
 
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7254
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Puedo invocar una WEB y llenar sus datos desde FWH

Postby ruben Dario » Fri Dec 05, 2014 12:41 pm

karinha wrote:
Code: Select all  Expand view

#include "FiveWin.ch"
#include "hbxml.ch"
#include "hbclass.ch"

/*

Puedes hacer algo asi tambien, mira se comprende:

http://www.republicavirtual.com.br/cep/exemplos.php


<webservicecep>
<resultado>2</resultado>
<resultado_txt>sucesso - cep único</resultado_txt>
<uf/>
<cidade/>
<bairro/>
<tipo_logradouro/>
<logradouro/>
</webservicecep>
*/


function main()

 //local cep := BuscaCEP():New("05171340")
 local cep := BuscaCEP():New("01330000") // Busca calle - Rua en portugues.

 ? cep:GetTipo() + " " + cep:GetLogradouro()

 ? cep:GetBairro()
 ? cep:GetCidade()
 ? cep:GetUF()

return nil

class BuscaCEP

 private:
 data cLogradouro init ""
 data cBairro init ""
 data cCidade init ""
 data cTipo init ""
 data cCep  init ""
 data cUF  init ""
 data cSrvResp init ""

 public:
 method new(cep) constructor
 method busca(cep)
 
 inline method GetLogradouro()
   return ::cLogradouro
 endmethod
 
 inline method GetBairro()
   return ::cBairro
 endmethod
 
 inline method GetCidade()
  return ::cCidade
 endmethod
 
 inline method GetTipo()
   return ::cTipo
 endmethod
 
 inline method GetUF()
   return ::cUF
 endmethod
 
 inline method GetSrvSts()
   return ::cSrvResp
 endmethod

endclass

method new(cep) class BuscaCEP

 if cep != nil
   ::cCep := cep
 else
   ::cCep := "99999999"
 endif

 ::busca()

return self

method busca(cep) class BuscaCEP

 local oHttp, cXML
 local oDoc, oIterator
 
 if cep != nil
   ::cCep := cep
 endif
 
 oHttp:= TIpClientHttp():new( "http://cep.republicavirtual.com.br/web_cep.php?cep="+::cCep+"&formato=xml" )
 oHttp:open()
 cXML := oHttp:readAll()
 oHttp:close()
 
 oDoc := TXmlDocument():New(cXML, HBXML_STYLE_NOESCAPE)

 if oDoc:nError != HBXML_ERROR_NONE

   ? "Erro ao ler o XML dos correios"

 endif

 oIterator := TXmlIterator():New( oDoc:findfirst( "webservicecep" ) )

 if oIterator:Next():cData == "1"

   ::cSrvResp  := oIterator:Next():cData
   ::cUF    := oIterator:Next():cData
   ::cCidade  := oIterator:Next():cData
   ::cBairro  := oIterator:Next():cData
   ::cTipo   := oIterator:Next():cData
   ::cLogradouro := oIterator:Next():cData

 else

   ? "ERRO :("

 endif
 
return nil
 


saludos.


Saludos

Compilo tu código y me da este error. Uso del buildh.bat de fwh .
Code: Select all  Expand view

ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³ FiveWin for Harbour 14.06 - Jun.  2014          Harbour development power  ³Ü
³ (c) FiveTech, 1993-2014   for Microsoft Windows 9X/NT/200X/ME/XP/Vista/7/8 ³Û
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙÛ
ÿ ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
Compiling...
Harbour 3.2.0dev (r1406271520)
Copyright (c) 1999-2014, http://harbour-project.org/
Compiling 'conweb.prg' and generating preprocessed output to 'conweb.ppo'...

14 errors

No code generated.

conweb.prg(38) Error E0020  Incomplete statement or unbalanced delimiters

conweb.prg(47) Error E0020  Incomplete statement or unbalanced delimiters

conweb.prg(51) Error E0030  Syntax error "syntax error at 'METHOD'"

conweb.prg(52) Error E0025  Invalid RETURN from within of SEQUENCE code

conweb.prg(52) Warning W0001  Ambiguous reference 'SELF'

conweb.prg(55) Error E0030  Syntax error "syntax error at 'METHOD'"

conweb.prg(56) Error E0025  Invalid RETURN from within of SEQUENCE code

conweb.prg(56) Warning W0001  Ambiguous reference 'SELF'

conweb.prg(59) Error E0030  Syntax error "syntax error at 'METHOD'"

conweb.prg(60) Error E0025  Invalid RETURN from within of SEQUENCE code

conweb.prg(60) Warning W0001  Ambiguous reference 'SELF'

conweb.prg(63) Error E0030  Syntax error "syntax error at 'METHOD'"

conweb.prg(64) Error E0025  Invalid RETURN from within of SEQUENCE code

conweb.prg(64) Warning W0001  Ambiguous reference 'SELF'

conweb.prg(67) Error E0030  Syntax error "syntax error at 'METHOD'"

conweb.prg(68) Error E0025  Invalid RETURN from within of SEQUENCE code

conweb.prg(68) Warning W0001  Ambiguous reference 'SELF'

conweb.prg(71) Error E0030  Syntax error "syntax error at 'METHOD'"

conweb.prg(72) Error E0025  Invalid RETURN from within of SEQUENCE code

conweb.prg(72) Warning W0001  Ambiguous reference 'SELF'
* Compile errors *
 
Ruben Dario Gonzalez
Cali-Colombia
rubendariogd@hotmail.com - rubendariogd@gmail.com
User avatar
ruben Dario
 
Posts: 1061
Joined: Thu Sep 27, 2007 3:47 pm
Location: Colombia

Re: Puedo invocar una WEB y llenar sus datos desde FWH

Postby karinha » Fri Dec 05, 2014 1:07 pm

Ruben este ejemplo és para FWH.. y xHARBOUR no se como se hace en HARBOUR, pués no uso HARBOUR aún.


saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7254
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Puedo invocar una WEB y llenar sus datos desde FWH

Postby Biel EA6DD » Fri Dec 12, 2014 8:28 am

Si se dispone de Internet Explorer, puedes usar InternetExplorer.Application
Puedes manejar cualquier objeto de la web, pulsar botones, etc, "simplemente" necesitas el nombre del objeto y el método o data que quieres manipular.

En concreto para la web que expones, algo así.
Code: Select all  Expand view

#include "FiveWin.ch"
FUNCTION main()
   LOCAL oIe,oDoc,nPos, oForm, oObj,cName
   TRY
      oIE:=CreateObject("InternetExplorer.Application")
   CATCH
      MsgStop('Error al crear el componente InternetExplorer.Application')
      RETURN NIL
   END
   oIE:Navigate( "http://www.sunat.gob.pe/ol-ti-itconsvalicpe/ConsValiCpe.htm" )
   HB_IDLESLEEP( 1 )
   nPos:=0
   WHILE oIE:ReadyState <> 4 .AND. nPos<20
      HB_IDLESLEEP( 1 )
      nPos++
   END
   IF nPos>=20
      MsgStop('Tiempo de descarga superado')
      RETURN NIL
   ENDIF
   oDoc:=oIE:Document
   FOR EACH oForm IN oDoc:Forms
      FOR EACH oObj IN oForm:all
         TRY
            cName:=oObj:Name
         CATCH
            cName:=''
         END
         DO CASE
         CASE cName=='num_ruc'
            oObj:Value:='12345'
         CASE cName=='num_docide'
            oObj:Value:='98765'
         ENDCASE
      NEXT
   NEXT
   oIe:Visible:=.T.
RETURN NIL
 
Saludos desde Mallorca
Biel Maimó
http://bielsys.blogspot.com/
User avatar
Biel EA6DD
 
Posts: 682
Joined: Tue Feb 14, 2006 9:48 am
Location: Mallorca

Re: Puedo invocar una WEB y llenar sus datos desde FWH

Postby Enrrique Vertiz » Fri Dec 12, 2014 3:08 pm

Muchas gracias a todos por sus respuestas.
Biel, con la tuya solucione el tema casi en su totalidad, MIL GRACIAS !!!, tengo unos problemas con el paso de valores a los Listbox y en la variable fecha, pero con lo que indicas entre al Debug del IE y revise la Web, espero encontrar la solucion
GRACIAS nuevamente !!!
Enrrique Vertiz Pitta
Lima-Peru
xHb 1.23.1026X, Fwh 23.04, MySQL 8.0.X, SQLLIB 1.9m, SQLRDD
Enrrique Vertiz
 
Posts: 514
Joined: Fri Oct 07, 2005 2:17 pm
Location: Lima - Peru


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 10 guests