ElvisCasolis

I can´t get a table from IE

23 posts in this topic

#1 ·  Posted

Hi, can anybody help me?

I´m writing a script that gets data from a table from IE, i have almost finished but when i try to get data from the table, it seems that autoit doesn´t detect the table.

To build the table i have to put some parameters, then i submit the form, and when i use the function 

_IETableGetCollection($oIE, 19)

i cant get the table.

I already counted all the tables in the page, i need the table 19, but as i said, autoit doesn´t detect the table.

 

So then i did a test, when i submited the form, i put the function 

_IEBodyReadText($oIE)

then i wrote this text in a notepad to know if i could see the table at least in the source code of the page, and neither.

 

 

Please, help me.:'(

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

This isn't how that function works. 0 or any positive integer just sets a flag that returns an indexed instance. 

I was incorrect, read the documentation wrong.

Can you post your HTML so we can see what it looks like? Your table could be in an iFrame which would prevent autoit from seeing it with that function.

Edited by anthonyjr2

UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
Share on other sites

#3 ·  Posted

7 minutes ago, anthonyjr2 said:

This isn't how that function works. 0 or any positive integer just sets a flag that returns an indexed instance. 

I was incorrect, read the documentation wrong.

Can you post your HTML so we can see what it looks like? Your table could be in an iFrame which would prevent autoit from seeing it with that function.

Sure, here is the code of the parameters, sorry if some text is in Spanish, i'm from Mexico.

here´s the code, this is how the code looks before submitting the form:

<td width=100% valign=top>
            <table border="0" cellpadding="0" cellspacing="5" width="100%">
              <tr><td colspan=3><font face=verdana size=3 color=#68a400><b>Desplazamientos.</b></font></td></tr>
                <!--- Captura de los parámetros --->
              <tr>
                <td valign="top" width=100% >
                  <form name="consulta" method="POST" action="desp.asp?IndDesp=1">
                  <table cellpadding="0" cellspacing="0" width="100%" border="0" align="center" valign="top">
                    <tr>
                      <td width="100%" align="left">
                        <table border=0>
                          <tr>
                            <td width="100%">
                              <font size="2" face="verdana"> Fecha: </font>
                              <select name="Anio" SIZE="1">
                                
                                <option value="217" > 2017 </option>
                                
                                <option value="216" > 2016 </option>
                                
                                <option value="215" > 2015 </option>
                                
                                <option value="214" > 2014 </option>
                                
                                <option value="213" > 2013 </option>
                                
                                <option value="212" > 2012 </option>
                                
                                <option value="211" > 2011 </option>
                                
                                <option value="210" > 2010 </option>
                                
                                <option value="209" > 2009 </option>
                                
                                <option value="208" > 2008 </option>
                                
                                <option value="207" > 2007 </option>
                                
                                <option value="206" > 2006 </option>
                                
                                <option value="205" > 2005 </option>
                                
                                <option value="204" > 2004 </option>
                                
                                <option value="203" > 2003 </option>
                                
                                <option value="202" > 2002 </option>
                                
                                <option value="201" > 2001 </option>
                                
                              </select>
                              
                              <select name="Mes" SIZE="1">
                                <option value="01" >  Enero
                                <option value="02" >  Febrero
                                <option value="03" >  Marzo
                                <option value="04" >  Abril
                                <option value="05" >  Mayo
                                <option value="06"  selected >  Junio
                                <option value="07" >  Julio
                                <option value="08" >  Agosto
                                <option value="09" >  Septiembre
                                <option value="10" >  Octubre
                                <option value="11" >  Noviembre
                                <option value="12" >  Diciembre
                              </select>
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                    <tr>
                      <td width="100%" valign=top>
                        <table width="100%" height=60 Border=0>
                          <tr>
                            <td align="left" valign="top" width="200">
                              <font size="2" face="verdana"> Selección de:</font>
                              <select name="Camino" id="Camino" onChange="javascript:Cambio();">
                                <option value="0"> Todos</option>
                                <option value="1"> División</option>
                                <option value="2"> Categoría</option>
                                <option value="3"> Código</option>
                              </select>
                            </td>
                            <td valign=top>
                              <div id="todos" class="oculto">
                              </div>

                              <div id="CapturaDivision" class="oculto">
                              <table align=left valign=top>
                                <tr>
                                  <td align="center"><font size="2" face="verdana"> División</font>
                                    <select name="Division" SIZE="1">
                                    <option value=0 >sin division<option value=1 >ROPA                <option value=2 >VARIEDADES          <option value=3 >ABARROTES           <option value=4 >FRESCOS<option value=5 >ALIMENTOS PREPARADOS<option value=6 >PROM. ESPECIALES<option value=8 >EQUIPO OPERATIVO<option value=9 >CONSUMOS INTERNOS<option value=10 >EQUIPO DE EDIFICIO<option value=11 >CONSTRUCCION<option value=12 >TRANSPORTE
                                    </select>
                                  </td>
                                </tr>
                              </table>
                              </div>

                              <div id="CapturaCategoria" class="oculto">
                              <table align=left>
                                <tr>
                                  <td align="center"><font size="2" face="verdana"> Categoría</font>
                                    <select name="categoria" SIZE="1">
                                    <option value=132 >COMPUTO<option value=325 >AUDIO<option value=496 >VIDEOJUEGOS
                                    </select>
                                  </td>
                                </tr>
                              </table>
                              </div>

                              <div id="CapturaCodigo" class="oculto">
                              <table align=left>
                                <tr>
                                  <td align="center">
                                    <font size="2" face="verdana"> Código</font>
                                    <font size="1" face="verdana"><input type="text" name="codigo" maxlength="14" size="14"></font>
                                  </td>
                                </tr>
                              </table>
                              </div>

                              <div id="todos2" class="oculto">
                              </div>
                            </td>
                          </tr>
                          <tr>
                            <td colspan=2 align="left" valign="top">
                              <font size="2" face="verdana"> Presentado por:</font>
                              <select name="Geografia" id="Geografia">
                                <option value="0" SELECTED> División</option>
                                <option value="1"> Zona</option>
                                <option value="2"> Ciudad</option>
                                <option value="3"> Estado</option>
                                <option value="4"> Municipio</option>
                                <option value="5"> Tienda</option>
                                <option value="6"> Código</option>
                                <option value="7"> Categoría</option>
                              </select>
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                    <tr>
                      <td align="center">
                        <input type=hidden name=cia value=1>
                        <input type=hidden name=mess value=06>
                        <input id=submit1 name=submit1 type=image src="../../resources/v3_Consultar.gif" border=0 alt="Iniciar Consulta">
                    </tr>
                  </table>
                  </form>
                </td>
              </tr>
                </tr>
              <!--- Presentación de los datos --->
              

            </table>
          </td>
        </tr>
      
