Jump to content

Help with _Ietablegetcollection


 Share

Recommended Posts

 

I need your guidance, I'm reading a text file from C: \ and put it in a form of a page to the query, when it made the query, I keep the website and read the existing tables and that information placed it in a excel and put it .. It happens that sometimes read tables and sometimes not and pulls me the error of the image. Could help because they do not understand why strip that problem if the saved page has tables. And if they can optimize the code is agradeceria .. thanks for your help

 

#include <IE.au3>
#include <Excel.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>
#include <array.au3>
#include <String.au3>

;apertura de libro de excel
;~ $oExcelRead = _Excel_Open()
;~ $aRead = _Excel_BookOpen($oExcelRead,"C:\man.xlsx")
;~ $dataMan = _Excel_RangeRead($aRead,1,default)

;~ prueba de lectura archivo de texto
$File ="C:\man.txt"
Local $dataMan
_FileReadToArray($File, $dataMan)

;Inicio de Ciclo de array
For $i = 1 to Ubound($dataMan) -1
   ;Creacion de objeto para consultar manifiesto
   $oIE = _IECreate("http://portal.sat.gob.gt/jmanif/faces/AdConsultaManifiesto.jsp",0,1)
   _IELoadWait($oIE)
   Local $oForm = _IEFormGetObjByName($oIE, "form1")
   Local $oQuery = _IEFormElementGetObjByName($oForm, "form1:txtNoManifiestoCons")
   sleep(1000)
   _IEFormElementSetValue ($oQuery,$dataMan[$i])
   _IEImgClick($oIE,"Consultar","alt")
   _IELoadWait($oIE)
   sleep(2000)

   ;Instrucciones para tiempo de ingreso de teclas
   Opt('SendKeyDelay', 150)
   sleep(1000)
   Send("{ALTDOWN}{ALTUP}")
   Send("f")
   sleep(250)
   Send("a")
   sleep(250)
   ControlSend("Save Webpage","","",$dataMan[$i])
   sleep(250)
   Send("{ENTER}")
   sleep(250)
   ;clausura de ventana de consulta de manifiesto
   WinClose("Consulta de manifiestos - Internet Explorer")

   ;apertura de objeto de pagina guardada de manifiestos
   $oIE1 = _IECreate ("C:\"&$dataMan[$i]&".htm")
   _IELoadWait($oIE1)
   sleep(1000)
   $lista = _IEBodyReadText($oiE1)
   Local $texto = _StringBetween($lista,"ningún","número")

   if (IsArray($texto)) Then
      ConsoleWrite("No data"&$dataMan[$i])
   Else
      ;apertura de libro de excel para guardar informacion
      $oExcel = _Excel_Open()
      $oWorkBook = _Excel_BookNew ($oExcel,1)

      $oTable = _IETableGetCollection ($oIE1, 5) ; Get number table of html
      $oTable1 = _IETableGetCollection ($oIE1, 29) ; Get number table of html 29

      ;~ Recoleccion de datos Manifiesto, fecha, puerto------------------------------------
      $aTableData = _IETableWriteToArray ($oTable)
      $ExtractNoManifest = _ArrayExtract($aTableData,1,1,0,0)
      $ExtractNamePort = _ArrayExtract($aTableData,1,1,12,12)
      $ExtractDate = _ArrayExtract($aTableData,1,1,6,6)
      ;_ArrayDisplay($aTableData)
      ;~ Recoleccion de datos embarques-------------------------------------------------

      $aTableData1 = _IETableWriteToArray ($oTable1)
      $TrasposeArray = _ArrayTranspose($aTableData1)
      _ArrayDelete($aTableData1,0)
;~    _ArrayDisplay($aTableData1)


      ;Llenado de informacion recolectada en excel
      for $j = 1 to Ubound($aTableData1)
         _Excel_RangeWrite($oWorkBook,1,$ExtractNoManifest,"A"&$j)
         _Excel_RangeWrite($oWorkBook,1,$ExtractNamePort,"B"&$j)
         _Excel_RangeWrite($oWorkBook,1,$ExtractDate,"C"&$j)
      Next
   _Excel_RangeWrite($oWorkBook,1,$aTableData1,"D1")
   ;Salvado de informacion recolectada y cierre de libro guardado
   $ExcelSave = _Excel_BookSaveAs($oWorkBook, "C:\"&$dataMan[$i], Default, True)
   Winclose($dataMan[$i]&".xlsx")
   EndIf

;~    $ExcelSave = _Excel_BookSaveAs($oWorkBook, "C:\"&$dataMan[$i], Default, True)
;~    Winclose($dataMan[$i]&".xlsx")
      _IEQuit($oIE1)
      FileDelete("C:\"&$dataMan[$i]&".htm")
      Sleep(1500)
   Next

 

Untitled.jpg

Link to comment
Share on other sites

5 minutes ago, hudani31 said:

 

I need your guidance, I'm reading a text file from C: \ and put it in a form of a page to the query, when it made the query, I keep the website and read the existing tables and that information placed it in a excel and put it .. It happens that sometimes read tables and sometimes not and pulls me the error of the image. Could help because they do not understand why strip that problem if the saved page has tables. And if they can optimize the code is agradeceria .. thanks for your help

 

#include <IE.au3>
#include <Excel.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>
#include <array.au3>
#include <String.au3>

;apertura de libro de excel
;~ $oExcelRead = _Excel_Open()
;~ $aRead = _Excel_BookOpen($oExcelRead,"C:\man.xlsx")
;~ $dataMan = _Excel_RangeRead($aRead,1,default)

;~ prueba de lectura archivo de texto
$File ="C:\man.txt"
Local $dataMan
_FileReadToArray($File, $dataMan)

;Inicio de Ciclo de array
For $i = 1 to Ubound($dataMan) -1
   ;Creacion de objeto para consultar manifiesto
   $oIE = _IECreate("http://portal.sat.gob.gt/jmanif/faces/AdConsultaManifiesto.jsp",0,1)
   _IELoadWait($oIE)
   Local $oForm = _IEFormGetObjByName($oIE, "form1")
   Local $oQuery = _IEFormElementGetObjByName($oForm, "form1:txtNoManifiestoCons")
   sleep(1000)
   _IEFormElementSetValue ($oQuery,$dataMan[$i])
   _IEImgClick($oIE,"Consultar","alt")
   _IELoadWait($oIE)
   sleep(2000)

   ;Instrucciones para tiempo de ingreso de teclas
   Opt('SendKeyDelay', 150)
   sleep(1000)
   Send("{ALTDOWN}{ALTUP}")
   Send("f")
   sleep(250)
   Send("a")
   sleep(250)
   ControlSend("Save Webpage","","",$dataMan[$i])
   sleep(250)
   Send("{ENTER}")
   sleep(250)
   ;clausura de ventana de consulta de manifiesto
   WinClose("Consulta de manifiestos - Internet Explorer")

   ;apertura de objeto de pagina guardada de manifiestos
   $oIE1 = _IECreate ("C:\"&$dataMan[$i]&".htm")
   _IELoadWait($oIE1)
   sleep(1000)
   $lista = _IEBodyReadText($oiE1)
   Local $texto = _StringBetween($lista,"ningún","número")

   if (IsArray($texto)) Then
      ConsoleWrite("No data"&$dataMan[$i])
   Else
      ;apertura de libro de excel para guardar informacion
      $oExcel = _Excel_Open()
      $oWorkBook = _Excel_BookNew ($oExcel,1)

      $oTable = _IETableGetCollection ($oIE1, 5) ; Get number table of html
      $oTable1 = _IETableGetCollection ($oIE1, 29) ; Get number table of html 29

      ;~ Recoleccion de datos Manifiesto, fecha, puerto------------------------------------
      $aTableData = _IETableWriteToArray ($oTable)
      $ExtractNoManifest = _ArrayExtract($aTableData,1,1,0,0)
      $ExtractNamePort = _ArrayExtract($aTableData,1,1,12,12)
      $ExtractDate = _ArrayExtract($aTableData,1,1,6,6)
      ;_ArrayDisplay($aTableData)
      ;~ Recoleccion de datos embarques-------------------------------------------------

      $aTableData1 = _IETableWriteToArray ($oTable1)
      $TrasposeArray = _ArrayTranspose($aTableData1)
      _ArrayDelete($aTableData1,0)
;~    _ArrayDisplay($aTableData1)


      ;Llenado de informacion recolectada en excel
      for $j = 1 to Ubound($aTableData1)
         _Excel_RangeWrite($oWorkBook,1,$ExtractNoManifest,"A"&$j)
         _Excel_RangeWrite($oWorkBook,1,$ExtractNamePort,"B"&$j)
         _Excel_RangeWrite($oWorkBook,1,$ExtractDate,"C"&$j)
      Next
   _Excel_RangeWrite($oWorkBook,1,$aTableData1,"D1")
   ;Salvado de informacion recolectada y cierre de libro guardado
   $ExcelSave = _Excel_BookSaveAs($oWorkBook, "C:\"&$dataMan[$i], Default, True)
   Winclose($dataMan[$i]&".xlsx")
   EndIf

;~    $ExcelSave = _Excel_BookSaveAs($oWorkBook, "C:\"&$dataMan[$i], Default, True)
;~    Winclose($dataMan[$i]&".xlsx")
      _IEQuit($oIE1)
      FileDelete("C:\"&$dataMan[$i]&".htm")
      Sleep(1500)
   Next

 

Untitled.jpg

 

Sorry, the document information ranging from the number 21F16000000 to 21F16000500

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...