FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Capturar pagina html y recuperar resultado
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Capturar pagina html y recuperar resultado
Posted: Wed Sep 18, 2024 03:51 PM
Antonio buenos d铆as como estas, que pena molestar de nuevo.

Pero quer铆a saber si ya tienes las lib de FW2407 con la actualizaci贸n del webview2 para poder implementar esta soluci贸n en la app. :D

Gracias de antemano.

Pdta. las necesitamos en 32 y 64 bits :oops:
Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Capturar pagina html y recuperar resultado
Posted: Wed Oct 02, 2024 08:01 PM
Antonio primero que todo agradecerte por la ayuda con este tema, ya que nos enviaste la actualizaci贸n con la revisi贸n del webview2, estamos intentando hacer la implementaci贸n de la soluci贸n para nuestros clientes, pero tenemos el problema que el c贸digo funciona de maravilla si lo compilamos solito en la carpeta samples del fw2409, pero cuando lo integramos a nuestra app, nos arroja un error, creo que puede ser referente a alguna librer铆a que nos hace falta enlazar, de antemano gracias.

el c贸digo:
Code (fw): Select all Collapse
#include "FiveWin.ch"

function consulta(cTerc)

聽 聽local oWnd, cResult, oWebView
聽 聽local cConsulta := space(0)
聽 聽DEFAULT cTerc := "79760202"

聽 聽cConsulta := "consultaDIAN( '"+cTerc+"' )"聽 聽

