Jump to content
Fivewin Brasil

Problema na Busca do Cnpj site da receita


Marca

Recommended Posts

Bom dia pessoal
Em minha rotina de busca do CNPJ utilizando a url https://www.receita.fazenda.gov.br/pessoajuridica/cnpj/cnpjreva/cnpjreva_solicitacao2.asp

Caso eu jogue esta no browser abre normalmente a tela do NAO SOU ROBO

sendo q. por dentro do sistema não consigo fazer esta tela NAO SOU ROBO abrir utilizando o

   oActiveX := TActivex():New( oDlgSint, "Shell.Explorer", 0, 0, 900, 600 )

Alguém já passou por isso ?


 

Link to comment
Share on other sites

Fiz todos os testes possíveis com Activex e no Internet Explorer não vai. No google vai. 

 

#include "FiveWin.ch"
	STATIC oWnd, oActivex
	FUNCTION Main()
	   LOCAL oBar
	   DEFINE WINDOW oWnd TITLE "Google Action"
	   DEFINE BUTTONBAR oBar _3D OF oWnd
	   DEFINE BUTTON OF oBar ACTION Receita( oWnd )
	   SET MESSAGE OF oWnd TO "Google Action" NOINSET CLOCK DATE KEYBOARD
	   ACTIVATE WINDOW oWnd
	RETURN NIL
	Function Receita( oWnd )
	   Local cPortal
   local cEvents := ""
	   If !IsInternet()
	      Msgalert("Não conectado a internet.", "Aviso!")
	      Return nil
	   Endif
	   MsgWait( "CONECTANDO AO PORTAL DA RECEITA ", ;
            "AGUARDE...                      ", 3.0 )
	   DEFINE WINDOW oWnd FROM 0,0 TO 600,800 PIXEL TITLE "Receita.GOV"
	   // oActiveX = TActiveX():New( oWnd, "Shell.Explorer.2" )  // nao funciona no IE
   // nao funciona no IE
   @ 0, 0 ACTIVEX oActiveX PROGID "Shell.Explorer.2" OF oWnd 
	   oWnd:oClient = oActiveX
	   // oActiveX:GoHome()
   oActivex:Silent     := .T.
   oActiveX:FullScreen := .T.
   oActiveX:Visible    := .T.
   oActiveX:ToolBar    := .T.
   oActiveX:StatusBar  := .T.
   oActiveX:MenuBar    := .T.
   oActivex:SetFocus()
	   oActiveX:Do( "Navigate2", "https://www.receita.fazenda.gov.br/PessoaJuridica/CNPJ/cnpjreva/Cnpjreva_Solicitacao2.asp" )
	   oActiveX:bOnEvent = { | event, aParams, pParams | cEvents += EventInfo( event, aParams, pParams, oActiveX ) }
	   ACTIVATE WINDOW oWnd CENTER ;
      VALID ( MemoEdit( cEvents ), .t. )
	   // VALID( oActiveX:End() )
	   // Com ShellExecute funciona perfeito no chrome.
	   /*
   cPortal := "https://www.receita.fazenda.gov.br/PessoaJuridica/CNPJ/cnpjreva/Cnpjreva_Solicitacao2.asp"
	   If !IsInternet()
	      Msgalert("Não conectado a internet.", "Aviso!")
	      Return nil
	   Endif
	   MsgWait( "CONECTANDO AO PORTAL DA SEFAZ...", ;
            "AGUARDE...                      ", 3.0 )
	   // Executa o navegador padrao... Google Chrome nao gosto do IE.
   ShellExecute( GetActiveWindow(), "open", cPortal,,,9 )
   */
	Return nil
	function EventInfo( event, aParams, pParams, oActiveX )
	   local cMsg := "Evento: " + cValToChar( event ) + CRLF
   local n
   
   cMsg += "Params: " + CRLF
   
   for n = 1 to Len( aParams )
      cMsg += cValToChar( aParams[ n ] ) + CRLF
   next
   
   if event == "BeforeNavigate2"
      // MsgInfo( aParams[ 2 ] )
      // SetEventParam( pParams, 7, .t. ) // Comment this to allow navigation
   endif   
	return cMsg + CRLF


 

Link to comment
Share on other sites

Quem manja de java, como seria o Script da Receita Federal tipo assim:

#include "FiveWin.ch"
	static cPais:="",cCiudad:="",cCalle:=""
static oGet1,oGet2,oGet3,oBtn1,oBtn2,nSeg:=0,oWnd
	FUNCTION Mapas()