</table>

 

Then, when you put the parameters:

 

<!--- Presentación de los datos --->
              
                <tr>
                  <td>
                    <table cellpadding=0 cellspacing=0 width="100%" align="center" border=1>
                      
                    <tr>
                      <td colspan="6" align="center"><font face="verdana" size="2"> Seleccion de Todo  Presentado por Código  En el mes de AGOSTO &nbsp;de&nbsp;2013</font></td>
                    </tr>

This is the table i want to get.

Share this post


Link to post
Share on other sites

#5 ·  Posted

3 minutes ago, anthonyjr2 said:
Local $oTable = _IETableGetCollection($oIE, 19)
Local $aTableData = _IETableWriteToArray($oTable)

_ArrayDisplay($aTableData)

What does this give you when you run it in your code? It should pop up a window with the data of the table.

I have already tried this, but that gives me another table, the table that is below of the table i want :

<table border="0" cellpadding="0" cellspacing="0" width=100%><tr><td bgcolor=#639C00 align=center><font face="Arial Narrow" size=-1 color=#FFFFF>Tiendas Soriana S.A. de C.V, Alejandro de Rodas 3102-A Colonia Cumbres 8o Sector, Monterrey, N.L., México</font></td></tr></table>

Then, i tried to get the  table 18, but that gives me the table of the parameters jaja, i don´t understand why

Share this post


Link to post
Share on other sites

#6 ·  Posted

The index is zero-based, so you would pass 18 for the 2nd parameter of _IETableGetCollection if you are trying to retrieve the 19th table.

Unsure why the results aren't matching up. You may want to pass -1 as the 2nd parameter to get a collection of all tables and then loop through each one until you find the correct one.

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

46 minutes ago, Danp2 said:

You may want to pass -1 as the 2nd parameter to get a collection of all tables and then loop through each one until you find the correct one.

This is what I recommend as well. That way you can just do:

Local $oTables = _IETableGetCollection($oIE, -1)
Local $ctr = 1
Local $myTable
For $table in $oTables
    If($ctr = 19) Then
        $myTable = $table
        ExitLoop
    EndIf
    $ctr += 1
Next

This may not be the best way but it should work nonetheless. The table you want will be stored in $myTable.

Edited by anthonyjr2

UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
Share on other sites

#8 ·  Posted

9 minutes ago, anthonyjr2 said:

This is what I recommend as well. That way you can just do:

Local $oTables = _IETableGetCollection($oIE, -1)
Local $ctr = 1
Local $myTable
For $table in $oTables
    If($ctr = 19) Then
        $myTable = $table
        ExitLoop
    EndIf
    $ctr += 1
Next

This may not be the best way but it should work nonetheless. The table you want will be stored in $myTable.

Thanks, i´ll try and then i tell you

Share this post


Link to post
Share on other sites

#9 ·  Posted

Honestly, I don't believe that will give different result than you saw previously. I was suggesting something like this --