聽 聽TEXT INTO cResult
聽 聽 聽 [ document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:primerNombre' ).innerHTML,
聽 聽 聽 聽 document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:otrosNombres' ).innerHTML,
聽 聽 聽 聽 document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:primerApellido' ).innerHTML,
聽 聽 聽 聽 document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:segundoApellido' ).innerHTML,
聽 聽 聽 聽 document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:estado' ).innerHTML,
聽 聽 聽 聽 document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:dv' ).innerHTML ]
聽 聽ENDTEXT 聽 聽

聽 聽DEFINE WINDOW oWnd TITLE "Usando DIAN desde un webview" SIZE 1050, 700
聽 聽oWnd:Hide()
聽 聽
聽 聽oWebView = TWebView2():New( oWnd )
聽 聽oWebView:bOnNavigationCompleted = { | cUrl, hWebView | If( "sessionid" $ cUrl, oWebView:Eval( cResult ),) }

聽 聽oWebView:Navigate( "https://muisca.dian.gov.co/WebRutMuisca/DefConsultaEstadoRUT.faces" )
聽 聽oWebView:InjectJavascript( JavaScript() )
聽 聽oWebView:bOnEval = { | cJson, hWebView | If( cJson != "null" .and. cJson != "{}", ( MsgInfo( cJson ), oWnd:End() ),) }
聽 聽oWebView:Eval( 聽)

聽 聽ACTIVATE WINDOW oWnd CENTER ;
聽 聽 聽 ON INIT oWnd:Hide() ;
聽 聽 聽 ON RESIZE oWebView:SetSize( nWidth, nHeight )

聽 聽oWebView:End()

return nil

function Javascript()

聽 聽local cCode

聽 聽TEXT INTO cCode
聽 聽 聽 function consultaDIAN( numeroIdentificacion )
聽 聽 聽 {
聽 聽 聽 聽 聽var inputNIT = document.getElementById('vistaConsultaEstadoRUT:formConsultaEstadoRUT:numNit');
聽 聽 聽 聽 聽if (inputNIT) {
聽 聽 聽 聽 聽 聽 inputNIT.value = numeroIdentificacion;
聽 聽 聽 聽 聽} else {
聽 聽 聽 聽 聽 聽 console.error('No se encontr贸 el campo de entrada para el NIT');
聽 聽 聽 聽 聽 聽 return;
聽 聽 聽 聽 聽} 聽 聽
聽 聽 聽 聽 聽
聽 聽 聽 聽 聽var botonBuscar = document.getElementById('vistaConsultaEstadoRUT:formConsultaEstadoRUT:btnBuscar');
聽 聽 聽 聽 聽if (botonBuscar) {
聽 聽 聽 聽 聽 聽 botonBuscar.click();
聽 聽 聽 聽 聽} else {
聽 聽 聽 聽 聽 聽 console.error('No se encontr贸 el bot贸n de b煤squeda');
聽 聽 聽 聽 聽 聽 return;
聽 聽 聽 聽 聽}
聽 聽 聽 }
聽 聽ENDTEXT

return cCode
El error en nuestra app
Code (fw): Select all Collapse
Application
===========
聽 聽Path and name: C:\cmplar_64\hymlyma.exe (64 bits)
聽 聽Size: ********* bytes
聽 聽Compiler version: xHarbour 1.3.1 Intl. (SimpLex) (Build 20240624)
聽 聽FiveWin 聽version: FWH 24.07
聽 聽C compiler version: LLVM/Clang C 5.0.2 (64-bit)
聽 聽Windows 8 64 Bits, version: 6.2, Build 9200 

聽 聽Time from start: 0 hours 0 mins 10 secs 
聽 聽Error occurred at: 02/10/2024, 14:59:07
聽 聽Error description: Error BASE/1070 聽Error de argumento: ==
聽 聽Args:
聽 聽 聽[ 聽 1] = N 聽 0
聽 聽 聽[ 聽 2] = P 聽 0x1C39685D0C8

Stack Calls
===========
聽 聽Called from: .\source\classes\twebview2.prg => (b)WEBVIEW2_ONEVAL( 128 )
聽 聽Called from: 聽=> ASCAN( 0 )
聽 聽Called from: .\source\classes\twebview2.prg => WEBVIEW2_ONEVAL( 128 )
聽 聽Called from: 聽=> WINRUN( 0 )
聽 聽Called from: .\source\classes\window.prg => TMDIFRAME:ACTIVATE( 1117 )
聽 聽Called from: .\PRG\R32_menu.prg => VTNAPRINCIPAL( 976 )
聽 聽Called from: .\PRG\R32_menu.prg => MAIN( 123 )

System
======
聽 聽Hardware memory: 32510 megs

聽 聽Free System resources: 90 %
聽 聽 聽 聽 GDI 聽 聽resources: 90 %
聽 聽 聽 聽 User 聽 resources: 90 %

聽 聽Windows total applications running: 1
聽 聽 聽 1 , 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 

Variables in use
================
聽 聽Procedure 聽 聽 Type 聽 Value
聽 聽==========================
聽 聽(b)WEBVIEW2_ONEVAL
聽 聽 聽Param 聽 1: 聽 聽O 聽 聽Class: TWEBVIEW2
聽 聽 聽Param 聽 2: 聽 聽N 聽 聽1
聽 聽 聽Local 聽 1: 聽 聽N 聽 聽0
聽 聽 聽Local 聽 2: 聽 聽P 聽 聽0x1C39685D0C8
聽 聽 聽Local 聽 3: 聽 聽U 聽 聽
聽 聽 聽Local 聽 4: 聽 聽U 聽 聽
聽 聽ASCAN
聽 聽 聽Param 聽 1: 聽 聽A 聽 聽Len: 聽 聽1
聽 聽 聽Param 聽 2: 聽 聽B 聽 聽{|| ... }
聽 聽WEBVIEW2_ONEVAL
聽 聽 聽Param 聽 1: 聽 聽C 聽 聽"null"
聽 聽 聽Param 聽 2: 聽 聽P 聽 聽0x1C39685D0C8
聽 聽 聽Local 聽 1: 聽 聽U 聽 聽
聽 聽 聽Local 聽 2: 聽 聽U 聽 聽
聽 聽WINRUN
聽 聽 聽Param 聽 1: 聽 聽N 聽 聽132530
聽 聽TMDIFRAME:ACTIVATE
聽 聽 聽Param 聽 1: 聽 聽C 聽 聽"NORMAL"
聽 聽 聽Param 聽 2: 聽 聽U 聽 聽
聽 聽 聽Param 聽 3: 聽 聽U 聽 聽
聽 聽 聽Param 聽 4: 聽 聽U 聽 聽
聽 聽 聽Param 聽 5: 聽 聽U 聽 聽
聽 聽 聽Param 聽 6: 聽 聽B 聽 聽{|| ... }
聽 聽 聽Param 聽 7: 聽 聽B 聽 聽{|| ... }
聽 聽 聽Param 聽 8: 聽 聽B 聽 聽{|| ... }
聽 聽 聽Param 聽 9: 聽 聽U 聽 聽
聽 聽 聽Param 聽10: 聽 聽U 聽 聽
聽 聽 聽Param 聽11: 聽 聽U 聽 聽
聽 聽 聽Param 聽12: 聽 聽U 聽 聽
聽 聽 聽Param 聽13: 聽 聽U 聽 聽
聽 聽 聽Param 聽14: 聽 聽U 聽 聽
聽 聽 聽Param 聽15: 聽 聽U 聽 聽
聽 聽 聽Param 聽16: 聽 聽U 聽 聽
聽 聽 聽Param 聽17: 聽 聽B 聽 聽{|| ... }
聽 聽 聽Param 聽18: 聽 聽U 聽 聽
聽 聽 聽Param 聽19: 聽 聽U 聽 聽
聽 聽 聽Param 聽20: 聽 聽L 聽 聽.F.
聽 聽 聽Local 聽 1: 聽 聽O 聽 聽Class: TMDIFRAME
聽 聽 聽Local 聽 2: 聽 聽U 聽 聽
聽 聽 聽Local 聽 3: 聽 聽U 聽 聽
聽 聽VTNAPRINCIPAL
聽 聽 聽Local 聽 1: 聽 聽C 聽 聽"Tahoma"
聽 聽 聽Local 聽 2: 聽 聽N 聽 聽12
聽 聽 聽Local 聽 3: 聽 聽U 聽 聽
聽 聽 聽Local 聽 4: 聽 聽U 聽 聽
聽 聽 聽Local 聽 5: 聽 聽U 聽 聽
聽 聽 聽Local 聽 6: 聽 聽O 聽 聽Class: TINI
聽 聽 聽Local 聽 7: 聽 聽O 聽 聽Class: TTIMER
聽 聽 聽Local 聽 8: 聽 聽O 聽 聽Class: TTIMER


聽 聽MAIN
聽 聽 聽Local 聽 1: 聽 聽U 聽 聽
聽 聽 聽Local 聽 2: 聽 聽U 聽 聽
聽 聽 聽Local 聽 3: 聽 聽U 聽 聽
聽 聽 聽Local 聽 4: 聽 聽U
Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Capturar pagina html y recuperar resultado
Posted: Thu Oct 03, 2024 04:24 AM
Leandro, prueba a quitar esto
Code (fw): Select all Collapse
// 聽oWebView:Eval( 聽)
y ponerlo en el ON INIT de la ventana
Code (fw): Select all Collapse
.../...

聽 聽ON INIT ( oWnd:Hide(), 聽 oWebView:Eval() ) ;
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Capturar pagina html y recuperar resultado
Posted: Thu Oct 03, 2024 04:31 AM

Leandro,

Adem谩s de lo que te comenta Cristobal, dos cosas:

  1. despu茅s de oWebView = TWebView2():New( oWnd ) a帽ade esta l铆nea:

MsgInfo( oWebView:hWebView )

y mira a ver si tiene un handle v谩lido o un cero

  1. Cuando llamas a oWebView:Eval( ) no le pasas ning煤n c贸digo javascript a ejecutar ??? Eso es diferente. Tal vez eso afecte...
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Capturar pagina html y recuperar resultado
Posted: Thu Oct 03, 2024 09:55 PM
Hola buenas tardes...

No se que cambie, pero ahora no funciona ni compilando el prg solito, el que publicaste funcionando en este mismo POST :oops:

El c贸digo
Code (fw): Select all Collapse
#include "FiveWin.ch"

static oWebView

function Main()

聽 聽local oWnd, cResult

聽 聽TEXT INTO cResult
聽 聽 聽 [ document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:primerNombre' ).innerHTML,
聽 聽 聽 聽 document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:otrosNombres' ).innerHTML,
聽 聽 聽 聽 document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:primerApellido' ).innerHTML,
聽 聽 聽 聽 document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:segundoApellido' ).innerHTML,
聽 聽 聽 聽 document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:estado' ).innerHTML,
聽 聽 聽 聽 document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:dv' ).innerHTML ]
聽 聽ENDTEXT 聽 聽

聽 聽DEFINE WINDOW oWnd TITLE "Usando DIAN desde un webview" SIZE 1050, 700
聽 聽oWnd:Hide()
聽 聽
聽 聽oWebView = TWebView2():New( oWnd )
聽 聽oWebView:bOnNavigationCompleted = { | cUrl, hWebView | If( "sessionid" $ cUrl, oWebView:Eval( cResult ),) }

聽 聽oWebView:Navigate( "https://muisca.dian.gov.co/WebRutMuisca/DefConsultaEstadoRUT.faces" )
聽 聽oWebView:InjectJavascript( JavaScript() )
聽 聽// oWebView:OpenDevToolsWindow()
聽 聽oWebView:bOnEval = { | cJson, hWebView | If( cJson != "null" .and. cJson != "{}", ( MsgInfo( cJson ), oWnd:End() ),) }
聽 聽oWebView:Eval( "consultaDIAN( '79760202' )" )

聽 聽ACTIVATE WINDOW oWnd CENTER ;
聽 聽 聽 ON INIT oWnd:Hide() ;
聽 聽 聽 ON RESIZE oWebView:SetSize( nWidth, nHeight )

聽 聽oWebView:End()

return nil

function Javascript()

聽 聽local cCode

聽 聽TEXT INTO cCode
聽 聽 聽 function consultaDIAN( numeroIdentificacion )
聽 聽 聽 {
聽 聽 聽 聽 聽var inputNIT = document.getElementById('vistaConsultaEstadoRUT:formConsultaEstadoRUT:numNit');
聽 聽 聽 聽 聽if (inputNIT) {
聽 聽 聽 聽 聽 聽 inputNIT.value = numeroIdentificacion;
聽 聽 聽 聽 聽} else {
聽 聽 聽 聽 聽 聽 console.error('No se encontr贸 el campo de entrada para el NIT');
聽 聽 聽 聽 聽 聽 return;
聽 聽 聽 聽 聽} 聽 聽
聽 聽 聽 聽 聽
聽 聽 聽 聽 聽var botonBuscar = document.getElementById('vistaConsultaEstadoRUT:formConsultaEstadoRUT:btnBuscar');
聽 聽 聽 聽 聽if (botonBuscar) {
聽 聽 聽 聽 聽 聽 botonBuscar.click();
聽 聽 聽 聽 聽} else {
聽 聽 聽 聽 聽 聽 console.error('No se encontr贸 el bot贸n de b煤squeda');
聽 聽 聽 聽 聽 聽 return;
聽 聽 聽 聽 聽}
聽 聽 聽 }
聽 聽ENDTEXT

return cCode
El error
Code (fw): Select all Collapse
Application
===========
聽 聽Path and name: C:\fwh64_2409\samples\leandro6.exe (64 bits)
聽 聽Size: 5,665,792 bytes
聽 聽Compiler version: xHarbour 1.3.1 Intl. (SimpLex) (Build 20240624)
聽 聽FiveWin 聽version: FWH 24.07
聽 聽C compiler version: LLVM/Clang C 5.0.2 (64-bit)
聽 聽Windows 8 64 Bits, version: 6.2, Build 9200 

聽 聽Time from start: 0 hours 0 mins 0 secs 
聽 聽Error occurred at: 10/03/24, 16:43:33
聽 聽Error description: Warning BASE/1005 聽Message not found: TWEBVIEW2:_BONNAVIGATIONCOMPLETED

Stack Calls
===========
聽 聽Called from: source\rtl\tobject.prg => TWEBVIEW2:ERROR( 0 )
聽 聽Called from: source\rtl\tobject.prg => TWEBVIEW2:MSGNOTFOUND( 0 )
聽 聽Called from: source\rtl\tobject.prg => TWEBVIEW2:_BONNAVIGATIONCOMPLETED( 0 )
聽 聽Called from: leandro6.prg => MAIN( 22 )

System
======
聽 聽Hardware memory: 32510 megs

聽 聽Free System resources: 90 %
聽 聽 聽 聽 GDI 聽 聽resources: 90 %
聽 聽 聽 聽 User 聽 resources: 90 %

聽 聽Windows total applications running: 1
聽 聽 聽 1 , 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 

Variables in use
================
聽 聽Procedure 聽 聽 Type 聽 Value
聽 聽==========================
聽 聽TWEBVIEW2:ERROR
聽 聽 聽Param 聽 1: 聽 聽C 聽 聽"Message not found"
聽 聽 聽Param 聽 2: 聽 聽C 聽 聽"TWEBVIEW2"
聽 聽 聽Param 聽 3: 聽 聽C 聽 聽"_BONNAVIGATIONCOMPLETED"
聽 聽 聽Param 聽 4: 聽 聽N 聽 聽1005
聽 聽 聽Local 聽 1: 聽 聽U 聽 聽
聽 聽 聽Local 聽 2: 聽 聽O 聽 聽Class: TWEBVIEW2
聽 聽 聽Local 聽 3: 聽 聽N 聽 聽16
聽 聽TWEBVIEW2:MSGNOTFOUND
聽 聽 聽Param 聽 1: 聽 聽C 聽 聽"_BONNAVIGATIONCOMPLETED"
聽 聽 聽Param 聽 2: 聽 聽O 聽 聽Class: TWEBVIEW2
聽 聽TWEBVIEW2:_BONNAVIGATIONCOMPLETED
聽 聽 聽Param 聽 1: 聽 聽B 聽 聽{|| ... }
聽 聽MAIN
聽 聽 聽Local 聽 1: 聽 聽O 聽 聽Class: TWINDOW
聽 聽 聽Local 聽 2: 聽 聽C 聽 聽" 聽 聽 聽[ document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:primerNombre' ).innerHTML, 聽 聽 聽 聽document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:otrosNombres' ).innerHTML, 聽 聽 聽 聽document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:primerApellido' ).innerHTML, 聽 聽 聽 聽document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:segundoApellido' ).innerHTML, 聽 聽 聽 聽document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:estado' ).innerHTML, 聽 聽 聽 聽document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:dv' ).innerHTML ]"

Linked RDDs
===========
聽 聽DBF
聽 聽DBFFPT
聽 聽DBFBLOB
聽 聽DBFCDX
聽 聽DBFNTX

DataBases in use
================

Classes in use:
===============
聽 聽 聽1 ERROR
聽 聽 聽2 HASHENTRY
聽 聽 聽3 HBCLASS
聽 聽 聽4 HBOBJECT
聽 聽 聽5 TWINDOW
聽 聽 聽6 TBRUSH
聽 聽 聽7 TFONT
聽 聽 聽8 TREG32
聽 聽 聽9 TWEBVIEW2

Memory Analysis
===============
聽 聽 聽 730 Static variables

聽 聽Dynamic memory consume:
聽 聽 聽 Actual 聽Value: 聽 聽 聽 聽 聽0 bytes
聽 聽 聽 Highest Value: 聽 聽 聽 聽 聽0 bytes
Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Capturar pagina html y recuperar resultado
Posted: Fri Oct 04, 2024 06:49 AM

No estar谩s enlazando una clase TWebView2 tuya de las publicadas en estos foros ?

Revisa todos tus PRGs a ver si la tienes a帽adida en alguno

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Capturar pagina html y recuperar resultado
Posted: Fri Oct 04, 2024 01:58 PM
cnavarro wrote:Leandro, prueba a quitar esto
Code (fw): Select all Collapse
// 聽oWebView:Eval( 聽)
y ponerlo en el ON INIT de la ventana
Code (fw): Select all Collapse
.../...

聽 聽ON INIT ( oWnd:Hide(), 聽 oWebView:Eval() ) ;
Amigo ya hice lo que mencionaste pero nada sigue devolviendo el mismo error
Antonio Linares wrote:Leandro,

Adem谩s de lo que te comenta Cristobal, dos cosas:

1. despu茅s de oWebView = TWebView2():New( oWnd ) a帽ade esta l铆nea:

MsgInfo( oWebView:hWebView )

y mira a ver si tiene un handle v谩lido o un cero

2. Cuando llamas a oWebView:Eval( ) no le pasas ning煤n c贸digo javascript a ejecutar ??? Eso es diferente. Tal vez eso afecte...
Antonio hicimos lo que mencionas y nos devolvi贸 el siguiente resultado:
Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Capturar pagina html y recuperar resultado
Posted: Fri Oct 04, 2024 02:27 PM
Bueno redujimos el c贸digo a lo mas peque帽o posible para intentar encontrar el error, la pagina la carga correctamente pero cuando ingresamos la linea oWebView:InjectJavascript( Javascript() ) crash, se revienta.
Code (fw): Select all Collapse
#include "FiveWin.ch"

static oWebView

consultaDIAN()

function consultaDIAN()

聽 聽local oWnd

聽 聽DEFINE WINDOW oWnd TITLE "Usando DIAN desde un webview" SIZE 1050, 700
聽 聽 聽 聽oWebView = TWebView2():New( oWnd )
聽 聽 聽 聽oWebView:Navigate( "https://muisca.dian.gov.co/WebRutMuisca/DefConsultaEstadoRUT.faces" )
聽 聽 聽 聽oWebView:InjectJavascript( Javascript() )
聽 聽ACTIVATE WINDOW oWnd CENTER ON RESIZE oWebView:SetSize( nWidth, nHeight )

聽 聽oWebView:End()

return nil

function Javascript()
聽 聽local cCode
聽 聽TEXT INTO cCode
聽 聽 聽 function consultaDIAN()
聽 聽 聽 {
聽 聽 聽 聽 聽var inputNIT = document.getElementById('vistaConsultaEstadoRUT:formConsultaEstadoRUT:numNit');
聽 聽 聽 聽 聽if (inputNIT) {
聽 聽 聽 聽 聽 聽 inputNIT.value = "79760202";
聽 聽 聽 聽 聽} else {
聽 聽 聽 聽 聽 聽 console.error('No se encontr贸 el campo de entrada para el NIT');
聽 聽 聽 聽 聽 聽 return;
聽 聽 聽 聽 聽} 聽 聽
聽 聽 聽 }
聽 聽ENDTEXT
return cCode
Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Capturar pagina html y recuperar resultado
Posted: Fri Oct 04, 2024 04:46 PM
Bueno parece ser, seg煤n lo que he entendido, es que el METHOD InjectJavascript( cScript ) CLASS TWebView2, no solo inyecta el c贸digo, si no que tambi茅n lo ejecuta.

Con este c贸digo el navegador alcanza a mostrar el alert() con la informaci贸n que le acabamos de pasar, pero inmediatamente le damos clic en aceptar en el alert del navegador, la aplicaci贸n sin mas ni mas se cierra y no deja rastro en el archivo error.log
Code (fw): Select all Collapse
#include "FiveWin.ch"

static oWebView

consultaDIAN()

function consultaDIAN()

聽 聽 local oWnd
聽 聽 local cJavaScript := Javascript()

聽 聽 DEFINE WINDOW oWnd TITLE "Usando DIAN desde un webview" SIZE 1050, 700
聽 聽 聽 聽 oWebView = TWebView2():New( oWnd )
聽 聽 聽 聽 oWebView:Navigate( "https://muisca.dian.gov.co/WebRutMuisca/DefConsultaEstadoRUT.faces" )
聽 聽 聽 聽 oWebView:InjectJavascript( cJavaScript )
聽 聽 聽 聽 
聽 聽 ACTIVATE WINDOW oWnd CENTER ON RESIZE oWebView:SetSize( nWidth, nHeight )

聽 聽 oWebView:End()

return nil

function Javascript()
聽 聽 local cCode
聽 聽 TEXT INTO cCode
聽 聽 聽 聽 var inputNIT = document.getElementById('vistaConsultaEstadoRUT:formConsultaEstadoRUT:numNit');
聽 聽 聽 聽 inputNIT.value = '79760202';
聽 聽 聽 聽 alert(inputNIT.value);
聽 聽 ENDTEXT
return cCode
Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Capturar pagina html y recuperar resultado
Posted: Fri Oct 04, 2024 05:29 PM
Leandro,

Aqui no se ejecuta el alert() hasta que no se descomenta la l铆nea del oWebView:Eval( ... )

Luego InjectJavascript() NO ejecuta el c贸digo. A ver si estas enlazando una Clase TWebView2 modificada...
Code (fw): Select all Collapse
#include "FiveWin.ch"

static oWebView

function Main()

聽 聽local oWnd

聽 聽DEFINE WINDOW oWnd TITLE "Usando DIAN desde un webview" SIZE 1050, 700
聽 聽 聽 聽oWebView = TWebView2():New( oWnd )
聽 聽 聽 聽oWebView:Navigate( "https://muisca.dian.gov.co/WebRutMuisca/DefConsultaEstadoRUT.faces" )
聽 聽 聽 聽oWebView:InjectJavascript( Javascript() )
聽 聽 聽 聽// oWebView:Eval( "consultaDIAN()" )
聽 聽ACTIVATE WINDOW oWnd CENTER ON RESIZE oWebView:SetSize( nWidth, nHeight )

聽 聽oWebView:End()

return nil

function Javascript()
聽 聽local cCode
聽 聽TEXT INTO cCode
聽 聽 聽 function consultaDIAN()
聽 聽 聽 {
聽 聽 聽 聽 聽var inputNIT = document.getElementById('vistaConsultaEstadoRUT:formConsultaEstadoRUT:numNit');
聽 聽 聽 聽 聽if (inputNIT) {
聽 聽 聽 聽 聽 聽 inputNIT.value = "79760202";
聽 聽 聽 聽 聽} else {
聽 聽 聽 聽 聽 聽 console.error('No se encontr贸 el campo de entrada para el NIT');
聽 聽 聽 聽 聽 聽 return;
聽 聽 聽 聽 聽} 聽 聽
聽 聽 聽 聽 聽alert( "aqui" ); 聽 聽 聽 
聽 聽 聽 }
聽 聽ENDTEXT
return cCode
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Capturar pagina html y recuperar resultado
Posted: Fri Oct 04, 2024 07:21 PM
Antonio gracias por responder, ni siquiera se como agregar una librer铆a diferente :oops: estamos usando la versi贸n que nos enviaste FWH64_2409.

Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Capturar pagina html y recuperar resultado
Posted: Fri Oct 04, 2024 07:49 PM
Reinstalamos la nueva versi贸n de FW64_2409 y compilamos el ultimo c贸digo que nos enviaste dentro de la carpeta samples y efectivamente tiene el mismo comportamiento que mencionas, el c贸digo se ejecuta 煤nicamente cuando se descomenta la l铆nea oWebView:Eval( "consultaDIAN()" )


Como hacemos para saber que libreria esta usando hbmk2, no sabemos si, el agregue algo que no se necesita.

Lo que si hemos notado es que muestra un warning al generar el ejecutable
Code (fw): Select all Collapse
...
...
...
Lines 58, Functions/Procedures 2, pCodes 144
xHarbour 1.3.1 Intl. (SimpLex) (Build 20240624)
Copyright 1999-2024, http://www.xharbour.org http://www.harbour-project.org/
Compiling '.\PRG\R64_fact.prg'...
Generating C source output to 'obj\R64_fact.c'...
Done.
Lines 39, Functions/Procedures 3, pCodes 186
bcc64.exe: warning: argument unused during compilation: '-Lc:\bcc770_64\LIB' [-Wunused-command-line-argument]
obj\R32_menu.c:
obj\R32_perm.c:
obj\Alyma.c:
obj\R32_bode.c:
obj\R32_cate.c:
obj\R32_ciud.c:
...
...
...
Tambi茅n revisamos las rutas de compilaci贸n del bat, buildx64.bat que esta en la carpeta samples y son las mismas que est谩n en el archivo .hbp

buildx64.bat
Code (fw): Select all Collapse
...
...
...

if "%FWDIR%" == "" set FWDIR=C:\fwh64_2409
if "%HBDIR%" == "" set HBDIR=C:\xHar2407_64
rem if "%2" == "/b" set GT=gtwin
rem if not "%2" == "/b" set GT=gtgui
set GT=gtgui
ECHO Compiling...

set hdir=%HBDIR%
set hdirl=%hdir%\lib
set fwh=%FWDIR%
set bcdir=C:\bcc770_64

...
...
...
xhb.hbp
Code (fw): Select all Collapse
-optim-
-ldflag+=-aa -n- 
-Ic:\fwh64_2409\include
-Lc:\fwh64_2409\lib
xgo64.bat
Code (fw): Select all Collapse
set bcc=bcc770_64
set path=c:\%bcc%\bin
set HB_USER_CFLAGS=-Ic:\%bcc%\INCLUDE\windows\crtl -Ic:\%bcc%\INCLUDE\windows\sdk -Lc:\%bcc%\LIB
set HB_USER_LDFLAGS=-Lc:\%bcc%\LIB;c:\%bcc%\LIB\psdk
c:\xHar2407_64\bin\hbmk2.exe xhbcmp.hbp -xhb -comp=bcc64
Cual ser谩 el error, de antemano gracias
Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Capturar pagina html y recuperar resultado
Posted: Fri Oct 04, 2024 11:14 PM

Estimado Leandro,

> Cual ser谩 el error

Que error ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Capturar pagina html y recuperar resultado
Posted: Sat Oct 05, 2024 03:10 PM
Antonio gracias por responder

El que vengo reportando

:shock:
Code (fw): Select all Collapse
Application
===========
聽 聽Path and name: C:\cmplar_64\hymlyma.exe (64 bits)
聽 聽Size: ********* bytes
聽 聽Compiler version: xHarbour 1.3.1 Intl. (SimpLex) (Build 20240624)
聽 聽FiveWin 聽version: FWH 24.07
聽 聽C compiler version: LLVM/Clang C 5.0.2 (64-bit)
聽 聽Windows 8 64 Bits, version: 6.2, Build 9200 

聽 聽Time from start: 0 hours 0 mins 9 secs 
聽 聽Error occurred at: 05/10/2024, 10:08:03
聽 聽Error description: Error BASE/1070 聽Error de argumento: ==
聽 聽Args:
聽 聽 聽[ 聽 1] = N 聽 0
聽 聽 聽[ 聽 2] = P 聽 0x2345D41D818

Stack Calls
===========
聽 聽Called from: .\source\classes\twebview2.prg => (b)WEBVIEW2_ONEVAL( 128 )
聽 聽Called from: 聽=> ASCAN( 0 )
聽 聽Called from: .\source\classes\twebview2.prg => WEBVIEW2_ONEVAL( 128 )
聽 聽Called from: 聽=> WINRUN( 0 )
聽 聽Called from: .\source\classes\window.prg => TMDIFRAME:ACTIVATE( 1117 )
聽 聽Called from: .\PRG\R32_menu.prg => VTNAPRINCIPAL( 976 )
聽 聽Called from: .\PRG\R32_menu.prg => MAIN( 123 )
No se, si tenga que ver con alguna dll del webview que esta mal integrada.

Nosotros estamos usando el webview1 en varias partes de la app, tiene algo que ver eso?
Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Capturar pagina html y recuperar resultado
Posted: Sat Oct 05, 2024 03:42 PM

Lo est谩s usando en un entorno MDI, tal vez est茅 relacionado

Lo curioso es por que el handle del webview vale cero...

regards, saludos

Antonio Linares
www.fivetechsoft.com