LOCAL oForm
cPais  :=LEFT("ARGENTINA"+SPACE(255),255)
cCiudad:=LEFT("MERCEDES"+SPACE(255),255)
cCalle :=LEFT("29 575"+SPACE(255),255)
DEFINE DIALOG oForm TITLE "Localizacion Google maps" FROM 05,15 TO 40,95 
  oForm:lHelpIcon := .f.
  @ 07, 05 SAY "Calle:"   OF oForm PIXEL SIZE 50,20 RIGHT
  @ 22, 05 SAY "Ciudad:"  OF oForm PIXEL SIZE 50,20 RIGHT
  @ 37, 05 SAY "Pais:"    OF oForm PIXEL SIZE 50,20 RIGHT
  @ 05, 65 GET oGet1 VAR cCalle  PICTURE "@S30"  OF oForm PIXEL 
  @ 20, 65 GET oGet2 VAR cCiudad PICTURE "@S30"  OF oForm PIXEL
  @ 35, 65 GET oGet3 VAR cPais   PICTURE "@S30"  OF oForm PIXEL
	   @ 45, 00 ACTIVEX oWnd OF oForm PROGID "Shell.Explorer.2"
	  @ 22,105 BUTTON oBtn1 OF oForm ACTION VerMapa(oWnd) PIXEL
	   ACTIVATE DIALOG oForm CENTERED //ON INIT VerMapa(oWnd)
	RETURN nil
	STATIC FUNCTION VerMapa( oActivex)
	   LOCAL cHtml, oWnd
	        cHtml :=[ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ] +CRLF
        cHtml +=[ <html xmlns="http://www.w3.org/1999/xhtml"> ] + CRLF
        cHtml +=[ <head> ]+CRLF
        cHtml +=[<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> ]+CRLF
        cHtml +=[<title> </title> ]+CRLF
        cHtml +=[<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAtOjLpIVcO8im8KJFR8pcMhQjskl1-YgiA_BGX2yRrf7htVrbmBTWZt39_v1rJ4xxwZZCEomegYBo1w" type="text/javascript"></script>]+CRLF
        cHtml +=[<script type="text/javascript">]+CRLF
        cHtml +=[var map = null;]+CRLF
        cHtml +=[var geocoder = null;]+CRLF
        cHtml +=[var coords = null;]+CRLF
        cHtml +=[function initialize() {]+CRLF
        cHtml +=[if (GBrowserIsCompatible()) {]+CRLF
        cHtml +=[map = new GMap2(document.getElementById("map_canvas"));]+CRLF
        cHtml +=[map.addControl(new GLargeMapControl());]+CRLF
        cHtml +=[map.addControl(new GMapTypeControl());]+CRLF
        cHtml +=[map.addControl(new GOverviewMapControl());]+CRLF
        cHtml +=[geocoder = new GClientGeocoder();]+CRLF
        cHtml +=[}]+CRLF
        cHtml +=[}]+CRLF
        cHtml +=[function showAddress(address, cAddressName) {]+CRLF
        cHtml +=[if (geocoder) {]+CRLF
        cHtml +=[geocoder.getLatLng(]+CRLF
        cHtml +=[address,]+CRLF
        cHtml +=[function(point) {]+CRLF
        cHtml +=[if (!point) {]+CRLF
        cHtml +="showAddress2('"+ALLTRIM(cCiudad)+"');"+CRLF
        cHtml +=[} else {                                                      ]+CRLF
        cHtml +=[map.setCenter(point, 15);                                  ]+CRLF
        cHtml +=[var marker = new GMarker(point);                            ]+CRLF
        cHtml +=[map.addOverlay(marker);                                    ]+CRLF
        cHtml +=[coords = marker.getPoint();                                ]+CRLF
        cHtml +=[var curl = cAddressName + "<p>" + coords.toUrlValue(6) + "</p>" ]+CRLF
        cHtml +=[var button = '<input type="button" value="Imprimir" onClick="window.print()"/>;' ]+CRLF
        cHtml +=[curl = curl + button ]+CRLF
        cHtml +=[}                          ]+CRLF                                  
        cHtml +=[}                                ]+CRLF                              
        cHtml +=[);                                     ]+CRLF                           
        cHtml +=[}                                                                  ]+CRLF
        cHtml +=[}                                                                    ]+CRLF
        cHtml +=[function showAddress2(address) {        ]+CRLF
        cHtml +=[if (geocoder) {                               ]+CRLF                     
        cHtml +=[geocoder.getLatLng(                                 ]+CRLF             
        cHtml +=[address,                                                  ]+CRLF      
        cHtml +=[function(point) {                                              ]+CRLF
        cHtml +=[if (!point) {                                                ]+CRLF
        cHtml +=[alert(address + " no encontrado");                          ]+CRLF
        cHtml +=[} else {                                                      ]+CRLF
        cHtml +=[map.setCenter(point, 15);                                  ]+CRLF
        cHtml +=[var marker = new GMarker(point);                            ]+CRLF
        cHtml +=[map.addOverlay(marker);                                    ]+CRLF
        cHtml +=[marker.openInfoWindowHtml(address);                        ]+CRLF
        cHtml +=[}                                                            ]+CRLF
        cHtml +=[}                                                              ]+CRLF
        cHtml +=[);                                                               ]+CRLF
        cHtml +=[}                                                                  ]+CRLF
        cHtml +=[}                                                                    ]+CRLF
        cHtml +=[</script>                                                            ]+CRLF
        cHtml +=[</head>                                                                ]+CRLF
        cHtml +=[<body onload="initialize();]
        cHtml +=" showAddress('"+ALLTRIM(cCalle)+", "+ALLTRIM(cCiudad)+"  "+ALLTRIM(cPais)+"', '"+ALLTRIM(cCalle)+", "+ALLTRIM(cCiudad)+"  "+ALLTRIM(cPais)+"');"
        cHtml +=[" onunload="GUnload()"]+CRLF
        cHtml +=[<div id="map_canvas" style="width: 597px; height: 376px"></div> ]+CRLF
        cHtml +=[</body>                                                               ]+CRLF 
        cHtml +=[</html>]+CRLF
	        MemoWrit("mihtml.htm",chtml)
	
   DEFINE WINDOW oWnd TITLE "FiveWin ActiveX Support"
	   oActiveX = TActiveX():New( oWnd, "Shell.Explorer.2" )
	   oWnd:oClient = oActiveX // To fill the entire window surface
	   oActiveX:Do("Navigate2",(CurDrive() + ":\"+CurDir()+"\MiHtml.htm"))
	   ACTIVATE WINDOW oWnd
	RETURN NIL

Link to comment
Share on other sites

Parametrize seu programa com a versão do seu navegador atual.

Ex: se seu navegador for iexplorer 11 coloque assim

INTER_APP_WEB_CONFIG("SeuPrograma.exe",11001)

FUNCTION INTER_APP_WEB_CONFIG(f_cNameProg,f_nVersion_IE)
Local oRegKey, cRegProgGet, lDeleteKey := .f.
  
  Default f_nVersion_IE := 11001

  if IsWow64() 
    
    oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
         "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" )
    oRegKey:Set(f_cNameProg,f_nVersion_IE,4)
    oRegKey:Close()

    oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
         "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_AJAX_CONNECTIONEVENTS" )
    oRegKey:Set(f_cNameProg,0,4)  // Padrão 0
    oRegKey:Close()

    oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
         "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ZONE_ELEVATION" )
    oRegKey:Set(f_cNameProg,0,4)  // Padrão 1
    oRegKey:Close()

    oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
         "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_READ_ZONE_STRINGS_FROM_REGISTRY" )
    oRegKey:Set(f_cNameProg,1,4)  // Padrão 0
    oRegKey:Close()

    oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
         "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BEHAVIORS" )
    oRegKey:Set(f_cNameProg,1,4)
    oRegKey:Close()

    oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
         "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_WEB_CONTROL_VISUALS" )
    oRegKey:Set(f_cNameProg,1,4)
    oRegKey:Close()

    oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
         "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_SHOW_APP_PROTOCOL_WARN_DIALOG" )
    oRegKey:Set(f_cNameProg,1,4) // Padrao 0
    oRegKey:Close()

    oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
         "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_GPU_RENDERING" )
    oRegKey:Set(f_cNameProg,1,4) // Padrao 0
    oRegKey:Close()

    oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
         "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_NINPUT_LEGACYMODE" )
    oRegKey:Set(f_cNameProg,0,4) // Padrao 1
    oRegKey:Close()


  Else

    oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
         "Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" )
    oRegKey:Set(f_cNameProg,f_nVersion_IE,4)
    oRegKey:Close()

    oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
         "SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BEHAVIORS" )
    cRegProgGet := oRegKey:GetBinary(f_cNameProg)
    //? cRegProgGet
    If Empty(cRegProgGet)
      oRegKey:Set(f_cNameProg,1,4)
    EndIf
    oRegKey:Close()

    oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
         "SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_ENABLE_WEB_CONTROL_VISUALS" )
      oRegKey:Set(f_cNameProg,1,4)
    oRegKey:Close()

  EndIf

RETURN NIL
Link to comment
Share on other sites

Perfect Giovany Vecchi, many thanks!

#include "FiveWin.ch"
	#define  HKEY_LOCAL_MACHINE      2147483650
	STATIC oWnd, oActivex
	FUNCTION Main()
	   LOCAL oBar
	   /*
  http://fivewin.com.br/index.php?/topic/27339-problema-na-busca-do-cnpj-site-da-receita/
	  http://forums.fivetechsupport.com/viewtopic.php?f=6&t=34901
   */
   INTER_APP_WEB_CONFIG("TESTE2.exe",11001)
	   DEFINE WINDOW oWnd TITLE "Google Action"
	   DEFINE BUTTONBAR oBar _3D OF oWnd
	   DEFINE BUTTON OF oBar ACTION Receita( oWnd )
	   SET MESSAGE OF oWnd TO "Google Action" NOINSET CLOCK DATE KEYBOARD
	   ACTIVATE WINDOW oWnd
	RETURN NIL
	Function Receita( oWnd )
	   Local cPortal
   local cEvents := ""
	   If !IsInternet()
	      Msgalert("Não conectado a internet.", "Aviso!")
	      Return nil
	   Endif
	   MsgWait( "CONECTANDO AO PORTAL DA RECEITA ", ;
            "AGUARDE...                      ", 3.0 )
	   DEFINE WINDOW oWnd FROM 0,0 TO 600,800 PIXEL TITLE "Receita.GOV"
	   // oActiveX = TActiveX():New( oWnd, "Shell.Explorer.2" )  // nao funciona no IE
   // nao funciona no IE
   @ 0, 0 ACTIVEX oActiveX PROGID "Shell.Explorer.2" OF oWnd 
	   oWnd:oClient = oActiveX
	   // oActiveX:GoHome()
   oActivex:Silent     := .T.
   oActiveX:FullScreen := .T.
   oActiveX:Visible    := .T.
   oActiveX:ToolBar    := .T.
   oActiveX:StatusBar  := .T.
   oActiveX:MenuBar    := .T.
   oActivex:SetFocus()
	   oActiveX:Do( "Navigate2", "https://www.receita.fazenda.gov.br/PessoaJuridica/CNPJ/cnpjreva/Cnpjreva_Solicitacao2.asp" )
	   oActiveX:bOnEvent = { | event, aParams, pParams | cEvents += EventInfo( event, aParams, pParams, oActiveX ) }
	   ACTIVATE WINDOW oWnd CENTER ;
      VALID ( MemoEdit( cEvents ), .t. )
	   // VALID( oActiveX:End() )
	   // Com ShellExecute funciona perfeito no chrome.
	   /*
   cPortal := "https://www.receita.fazenda.gov.br/PessoaJuridica/CNPJ/cnpjreva/Cnpjreva_Solicitacao2.asp"
	   If !IsInternet()
	      Msgalert("Não conectado a internet.", "Aviso!")
	      Return nil
	   Endif
	   MsgWait( "CONECTANDO AO PORTAL DA SEFAZ...", ;
            "AGUARDE...                      ", 3.0 )
	   // Executa o navegador padrao... Google Chrome nao gosto do IE.
   ShellExecute( GetActiveWindow(), "open", cPortal,,,9 )
   */
	Return nil
	function EventInfo( event, aParams, pParams, oActiveX )
	   local cMsg := "Evento: " + cValToChar( event ) + CRLF
   local n
   
   cMsg += "Params: " + CRLF
   
   for n = 1 to Len( aParams )
      cMsg += cValToChar( aParams[ n ] ) + CRLF
   next
   
   if event == "BeforeNavigate2"
      // MsgInfo( aParams[ 2 ] )
      // SetEventParam( pParams, 7, .t. ) // Comment this to allow navigation
   endif   
	return cMsg + CRLF
	/*
Parametrize seu programa com a versão do seu navegador atual.
	Ex: se seu navegador for iexplorer 11 coloque assim
	INTER_APP_WEB_CONFIG("SeuPrograma.exe",11001)
*/
	FUNCTION INTER_APP_WEB_CONFIG(f_cNameProg,f_nVersion_IE)
	   Local oRegKey, cRegProgGet, lDeleteKey := .f.
  
   Default f_nVersion_IE := 11001
	   if IsWow64()
    
      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" )
      oRegKey:Set(f_cNameProg,f_nVersion_IE,4)
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_AJAX_CONNECTIONEVENTS" )
      oRegKey:Set(f_cNameProg,0,4)  // Padrão 0
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ZONE_ELEVATION" )
      oRegKey:Set(f_cNameProg,0,4)  // Padrão 1
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_READ_ZONE_STRINGS_FROM_REGISTRY" )
      oRegKey:Set(f_cNameProg,1,4)  // Padrão 0
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BEHAVIORS" )
      oRegKey:Set(f_cNameProg,1,4)
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_WEB_CONTROL_VISUALS" )
      oRegKey:Set(f_cNameProg,1,4)
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_SHOW_APP_PROTOCOL_WARN_DIALOG" )
      oRegKey:Set(f_cNameProg,1,4) // Padrao 0
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_GPU_RENDERING" )
      oRegKey:Set(f_cNameProg,1,4) // Padrao 0
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_NINPUT_LEGACYMODE" )
      oRegKey:Set(f_cNameProg,0,4) // Padrao 1
      oRegKey:Close()
	
   Else
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" )
      oRegKey:Set(f_cNameProg,f_nVersion_IE,4)
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BEHAVIORS" )
      cRegProgGet := oRegKey:GetBinary(f_cNameProg)
      //? cRegProgGet
      If Empty(cRegProgGet)
        oRegKey:Set(f_cNameProg,1,4)
      EndIf
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_ENABLE_WEB_CONTROL_VISUALS" )
        oRegKey:Set(f_cNameProg,1,4)
      oRegKey:Close()
	   EndIf
	RETURN NIL