Local $ctr = 0
Local $aTableData

Local $oTables = _IETableGetCollection($oIE, -1)

For $oTable in $oTables
    ConsoleWrite("$ctr=" & $ctr & @CRLF)
    $aTableData = _IETableWriteToArray($oTable)
    _ArrayDisplay($aTableData)
    $ctr += 1
Next

Then use the console output along with the array info to try to figure out which table is the correct one.

Share this post


Link to post
Share on other sites

#10 ·  Posted

14 minutes ago, Danp2 said:

Honestly, I don't believe that will give different result than you saw previously. I was suggesting something like this --

Local $ctr = 0
Local $aTableData

Local $oTables = _IETableGetCollection($oIE, -1)

For $oTable in $oTables
    ConsoleWrite("$ctr=" & $ctr & @CRLF)
    $aTableData = _IETableWriteToArray($oTable)
    _ArrayDisplay($aTableData)
    $ctr += 1
Next

Then use the console output along with the array info to try to figure out which table is the correct one.

Thanks, i´ll also try and then i tell you

Share this post


Link to post
Share on other sites

#11 ·  Posted

23 minutes ago, Danp2 said:

Honestly, I don't believe that will give different result than you saw previously. I was suggesting something like this --

Local $ctr = 0
Local $aTableData

Local $oTables = _IETableGetCollection($oIE, -1)

For $oTable in $oTables
    ConsoleWrite("$ctr=" & $ctr & @CRLF)
    $aTableData = _IETableWriteToArray($oTable)
    _ArrayDisplay($aTableData)
    $ctr += 1
Next

Then use the console output along with the array info to try to figure out which table is the correct one.

This was useful to see all the tables in the page, but the table i need was not displayed, i can see it in the page, but it seems autoit doesn´t detect it

Share this post


Link to post
Share on other sites

#12 ·  Posted

Did my way not work either?


UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
Share on other sites

#13 ·  Posted

2 minutes ago, anthonyjr2 said:

Did my way not work either?

nope, the same. i dont know why autoit doesn´t detect the table i need

Share this post


Link to post
Share on other sites

#14 ·  Posted

Have you checked to see if there are any frames in use on this site?

Share this post


Link to post
Share on other sites

#15 ·  Posted

8 minutes ago, Danp2 said:

Have you checked to see if there are any frames in use on this site?

there are no frames

Share this post


Link to post
Share on other sites

#16 ·  Posted

Sorry, but I'm out of ideas. Can you save the full HTML page to a file and then post it here?

Share this post


Link to post
Share on other sites

#17 ·  Posted

10 minutes ago, Danp2 said:

Sorry, but I'm out of ideas. Can you save the full HTML page to a file and then post it here?

sure, here you have 

Page.htm

Share this post


Link to post
Share on other sites

#18 ·  Posted

Not sure why we are seeing different results. Here's my code --

#include <IE.au3>
#include <array.au3>

Local $sURL = "C:\page.htm"
Local $oIE = _IECreate($sURL)

Local $oTable = _IETableGetCollection($oIE, 19)
Local $aTableData = _IETableWriteToArray($oTable)

_ArrayDisplay($aTableData)

And here's the output from _ArrayDisplay --

Row|Col 0|Col 1|Col 2
[0]| Seleccion de Todo Presentado por Código En el mes de MAYO  de 2017| Dimensión|889842181357
[1]|| Unid. Vendidas|44
[2]||Valor Ventas|$285.00
[3]|| Unid. Compradas|23
[4]||Valor Compras|$143.00
[5]|| Existencia|395

 

Share this post


Link to post
Share on other sites

#19 ·  Posted

2 minutes ago, Danp2 said:

Not sure why we are seeing different results. Here's my code --

#include <IE.au3>
#include <array.au3>

Local $sURL = "C:\page.htm"
Local $oIE = _IECreate($sURL)

Local $oTable = _IETableGetCollection($oIE, 19)
Local $aTableData = _IETableWriteToArray($oTable)

_ArrayDisplay($aTableData)

And here's the output from _ArrayDisplay --

Row|Col 0|Col 1|Col 2
[0]| Seleccion de Todo Presentado por Código En el mes de MAYO  de 2017| Dimensión|889842181357
[1]|| Unid. Vendidas|44
[2]||Valor Ventas|$285.00
[3]|| Unid. Compradas|23
[4]||Valor Compras|$143.00
[5]|| Existencia|395

 

I´m sure that it´s something when i put the parameters, because when i submit the form, the page looks like it reload, and then it shows the table.

Share this post


Link to post
Share on other sites

#20 ·  Posted

1 minute ago, ElvisCasolis said:

I´m sure that it´s something when i put the parameters, because when i submit the form, the page looks like it reload, and then it shows the table.

I put the source code in the file how it looks after submitting the form, before it´s the same but without the table.

Share this post


Link to post
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