Link to comment
Share on other sites

 

Perfect Giovany Vecchi, many thanks!

 


#include "FiveWin.ch"
	#define  HKEY_LOCAL_MACHINE      2147483650
	STATIC oWnd, oActivex
	FUNCTION Main()
	   LOCAL oBar
	   /*
  http://fivewin.com.br/index.php?/topic/27339-problema-na-busca-do-cnpj-site-da-receita/
	  http://forums.fivetechsupport.com/viewtopic.php?f=6&t=34901
   */
   INTER_APP_WEB_CONFIG("TESTE2.exe",11001)
	   DEFINE WINDOW oWnd TITLE "Google Action"
	   DEFINE BUTTONBAR oBar _3D OF oWnd
	   DEFINE BUTTON OF oBar ACTION Receita( oWnd )
	   SET MESSAGE OF oWnd TO "Google Action" NOINSET CLOCK DATE KEYBOARD
	   ACTIVATE WINDOW oWnd
	RETURN NIL
	Function Receita( oWnd )
	   Local cPortal
   local cEvents := ""
	   If !IsInternet()
	      Msgalert("Não conectado a internet.", "Aviso!")
	      Return nil
	   Endif
	   MsgWait( "CONECTANDO AO PORTAL DA RECEITA ", ;
            "AGUARDE...                      ", 3.0 )
	   DEFINE WINDOW oWnd FROM 0,0 TO 600,800 PIXEL TITLE "Receita.GOV"
	   // oActiveX = TActiveX():New( oWnd, "Shell.Explorer.2" )  // nao funciona no IE
   // nao funciona no IE
   @ 0, 0 ACTIVEX oActiveX PROGID "Shell.Explorer.2" OF oWnd 
	   oWnd:oClient = oActiveX
	   // oActiveX:GoHome()
   oActivex:Silent     := .T.
   oActiveX:FullScreen := .T.
   oActiveX:Visible    := .T.
   oActiveX:ToolBar    := .T.
   oActiveX:StatusBar  := .T.
   oActiveX:MenuBar    := .T.
   oActivex:SetFocus()
	   oActiveX:Do( "Navigate2", "https://www.receita.fazenda.gov.br/PessoaJuridica/CNPJ/cnpjreva/Cnpjreva_Solicitacao2.asp" )
	   oActiveX:bOnEvent = { | event, aParams, pParams | cEvents += EventInfo( event, aParams, pParams, oActiveX ) }
	   ACTIVATE WINDOW oWnd CENTER ;
      VALID ( MemoEdit( cEvents ), .t. )
	   // VALID( oActiveX:End() )
	   // Com ShellExecute funciona perfeito no chrome.
	   /*
   cPortal := "https://www.receita.fazenda.gov.br/PessoaJuridica/CNPJ/cnpjreva/Cnpjreva_Solicitacao2.asp"
	   If !IsInternet()
	      Msgalert("Não conectado a internet.", "Aviso!")
	      Return nil
	   Endif
	   MsgWait( "CONECTANDO AO PORTAL DA SEFAZ...", ;
            "AGUARDE...                      ", 3.0 )
	   // Executa o navegador padrao... Google Chrome nao gosto do IE.
   ShellExecute( GetActiveWindow(), "open", cPortal,,,9 )
   */
	Return nil
	function EventInfo( event, aParams, pParams, oActiveX )
	   local cMsg := "Evento: " + cValToChar( event ) + CRLF
   local n
   
   cMsg += "Params: " + CRLF
   
   for n = 1 to Len( aParams )
      cMsg += cValToChar( aParams[ n ] ) + CRLF
   next
   
   if event == "BeforeNavigate2"
      // MsgInfo( aParams[ 2 ] )
      // SetEventParam( pParams, 7, .t. ) // Comment this to allow navigation
   endif   
	return cMsg + CRLF
	/*
Parametrize seu programa com a versão do seu navegador atual.
	Ex: se seu navegador for iexplorer 11 coloque assim
	INTER_APP_WEB_CONFIG("SeuPrograma.exe",11001)
*/
	FUNCTION INTER_APP_WEB_CONFIG(f_cNameProg,f_nVersion_IE)
	   Local oRegKey, cRegProgGet, lDeleteKey := .f.
  
   Default f_nVersion_IE := 11001
	   if IsWow64()
    
      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" )
      oRegKey:Set(f_cNameProg,f_nVersion_IE,4)
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_AJAX_CONNECTIONEVENTS" )
      oRegKey:Set(f_cNameProg,0,4)  // Padrão 0
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ZONE_ELEVATION" )
      oRegKey:Set(f_cNameProg,0,4)  // Padrão 1
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_READ_ZONE_STRINGS_FROM_REGISTRY" )
      oRegKey:Set(f_cNameProg,1,4)  // Padrão 0
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BEHAVIORS" )
      oRegKey:Set(f_cNameProg,1,4)
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_WEB_CONTROL_VISUALS" )
      oRegKey:Set(f_cNameProg,1,4)
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_SHOW_APP_PROTOCOL_WARN_DIALOG" )
      oRegKey:Set(f_cNameProg,1,4) // Padrao 0
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_GPU_RENDERING" )
      oRegKey:Set(f_cNameProg,1,4) // Padrao 0
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_NINPUT_LEGACYMODE" )
      oRegKey:Set(f_cNameProg,0,4) // Padrao 1
      oRegKey:Close()
	
   Else
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" )
      oRegKey:Set(f_cNameProg,f_nVersion_IE,4)
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BEHAVIORS" )
      cRegProgGet := oRegKey:GetBinary(f_cNameProg)
      //? cRegProgGet
      If Empty(cRegProgGet)
        oRegKey:Set(f_cNameProg,1,4)
      EndIf
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_ENABLE_WEB_CONTROL_VISUALS" )
        oRegKey:Set(f_cNameProg,1,4)
      oRegKey:Close()
	   EndIf
	RETURN NIL

 

Era isso ai, faltava fazer essa rotina antes

Link to comment
Share on other sites

E tem outra

Depois de muitas pesquisas (uma atras da outra) o capcha começa a pedir muitas tarefas, tipo assim: marque os carros, marque as vias, marque as placas etc etc. 

Então aconselho depois de umas 5 consultas chamar esta função para apagar os cockies e data caches

WaitRun("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351")
 

E esta solução voces só vão achar aqui no nosso forum > (Nós somos melhores) kkkkkkkk

Link to comment
Share on other sites

Very good Giovany Vecchi

#include "FiveWin.ch"
	#define  HKEY_LOCAL_MACHINE      2147483650
	STATIC oWnd, oActivex
	FUNCTION Main()
	   LOCAL oBar
	   /*
  http://fivewin.com.br/index.php?/topic/27339-problema-na-busca-do-cnpj-site-da-receita/
	  http://forums.fivetechsupport.com/viewtopic.php?f=6&t=34901
   */
   INTER_APP_WEB_CONFIG("IEBROWSE.exe",11001)
	   DEFINE WINDOW oWnd TITLE "Google Action"
	   DEFINE BUTTONBAR oBar _3D OF oWnd
	   DEFINE BUTTON OF oBar ACTION Receita( oWnd )
	   SET MESSAGE OF oWnd TO "Google Action" NOINSET CLOCK DATE KEYBOARD
	   ACTIVATE WINDOW oWnd
	
   /*
	   giovany vecchi:
	   E tem outra
	   Depois de muitas pesquisas (uma atras da outra) o capcha começa a pedir muitas tarefas, tipo assim: marque os carros, marque as vias, marque as placas etc etc.
	   Então aconselho depois de umas 5 consultas chamar esta função para apagar os cockies e data caches
   */
	   // Remove o Historico de Navegacao...
   WaitRun("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351")
	   // E esta solução voces só vão achar aqui no nosso forum > (Nós somos melhores) kkkkkkkk
	RETURN NIL
	Function Receita( oWnd )
	   Local cPortal
   local cEvents := ""
	   If !IsInternet()
	      Msgalert("Não conectado a internet.", "Aviso!")
	      Return nil
	   Endif
	   MsgWait( "CONECTANDO AO PORTAL DA RECEITA ", ;
            "AGUARDE...                      ", 3.0 )
	   DEFINE WINDOW oWnd FROM 0,0 TO 600,800 PIXEL TITLE "Receita.GOV"
	   // oActiveX = TActiveX():New( oWnd, "Shell.Explorer.2" )  // nao funciona no IE
   // nao funciona no IE
   @ 0, 0 ACTIVEX oActiveX PROGID "Shell.Explorer.2" OF oWnd 
	   oWnd:oClient = oActiveX
	   // oActiveX:GoHome()
   oActivex:Silent     := .T.
   oActiveX:FullScreen := .T.
   oActiveX:Visible    := .T.
   oActiveX:ToolBar    := .T.
   oActiveX:StatusBar  := .T.
   oActiveX:MenuBar    := .T.
   oActivex:SetFocus()
	   oActiveX:Do( "Navigate2", "https://www.receita.fazenda.gov.br/PessoaJuridica/CNPJ/cnpjreva/Cnpjreva_Solicitacao2.asp" )
	   oActiveX:bOnEvent = { | event, aParams, pParams | cEvents += EventInfo( event, aParams, pParams, oActiveX ) }
	   ACTIVATE WINDOW oWnd CENTER ;
      VALID ( MemoEdit( cEvents ), .t. )
	   // VALID( oActiveX:End() )
	   // Com ShellExecute funciona perfeito no chrome.
	   /*
   cPortal := "https://www.receita.fazenda.gov.br/PessoaJuridica/CNPJ/cnpjreva/Cnpjreva_Solicitacao2.asp"
	   If !IsInternet()
	      Msgalert("Não conectado a internet.", "Aviso!")
	      Return nil
	   Endif
	   MsgWait( "CONECTANDO AO PORTAL DA SEFAZ...", ;
            "AGUARDE...                      ", 3.0 )
	   // Executa o navegador padrao... Google Chrome nao gosto do IE.
   ShellExecute( GetActiveWindow(), "open", cPortal,,,9 )
   */
	Return nil
	function EventInfo( event, aParams, pParams, oActiveX )
	   local cMsg := "Evento: " + cValToChar( event ) + CRLF
   local n
   
   cMsg += "Params: " + CRLF
   
   for n = 1 to Len( aParams )
      cMsg += cValToChar( aParams[ n ] ) + CRLF
   next
   
   if event == "BeforeNavigate2"
      // MsgInfo( aParams[ 2 ] )
      // SetEventParam( pParams, 7, .t. ) // Comment this to allow navigation
   endif   
	return cMsg + CRLF
	/*
Parametrize seu programa com a versão do seu navegador atual.
	Ex: se seu navegador for iexplorer 11 coloque assim
	INTER_APP_WEB_CONFIG("SeuPrograma.exe",11001)
*/
	FUNCTION INTER_APP_WEB_CONFIG(f_cNameProg,f_nVersion_IE)
	   Local oRegKey, cRegProgGet, lDeleteKey := .f.
  
   Default f_nVersion_IE := 11001
	   if IsWow64()
    
      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" )
      oRegKey:Set(f_cNameProg,f_nVersion_IE,4)
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_AJAX_CONNECTIONEVENTS" )
      oRegKey:Set(f_cNameProg,0,4)  // Padrão 0
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ZONE_ELEVATION" )
      oRegKey:Set(f_cNameProg,0,4)  // Padrão 1
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_READ_ZONE_STRINGS_FROM_REGISTRY" )
      oRegKey:Set(f_cNameProg,1,4)  // Padrão 0
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BEHAVIORS" )
      oRegKey:Set(f_cNameProg,1,4)
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_WEB_CONTROL_VISUALS" )
      oRegKey:Set(f_cNameProg,1,4)
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_SHOW_APP_PROTOCOL_WARN_DIALOG" )
      oRegKey:Set(f_cNameProg,1,4) // Padrao 0
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_GPU_RENDERING" )
      oRegKey:Set(f_cNameProg,1,4) // Padrao 0
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_NINPUT_LEGACYMODE" )
      oRegKey:Set(f_cNameProg,0,4) // Padrao 1
      oRegKey:Close()
	
   Else
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" )
      oRegKey:Set(f_cNameProg,f_nVersion_IE,4)
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BEHAVIORS" )
      cRegProgGet := oRegKey:GetBinary(f_cNameProg)
      //? cRegProgGet
      If Empty(cRegProgGet)
        oRegKey:Set(f_cNameProg,1,4)
      EndIf
      oRegKey:Close()
	      oRegKey := TReg32():New( HKEY_LOCAL_MACHINE,;
           "SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_ENABLE_WEB_CONTROL_VISUALS" )
        oRegKey:Set(f_cNameProg,1,4)
      oRegKey:Close()
	   EndIf
	RETURN NIL


 

Link to comment
Share on other sites

Add/Remove Programs
RunDll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,0
	Clear Internet Explorer Title
RUNDLL32.EXE IEdkcs32.dll,Clear
	Content Advisor
RunDll32.exe msrating.dll,RatingSetupUI
	Control Panel
RunDll32.exe shell32.dll,Control_RunDLL
	Delete Temporary Internet Files:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
	Delete Cookies:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2
	Delete History:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1
	Delete Form Data:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16
	Delete Passwords:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32
	Delete All:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
	Delete All + files and settings stored by Add-ons:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351
	Date and Time Properties
RunDll32.exe shell32.dll,Control_RunDLL timedate.cpl
	Display Settings - Windows XP
RunDll32.exe shell32.dll,Control_RunDLL access.cpl,,3
	Display Appearance Settings - Vista
RunDll32.exe shell32.dll,Control_RunDLL desk.cpl,,2
	Display, Screen Saver Settings - Vista
RunDll32.exe shell32.dll,Control_RunDLL desk.cpl,,1
	Display, Monitor Settings - Vista
RunDll32.exe shell32.dll,Control_RunDLL desk.cpl,,
	Display, Desktop Icon Settings - Vista
RunDll32.exe shell32.dll,Control_RunDLL desk.cpl,,0
	Device Manager
RunDll32.exe devmgr.dll DeviceManager_Execute
	Folder Options - General
RunDll32.exe shell32.dll,Options_RunDLL 0
	Folder Options - File Types
RunDll32.exe shell32.dll,Control_Options 2
	Folder Options - Search
RunDll32.exe shell32.dll,Options_RunDLL 2
	Folder Options - View
RunDll32.exe shell32.dll,Options_RunDLL 7
	Forgotten Password Wizard
RunDll32.exe keymgr.dll,PRShowSaveWizardExW
	Vista Flip 3D
RunDll32.exe DwmApi #105
	Hibernate
RunDll32.exe powrprof.dll,SetSuspendState
	Internet Explorer's Internet Properties dialog box
Rundll32 Shell32.dll,ConBring up trol_RunDLL Inetcpl.cpl,,6
	Keyboard Properties
RunDll32.exe shell32.dll,Control_RunDLL main.cpl @1
	Lock Screen
RunDll32.exe user32.dll,LockWorkStation
	Mouse Button - Swap left button to function as right
Rundll32 User32.dll,SwapMouseButton (Para resolver, usar: RUNDLL32.EXE SHELL32.dll,Control_RunDLL main.cpl @0,0)
	Mouse Properties Dialog Box
Rundll32 Shell32.dll,Control_RunDLL main.cpl @0,0
	Map Network Drive Wizard
Rundll32 Shell32.dll,SHHelpShortcuts_RunDLL Connect
	Network Connections
RunDll32.exe shell32.dll,Control_RunDLL ncpa.cpl
	Organize IE Favorites
Rundll32.exe shdocvw.dll,DoOrganizeFavDlg
	Open With Dialog Box
Rundll32 Shell32.dll,OpenAs_RunDLL Any_File-name.ext
	Printer User Interface
Rundll32 Printui.dll,PrintUIEntry /?
	Printer Management Folder
Rundll32 Shell32.dll,SHHelpShortcuts_RunDLL PrintersFolder
	Power Options
RunDll32.exe Shell32.dll,Control_RunDLL powercfg.cpl
	Process Idle Tasks
rundll32.exe advapi32.dll,ProcessIdleTasks
	Regional and Language Options
Rundll32 Shell32.dll,Control_RunDLL Intl.cpl,,0
	Stored Usernames and Passwords
RunDll32.exe keymgr.dll,KRShowKeyMgr
	Safely Remove Hardware Dialog Box
Rundll32 Shell32.dll,Control_RunDLL HotPlug.dll
	Sound Properties Dialog Box
Rundll32 Shell32.dll,Control_RunDLL Mmsys.cpl,,0
	System Properties Box
Rundll32 Shell32.dll,Control_RunDLL Sysdm.cpl,,3
	System Properties - Advanced
RunDll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,4
	System Properties: Automatic Updates
RunDll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,5
	System Properties, Computer Name Tab
RunDll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,1
	System Properties, Hardware Tab
RunDll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,2 
	System Properties, Advanced Tab
RunDll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,3 
	System Properties, System Protection Tab
RunDll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,4
	System Properties, Remote Tab
RunDll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,5
	System Properties, Performance, Visual Effects
RunDll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,-1
	Taskbar Properties
RunDll32.exe shell32.dll,Options_RunDLL 1
	User Accounts
RunDll32.exe shell32.dll,Control_RunDLL nusrmgr.cpl
	Unplug/Eject Hardware
RunDll32.exe shell32.dll,Control_RunDLL hotplug.dll
	Windows Security Center
RunDll32.exe shell32.dll,Control_RunDLL wscui.cpl
	Windows - About
RunDll32.exe SHELL32.DLL,ShellAboutW
	Windows Fonts Installation Folder
Rundll32 Shell32.dll,SHHelpShortcuts_RunDLL FontsFolder
	Windows Firewall
RunDll32.exe shell32.dll,Control_RunDLL firewall.cpl
	Wireless Network Setup
RunDll32.exe shell32.dll,Control_RunDLL NetSetup.cpl,@0,WNSW


 

Link to comment
Share on other sites

Pessoal, pegar os dados da receita federal não é tão útil quanto do site do Sintegra, pois no site do Sintegra, vc pega mais informações como inscrição estadual e o tipo da empresa, se é simples nacional ou não

Alguém conseguiu desenvolver para busca os dados da empresa pelo Sintegra?

 

Link to comment
Share on other sites

 

Pessoal, pegar os dados da receita federal não é tão útil quanto do site do Sintegra, pois no site do Sintegra, vc pega mais informações como inscrição estadual e o tipo da empresa, se é simples nacional ou não

Alguém conseguiu desenvolver para busca os dados da empresa pelo Sintegra?

 

Pelo Sintegra, somente informações de contribuintes e de âmbito estadual.

[]s,

Link to comment
Share on other sites

Para pegar os dados de uma pessoa juridica, uso a rotina abaixo:


FUNCTION PEGA_CNPJ(CPF_C,OG02_C,FAN_C,OG04_C,NE_C,OG05_C,CE_C,OG06_C,EN_C,OG07_C,NU_C,OG08_C,CPL_C,OG09_C,BA_C,OG10_C,CD_C,OG11_C,UF_C,OG12_C,DTN_C,OG17_C,TEL_C,OG22_C,EM_C,OG15_C)
Local oServerWS, cUrl, aArray, oCnpj:= TIRA(CPF_C,"Z")
IF LEN(oCnpj)#14
   MSGINFO("Este botão só busca dados de pessoal jurídica!")
   return .t.
endif
     cUrl:= "https://www.receitaws.com.br/v1/cnpj/"+Alltrim(oCnpj) 

     Try
        oServerWS := CreateObject( 'MSXML2.ServerXMLHTTP.5.0' )  
     Catch oError
        try
          oServerWS := CreateObject( 'MSXML2.ServerXMLHTTP.6.0' )  
        catch oError
          try
             oServerWS := CreateObject("Microsoft.XMLHTTP")
          catch oError
             ? e:Description
             return nil
          end
        END
     end
     TRY
        oServerWS:open('GET', cUrl, .f.)
        oServerWS:setRequestHeader('Content-Type'    , 'text/xml; charset=utf-8')    // Obtém ou define o valor de cabeçalho de Content-type HTTP. 
        oServerWS:send()    
     CATCH
        ? "Não conseguiu enviar solicitação para requisição dos dados do CNPJ"
        return .t.
     END
     
     * Verifica o status do request. Exibe erro se houver
     IF oServerWS:Status != 200 // OK
        MsgStop( Alltrim(STR(oServerWS:Status)) +" - "+ oServerWS:StatusText , "Erro")
        RETURN NIL
     ENDIF
     
     WHILE oServerWS:readyState != 4
        oServerWS:waitForResponse(1000)
     END   
         
     * decodifica o arquivo json e transforma em um array multidimensional
**    x :=  hb_jsondecode( oServerWS:responseText, @aArray )

     txt:=  oServerWS:responseText
     
   
Arq_1:=ALLTRIM(txt)

ARR0:=HB_ATokens( Arq_1, CHR(10) )
TAB:={}
QT:=0
n_f1:=""
n_f2:=""
FOR I=1 TO LEN(ARR0)
    I0:=CHR(34)+"nome"+chr(34)
    IF I0$ARR0
       IF QT=0
          QT:=QT+1
          I0:=ARR0
          I0:=StrTran( I0, "nome" ) 
          I0:=StrTran( I0, ":" ) 
          I0:=StrTran( I0, "," ) 
          I0:=StrTran( I0, ";" ) 
          I0:=StrTran( I0, CHR(34) ) 
          if len(alltrim(I0))>0
             OG04_C:refresh()
             NE_C:=alltrim(I0)
             n_f2:=alltrim(I0)
             OG04_C:refresh()
          endif
       ENDIF
    ENDIF
    I0:=CHR(34)+"uf"+chr(34)
    IF I0$ARR0
          I0:=ARR0
          I0:=StrTran( I0, "uf" ) 
          I0:=StrTran( I0, ":" ) 
          I0:=StrTran( I0, "," ) 
          I0:=StrTran( I0, ";" ) 
          I0:=StrTran( I0, CHR(34) ) 
          if len(alltrim(I0))>0
             UF_C:=alltrim(I0)
             OG11_C:refresh()
          endif
    ENDIF
    I0:=CHR(34)+"logradouro"+chr(34)
    IF I0$ARR0
          I0:=ARR0
          I0:=StrTran( I0, "logradouro" ) 
          I0:=StrTran( I0, ":" ) 
          I0:=StrTran( I0, "," ) 
          I0:=StrTran( I0, ";" ) 
          I0:=StrTran( I0, CHR(34) ) 
          if len(alltrim(I0))>0
             EN_C:=alltrim(I0)             
             OG06_C:REFRESH()
          endif
    ENDIF
    I0:=CHR(34)+"numero"+chr(34)
    IF I0$ARR0
          I0:=ARR0
          I0:=StrTran( I0, "numero" ) 
          I0:=StrTran( I0, ":" ) 
          I0:=StrTran( I0, "," ) 
          I0:=StrTran( I0, ";" ) 
          I0:=StrTran( I0, CHR(34) ) 
          if len(alltrim(I0))>0
             NU_C:=alltrim(I0)             
             OG07_C:REFRESH()
          endif
    ENDIF
    I0:=CHR(34)+"cep"+chr(34)
    IF I0$ARR0
          I0:=ARR0
          I0:=StrTran( I0, "cep" ) 
          I0:=StrTran( I0, ":" ) 
          I0:=StrTran( I0, "," ) 
          I0:=StrTran( I0, ";" ) 
          I0:=StrTran( I0, CHR(34) ) 
          if len(alltrim(I0))>0
             CE_C:=transform(alltrim(tira(I0,"Z")),"@R 99999-999")
             OG05_C:REFRESH()
          endif
    ENDIF
    I0:=CHR(34)+"municipio"+chr(34)
    IF I0$ARR0
          I0:=ARR0
          I0:=StrTran( I0, "municipio" ) 
          I0:=StrTran( I0, ":" ) 
          I0:=StrTran( I0, "," ) 
          I0:=StrTran( I0, ";" ) 
          I0:=StrTran( I0, CHR(34) ) 
          if len(alltrim(I0))>0
             CD_C:=alltrim(I0)
             OG10_C:REFRESH()
          endif
    ENDIF
    I0:=CHR(34)+"abertura"+chr(34)
    IF I0$ARR0
          I0:=ARR0
          I0:=StrTran( I0, "abertura" ) 
          I0:=StrTran( I0, ":" ) 
          I0:=StrTran( I0, "," ) 
          I0:=StrTran( I0, ";" ) 
          I0:=StrTran( I0, CHR(34) ) 
          if len(alltrim(I0))>0
             DTN_C:=CTOD(alltrim(I0))
             OG12_C:REFRESH()
          endif
    ENDIF
    I0:=CHR(34)+"bairro"+chr(34)
    IF I0$ARR0
          I0:=ARR0
          I0:=StrTran( I0, "bairro" ) 
          I0:=StrTran( I0, ":" ) 
          I0:=StrTran( I0, "," ) 
          I0:=StrTran( I0, ";" ) 
          I0:=StrTran( I0, CHR(34) ) 
          if len(alltrim(I0))>0
             BA_C:=alltrim(I0)
             OG09_C:REFRESH()
          endif
    ENDIF
    I0:=CHR(34)+"complemento"+chr(34)
    IF I0$ARR0
          I0:=ARR0
          I0:=StrTran( I0, "complemento" ) 
          I0:=StrTran( I0, ":" ) 
          I0:=StrTran( I0, "," ) 
          I0:=StrTran( I0, ";" ) 
          I0:=StrTran( I0, CHR(34) ) 
          if len(alltrim(I0))>0
             CPL_C:=alltrim(I0)
             OG08_C:REFRESH()
          endif
    ENDIF
    I0:=CHR(34)+"email"+chr(34)
    IF I0$ARR0
          I0:=ARR0
          I0:=StrTran( I0, "email" ) 
          I0:=StrTran( I0, ":" ) 
          I0:=StrTran( I0, "," ) 
          I0:=StrTran( I0, ";" ) 
          I0:=StrTran( I0, CHR(34) ) 
          if len(alltrim(I0))>0
             EM_C:=alltrim(I0)
             OG22_C:REFRESH()
          endif
    ENDIF
    I0:=CHR(34)+"telefone"+chr(34)
    IF I0$ARR0
          I0:=ARR0
          I0:=StrTran( I0, "telefone" ) 
          I0:=StrTran( I0, ":" ) 
          I0:=StrTran( I0, "," ) 
          I0:=StrTran( I0, ";" ) 
          I0:=StrTran( I0, CHR(34) ) 
          if len(alltrim(I0))>0
             TEL_C:=alltrim(I0)
             IF AT("/",TEL_C)>0
                TEL_C:=ALLTRIM(LEFT(TEL_C,AT("/",TEL_C)-1))
             ENDIF
             OG17_C:REFRESH()
          endif
    ENDIF
    I0:=CHR(34)+"fantasia"+chr(34)
    IF I0$ARR0
          I0:=ARR0
          I0:=StrTran( I0, "fantasia" ) 
          I0:=StrTran( I0, ":" ) 
          I0:=StrTran( I0, "," ) 
          I0:=StrTran( I0, ";" ) 
          I0:=StrTran( I0, CHR(34) ) 
          if len(alltrim(I0))>0
             FAN_C:=alltrim(I0)
             n_f1:=alltrim(I0)
             OG02_C:REFRESH()
          endif
    ENDIF
    
NEXT
if len(n_f1)=0
   FAN_C:=n_f2
   OG02_C:REFRESH()
endif   
XSETFOCUS(OG15_C)
RETURN .T.
 

Link to comment
Share on other sites

  • 3 months later...
  • 1 month later...

mkyx, é possível postar a funcção: TIRA()?     Obg. Abs.


#include "FiveWin.ch"
	static oWnd
	//----------------------------------------------------------------//
	function Main()
	   local oBar, nCnpj
	   nCnpj := "48209381000140"
	   DEFINE WINDOW oWnd TITLE "Busca Cnpj"
	   DEFINE BUTTONBAR oBar _3D OF oWnd
	   DEFINE BUTTON OF oBar ACTION PEGA_CNPJ( nCnpj )
	   SET MESSAGE OF oWnd TO "Busca Cnpj" NOINSET CLOCK DATE KEYBOARD
	   ACTIVATE WINDOW oWnd
	return nil
	// Para pegar os dados de uma pessoa juridica, uso a rotina abaixo:
	// FUNCTION PEGA_CNPJ( CPF_C, OG02_C, FAN_C, OG04_C, NE_C, OG05_C, CE_C, OG06_C, EN_C, OG07_C, NU_C, OG08_C, CPL_C, OG09_C, BA_C, OG10_C, CD_C, OG11_C, UF_C, OG12_C, DTN_C, OG17_C, TEL_C, OG22_C, EM_C, OG15_C )
FUNCTION PEGA_CNPJ( oCnpj )
	   LOCAL oServerWS, cUrl, aArray // , oCnpj := TIRA( CPF_C, "Z" )
	   IF LEN( oCnpj ) # 14
      MSGINFO( "Este botão só busca dados de pessoal jurídica!" )
      RETURN .T.
   ENDIF
	   cUrl := "https://www.receitaws.com.br/v1/cnpj/" + Alltrim( oCnpj )
	   Try
      oServerWS := CreateObject( 'MSXML2.ServerXMLHTTP.5.0' )
   Catch oError
      try
         oServerWS := CreateObject( 'MSXML2.ServerXMLHTTP.6.0' )
      catch oError
         try
            oServerWS := CreateObject( "Microsoft.XMLHTTP" )
         catch oError
            ? e:Description
            RETURN nil
         end
      END
   end
	   TRY
      oServerWS:open( 'GET', cUrl, .F. )
      oServerWS:setRequestHeader( 'Content-Type'    , 'text/xml; charset=utf-8' )    // Obtém ou define o valor de cabeçalho de Content-type HTTP.
      oServerWS:send()
   CATCH
      ? "Não conseguiu enviar solicitação para requisição dos dados do CNPJ"
      RETURN .T.
   END
     
   // Verifica o status do request. Exibe erro se houver
   IF oServerWS:Status != 200 // OK
      MsgStop( Alltrim( STR(oServerWS:Status ) ) + " - " + oServerWS:StatusText , "Erro" )
      RETURN NIL
   ENDIF
     
   WHILE oServerWS:readyState != 4
      oServerWS:waitForResponse( 1000 )
   END
         
   // decodifica o arquivo json e transforma em um array multidimensional
   //*    x :=  hb_jsondecode( oServerWS:responseText, @aArray )
	   txt :=  oServerWS:responseText
   
   Arq_1 := ALLTRIM( txt )
	   ARR0 := HB_ATokens( Arq_1, CHR( 10 ) )
	   TAB := {}
	   QT := 0
   n_f1 := ""
   n_f2 := ""
	   FOR I = 1 TO LEN( ARR0 )
	      I0 := CHR( 34 ) + "nome" + chr( 34 )
	      IF I0 $ ARR0
	         IF QT = 0
	            QT := QT + 1
            I0 := ARR0
            I0 := StrTran( I0, "nome" )
            I0 := StrTran( I0, ":" )
            I0 := StrTran( I0, "," )
            I0 := StrTran( I0, ";" )
            I0 := StrTran( I0, CHR( 34 ) )
	            IF len( alltrim( I0 ) ) > 0
	               OG04_C:refresh()
               NE_C := alltrim( I0 )
               n_f2 := alltrim( I0 )
               OG04_C:refresh()
	            ENDIF
	         ENDIF
	      ENDIF
	      I0 := CHR( 34 ) + "uf" + chr( 34 )
	      IF I0 $ ARR0
	         I0 := ARR0
         I0 := StrTran( I0, "uf" )
         I0 := StrTran( I0, ":" )
         I0 := StrTran( I0, "," )
         I0 := StrTran( I0, ";" )
         I0 := StrTran( I0, CHR( 34 ) )
	         IF len( alltrim( I0 ) ) > 0
            UF_C := alltrim( I0 )
            OG11_C:refresh()
         ENDIF
	      ENDIF
	      I0 := CHR( 34 ) + "logradouro" + chr( 34 )
	      IF I0 $ ARR0
	         I0 := ARR0
         I0 := StrTran( I0, "logradouro" )
         I0 := StrTran( I0, ":" )
         I0 := StrTran( I0, "," )
         I0 := StrTran( I0, ";" )
         I0 := StrTran( I0, CHR( 34 ) )
	         IF len( alltrim( I0 ) ) > 0
	            EN_C := alltrim( I0 )
            OG06_C:REFRESH()
	         ENDIF
	      ENDIF
	      I0 := CHR( 34 ) + "numero" + chr( 34 )
	      IF I0 $ ARR0
	         I0 := ARR0
         I0 := StrTran( I0, "numero" )
         I0 := StrTran( I0, ":" )
         I0 := StrTran( I0, "," )
         I0 := StrTran( I0, ";" )
         I0 := StrTran( I0, CHR( 34 ) )
	         IF len( alltrim( I0 ) ) > 0
	            NU_C := alltrim( I0 )
            OG07_C:REFRESH()
	         ENDIF
	      ENDIF
	      I0 := CHR( 34 ) + "cep" + chr( 34 )
	      IF I0 $ ARR0
	         I0 := ARR0
         I0 := StrTran( I0, "cep" )
         I0 := StrTran( I0, ":" )
         I0 := StrTran( I0, "," )
         I0 := StrTran( I0, ";" )
         I0 := StrTran( I0, CHR( 34 ) )
	         IF len( alltrim( I0 ) ) > 0
	            // CE_C := transform( alltrim( tira(I0,"Z" ) ), "@R 99999-999" )
	            // OG05_C:REFRESH()
	         ENDIF
	      ENDIF
	      I0 := CHR( 34 ) + "municipio" + chr( 34 )
	      IF I0 $ ARR0
	         I0 := ARR0
         I0 := StrTran( I0, "municipio" )
         I0 := StrTran( I0, ":" )
         I0 := StrTran( I0, "," )
         I0 := StrTran( I0, ";" )
         I0 := StrTran( I0, CHR( 34 ) )
	         IF len( alltrim( I0 ) ) > 0
	            CD_C := alltrim( I0 )
            OG10_C:REFRESH()
	         ENDIF
	      ENDIF
	      I0 := CHR( 34 ) + "abertura" + chr( 34 )
	      IF I0 $ ARR0
	         I0 := ARR0
         I0 := StrTran( I0, "abertura" )
         I0 := StrTran( I0, ":" )
         I0 := StrTran( I0, "," )
         I0 := StrTran( I0, ";" )
         I0 := StrTran( I0, CHR( 34 ) )
	         IF len( alltrim( I0 ) ) > 0
	            DTN_C := CTOD( alltrim( I0 ) )
            OG12_C:REFRESH()
	         ENDIF
	      ENDIF
	      I0 := CHR( 34 ) + "bairro" + chr( 34 )
	      IF I0 $ ARR0
	         I0 := ARR0
         I0 := StrTran( I0, "bairro" )
         I0 := StrTran( I0, ":" )
         I0 := StrTran( I0, "," )
         I0 := StrTran( I0, ";" )
         I0 := StrTran( I0, CHR( 34 ) )
	         IF len( alltrim( I0 ) ) > 0
	            BA_C := alltrim( I0 )
            OG09_C:REFRESH()
	         ENDIF
	      ENDIF
	      I0 := CHR( 34 ) + "complemento" + chr( 34 )
	      IF I0 $ ARR0
	         I0 := ARR0
         I0 := StrTran( I0, "complemento" )
         I0 := StrTran( I0, ":" )
         I0 := StrTran( I0, "," )
         I0 := StrTran( I0, ";" )
         I0 := StrTran( I0, CHR( 34 ) )
	         IF len( alltrim( I0 ) ) > 0
            CPL_C := alltrim( I0 )
            OG08_C:REFRESH()
         ENDIF
	      ENDIF
	      I0 := CHR( 34 ) + "email" + chr( 34 )
	      IF I0 $ ARR0
         I0 := ARR0
         I0 := StrTran( I0, "email" )
         I0 := StrTran( I0, ":" )
         I0 := StrTran( I0, "," )
         I0 := StrTran( I0, ";" )
         I0 := StrTran( I0, CHR( 34 ) )
	         IF len( alltrim( I0 ) ) > 0
            EM_C := alltrim( I0 )
            OG22_C:REFRESH()
         ENDIF
	      ENDIF
	      I0 := CHR( 34 ) + "telefone" + chr( 34 )
	      IF I0 $ ARR0
	         I0 := ARR0
         I0 := StrTran( I0, "telefone" )
         I0 := StrTran( I0, ":" )
         I0 := StrTran( I0, "," )
         I0 := StrTran( I0, ";" )
         I0 := StrTran( I0, CHR( 34 ) )
	         IF len( alltrim( I0 ) ) > 0
	            TEL_C := alltrim( I0 )
	            IF AT( "/", TEL_C ) > 0
               TEL_C := ALLTRIM( LEFT( TEL_C,AT("/",TEL_C ) - 1 ) )
            ENDIF
	            OG17_C:REFRESH()
	         ENDIF
	      ENDIF
	      I0 := CHR( 34 ) + "fantasia" + chr( 34 )
	      IF I0 $ ARR0
	         I0 := ARR0
         I0 := StrTran( I0, "fantasia" )
         I0 := StrTran( I0, ":" )
         I0 := StrTran( I0, "," )
         I0 := StrTran( I0, ";" )
         I0 := StrTran( I0, CHR( 34 ) )
	         IF len( alltrim( I0 ) ) > 0
	            FAN_C := alltrim( I0 )
            n_f1 := alltrim( I0 )
            OG02_C:REFRESH()
	         ENDIF
	      ENDIF
    
   NEXT
	   IF len( n_f1 ) = 0
      FAN_C := n_f2
	      //OG02_C:REFRESH()
	   ENDIF
	   //   XSETFOCUS( OG15_C )
   // XBROWSE( Arq_1 )
	   ? Arq_1
	RETURN .T.


 

Link to comment
Share on other sites

Boa tarde, eu dei uma mudadinha, retorna um array com os dados

 

FUNCTION PEGA_CNPJ(PROC_CNPJ)
    Local oServerWS, cUrl, aCNPJ[12]
    if LEN(PROC_CNPJ)#14
        MSGINFO("Este busca não funciona para CPF!")
        return .t.
    endif
    
    cUrl:= "https://www.receitaws.com.br/v1/cnpj/"+PROC_CNPJ

    Try
        oServerWS := CreateObject( 'MSXML2.ServerXMLHTTP.5.0' )  
    Catch oError
        try
            oServerWS := CreateObject( 'MSXML2.ServerXMLHTTP.6.0' )  
        catch oError
            try
                oServerWS := CreateObject("Microsoft.XMLHTTP")
            catch oError
                ? e:Description
                return nil
            end
        END
    end

    TRY
        oServerWS:open('GET', cUrl, .f.)
        oServerWS:setRequestHeader('Content-Type'    , 'text/xml; charset=utf-8')    // Obtém ou define o valor de cabeçalho de Content-type HTTP. 
        oServerWS:send()    
    CATCH
        ? "Não conseguiu enviar solicitação para requisição dos dados do CNPJ"
        return .t.
    END
     
    * Verifica o status do request. Exibe erro se houver
    IF oServerWS:Status != 200 // OK
        MsgStop( Alltrim(STR(oServerWS:Status)) +" - "+ oServerWS:StatusText , "Erro")
        RETURN NIL
    ENDIF
     
    WHILE oServerWS:readyState != 4
        oServerWS:waitForResponse(1000)
    END   
         
    * decodifica o arquivo json e transforma em um array multidimensional
    **    x :=  hb_jsondecode( oServerWS:responseText, @aArray )

    txt:=  oServerWS:responseText
*? txt   
    Arq_1:=ALLTRIM(txt)                                              

    ARR0:=HB_ATokens( Arq_1, CHR(10) )
*xbrowse(ARR0)
    TAB:={}
    QT:=0
    n_f1:=""
    n_f2:=""
    FOR I=1 TO LEN(ARR0)

        if substr(ARR0,4,4) = "nome"  // REG 1 - Nome
            I0:=ARR0   
            I0:=StrTran( I0, "nome" ) 
            I0:=StrTran( I0, ":" ) 
            I0:=StrTran( I0, "," ) 
            I0:=StrTran( I0, ";" ) 
            I0:=StrTran( I0, CHR(34) ) 
            if len(alltrim(I0))>0
                aCNPJ[1] := alltrim(I0)
            endif
        endif

        if substr(ARR0,4,2) = "uf"  // REG 2 - UF
            I0:=ARR0    
            I0:=StrTran( I0, "uf" ) 
            I0:=StrTran( I0, ":" ) 
            I0:=StrTran( I0, "," ) 
            I0:=StrTran( I0, ";" ) 
            I0:=StrTran( I0, CHR(34) ) 
            if len(alltrim(I0))>0
                aCNPJ[2] := alltrim(I0)
            endif
        ENDIF

        if substr(ARR0,4,10) = "logradouro"  // REG 3 - LOGRADOURO
            I0:=ARR0
            I0:=StrTran( I0, "logradouro" ) 
            I0:=StrTran( I0, ":" ) 
            I0:=StrTran( I0, "," ) 
            I0:=StrTran( I0, ";" ) 
            I0:=StrTran( I0, CHR(34) ) 
            if len(alltrim(I0))>0
                aCNPJ[3] := alltrim(I0)
            endif
        ENDIF

        if substr(ARR0,4,6) = "numero"  // REG 4 - NÚMERO
            I0:=ARR0
            I0:=StrTran( I0, "numero" ) 
            I0:=StrTran( I0, ":" ) 
            I0:=StrTran( I0, "," ) 
            I0:=StrTran( I0, ";" ) 
            I0:=StrTran( I0, CHR(34) ) 
            if len(alltrim(I0))>0
                aCNPJ[4] := alltrim(I0)
            endif
        ENDIF
        
        if substr(ARR0,4,3) = "cep"  // REG 5 - CEP
            I0:=ARR0
            I0:=StrTran( I0, "cep" ) 
            I0:=StrTran( I0, ":" ) 
            I0:=StrTran( I0, "," ) 
            I0:=StrTran( I0, ";" )
            I0:=StrTran( I0, "." )
            I0:=StrTran( I0, "-" )
            I0:=StrTran( I0, CHR(34) ) 
            if len(alltrim(I0))>0
                aCNPJ[5] := transform(alltrim(I0),"@R 99999-999")
            endif
        ENDIF
        
        if substr(ARR0,4,9) = "municipio"  // REG 6 - MUNICÍPIO
            I0:=ARR0
            I0:=StrTran( I0, "municipio" ) 
            I0:=StrTran( I0, ":" ) 
            I0:=StrTran( I0, "," ) 
            I0:=StrTran( I0, ";" ) 
            I0:=StrTran( I0, CHR(34) ) 
            if len(alltrim(I0))>0
                aCNPJ[6] := alltrim(I0)
            endif
        ENDIF
        
        if substr(ARR0,4,8) = "abertura"  // REG 7 - DT ABERTURA
            I0:=ARR0
            I0:=StrTran( I0, "abertura" ) 
            I0:=StrTran( I0, ":" ) 
            I0:=StrTran( I0, "," ) 
            I0:=StrTran( I0, ";" ) 
            I0:=StrTran( I0, CHR(34) ) 
            if len(alltrim(I0))>0
                aCNPJ[7] := alltrim(I0)
            endif
        ENDIF
        
        if substr(ARR0,4,6) = "bairro" // REG 8 - BAIRRO
            I0:=ARR0
            I0:=StrTran( I0, "bairro" ) 
            I0:=StrTran( I0, ":" ) 
            I0:=StrTran( I0, "," ) 
            I0:=StrTran( I0, ";" ) 
            I0:=StrTran( I0, CHR(34) ) 
            if len(alltrim(I0))>0
                aCNPJ[8] := alltrim(I0)
            endif
        ENDIF
        
        if substr(ARR0,4,11) = "complemento"  // REG 9 - COMPLEMENTO
            I0:=ARR0
            I0:=StrTran( I0, "complemento" ) 
            I0:=StrTran( I0, ":" ) 
            I0:=StrTran( I0, "," ) 
            I0:=StrTran( I0, ";" ) 
            I0:=StrTran( I0, CHR(34) ) 
            if len(alltrim(I0))>0
                aCNPJ[9] := alltrim(I0)
            endif
        ENDIF
        
        if substr(ARR0,4,5) = "email"  // REG 10 - EMAIL
            I0:=ARR0
            I0:=StrTran( I0, "email" ) 
            I0:=StrTran( I0, ":" ) 
            I0:=StrTran( I0, "," ) 
            I0:=StrTran( I0, ";" ) 
            I0:=StrTran( I0, CHR(34) ) 
            if len(alltrim(I0))>0
                aCNPJ[10] := alltrim(I0)
            endif
        ENDIF
        
        
        if substr(ARR0,4,8) = "telefone"  // REG 11 - TELEFONE
            I0:=ARR0
            I0:=StrTran( I0, "telefone" ) 
            I0:=StrTran( I0, ":" ) 
            I0:=StrTran( I0, "," ) 
            I0:=StrTran( I0, ";" ) 
            I0:=StrTran( I0, CHR(34) ) 
            if len(alltrim(I0))>0
                aCNPJ[11] := alltrim(I0)
*                IF AT("/",TEL_C)>0
*                    TEL_C:=ALLTRIM(LEFT(TEL_C,AT("/",TEL_C)-1))
*                ENDIF
            endif
        ENDIF
        
        
        if substr(ARR0,4,8) = "fantasia"  // REG 12 - FANTASIA
            I0:=ARR0
            I0:=StrTran( I0, "fantasia" ) 
            I0:=StrTran( I0, ":" ) 
            I0:=StrTran( I0, "," ) 
            I0:=StrTran( I0, ";" ) 
            I0:=StrTran( I0, CHR(34) ) 
            if len(alltrim(I0))>0
                aCNPJ[12] := alltrim(I0)
            endif
        ENDIF
    
    NEXT
*    xbrowse(aCNPJ)
RETURN(aCNPJ)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...