Jump to content

Read table from arrey in browser, handle the fields,


Recommended Posts

on my way to create a script that reads text from the browser i found this post that helps me alot

 

the essential part of the topic is this script

 
the webpage im on is this one WD.htm

 

#include <IE.au3>
#include <Array.au3>

$oIE = _IECreate("file:///C:/Users/User/Desktop/WD.htm#")
$oTable = _IETableGetCollection ($oIE) ; Get number of tables
$iNumTables = @extended
MsgBox(0, "Table Info", "There are " & $iNumTables & " tables on the page")
$oTable = _IETableGetCollection ($oIE, $iNumTables-1) ; Get last table
$aTableData = _IETableWriteToArray ($oTable)

 

 

now theres the result it got the output that i need on row2

how can i go on to get this texts usable for me?

what i need is the text from the collums in row2.

is it possible to safe the output to a file and how?

Edited by svenjatzu
Link to comment
Share on other sites

#include <IE.au3>
#include <Array.au3>
Global $sMsg = ""
$oIE = _IECreate("file:///C:/Users/User/Desktop/tipico%20watchdog/WD.htm#")
$oTable = _IETableGetCollection ($oIE) ; Get number of tables
$iNumTables = @extended
MsgBox(0, "Table Info", "There are " & $iNumTables & " tables on the page")
$oTable = _IETableGetCollection ($oIE, $iNumTables-1) ; Get last table
$aTableData = _IETableWriteToArray ($oTable)
_ArrayDisplay($aTableData)

ClipPut($atabledata[2][1])     ; <----- row 2 (offset[1]) column 4 (offset[3])  arrays are zero based
MsgBox(0, "Clipboard contains:", ClipGet())

 

Link to comment
Share on other sites

next step is i got to take the number from col2 row1 somehow safed for useing it later again.

what i got to do now is

1) work with the number from col2row1 in another script. also the next script uses the clipbord so i cant keep it in there.

2) after the second script is done i need to mark the checkbox from the col2row1

3) there are different values in the col2row1 like eg termial-12345, k1234567890, namedpaul, how can i make the first script imidiatley mark the checkbox on values like k1234567890, namedpaul, and only use the value terminal-12345?

 

Link to comment
Share on other sites

thats wired,

with this codes last line

#include <Array.au3>

$oTable = _IETableGetCollection ($oIE) ; Get number of tables
$iNumTables = @extended
MsgBox(0, "Table Info", "There are " & $iNumTables & " tables on the page")
$oTable = _IETableGetCollection ($oIE, $iNumTables-1) ; Get last table
$aTableData = _IETableWriteToArray ($oTable)
_ArrayDisplay($aTableData)
ClipPut($atabledata[2][1])     ; <----- row 2 (offset[1]) column 4 (offset[3])  arrays are zero based
MsgBox(0, "Clipboard contains:", ClipGet())

_IEFormElementCheckBoxSelect($oForm, ClipGet(), "_chk", 1, "byIndex",0) ;; checkbox vom terminal setzen

the script makes the checkbox from the number read before checked in the ofline version from the website.

now if i use the same script in the online version the checkbox doenst check.

do you know why this happens?

Link to comment
Share on other sites

3 hours ago, svenjatzu said:

do you know why this happens?

Maybe checking the @error code after each function call would help you know if an error occurs, and which error (if present), is causing the script to not work as expected :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

It's always hard to debug these things without your full code and the website itself.

In your snippet, you don't even include the part where you define $oForm.

Also, I would go with what Danp2 suggested, because right now the data you need is in the last table, but what if they add another table after the data you want. With _IEGetObjById it will always find the specific element with required ID or if not it will error out so you know they changed the HTML.

8 hours ago, Danp2 said:

The table has an ID, so use _IEGetObjById to get the object reference for the element. Then use _IETableWriteToArray to load the table's contents into an array.

 

Link to comment
Share on other sites

;~ WinWaitActive("Windows-Sicherheit","") ;;; warten bis fesnter aktiv ist
;~ MsgBox(1,"","",0)
;~ Send("^{a}")
;~ Send("pm") ;;;; einloggen
;~ send("{tab}")
;~ Sleep(222)
;~ Send("giBBpX3fs6")  ;;;einloggen
;~ Sleep(222)
;~ Send("{enter}")


;formular ausfüllen    DATUM
#include <Array.au3>
#include <IE.au3>
Global $oIE =  _IECreate("file:///C:/Users/User/Desktop/WD.htm#")
;~ $oIE = _IE_Example("form")
$oForm = _IEFormGetObjByName($oIE, "errorForm")
Local $oInputFile = _IEFormElementGetObjByName($oForm, "dateFrom")
; Assign input focus to the field and then send the text string
_IEAction($oInputFile, "focus")
; Select existing content so it will be overwritten.
_IEAction($oInputFile, "selectall")
Send("2019-07-31")


;formular ausfüllen    Meldung Message
Local $oInputFile = _IEFormElementGetObjByName($oForm, "message")
; Assign input focus to the field and then send the text string
_IEAction($oInputFile, "focus")
; Select existing content so it will be overwritten.
_IEAction($oInputFile, "selectall")
Send("does not match")


;formular ausfüllen    Benutzer
Local $oSelect = _IEFormElementGetObjByName($oForm, "groupBy")
_IEAction($oSelect, "focus")
;~ For $i = 1 To 10
    _IEFormElementOptionSelect($oSelect, "user", 1, "byText")

;Filter Button drücken
    Local $oSubmit = _IEGetObjById($oIE, "filterButton")
_IEAction($oSubmit, "click")
_IELoadWait($oIE)


;;;;warten bis geladen ist !!!!!!!!


;;;ergebnis auslesen
$oTable = _IETableGetCollection ($oIE) ; Get number of tables
$iNumTables = @extended
MsgBox(0, "Table Info", "There are " & $iNumTables & " tables on the page")
$oTable = _IETableGetCollection ($oIE, $iNumTables-1) ; Get last table
$aTableData = _IETableWriteToArray ($oTable)
_ArrayDisplay($aTableData)
ClipPut($atabledata[2][1])     ; <----- row 2 (offset[1]) column 4 (offset[3])  arrays are zero based
MsgBox(0, "Clipboard contains:", ClipGet())

_IEFormElementCheckBoxSelect($oForm, ClipGet(), "_chk", 1, "byIndex",0) ;; checkbox vom terminal setzen

;;;  processed klicken?
;Filter Button drücken
;~  Local $oSubmit = _IEGetObjById($oIE, "Processed")
;~ _IEAction($oSubmit, "click")
;~ _IELoadWait($oIE)

;;;  ClipGet() in

 

Edited by svenjatzu
Link to comment
Share on other sites

3 hours ago, Seminko said:

It's always hard to debug these things without your full code and the website itself.

In your snippet, you don't even include the part where you define $oForm.

Also, I would go with what Danp2 suggested, because right now the data you need is in the last table, but what if they add another table after the data you want. With _IEGetObjById it will always find the specific element with required ID or if not it will error out so you know they changed the HTML.

 

somewhere up the first post is the safed offline webpage from this one, please loog at it thats the same where im working on

Link to comment
Share on other sites

Again, it's hard to work on a problem where I'm not able to see the "live version" of a site.

However, I have a hunch that on the live page the table you were looking for was not in fact the last table. Even if it was, if you can, always pick a specific element instead of relying on indexes which can change quite often.

Anyways, try this:

;;;ergebnis auslesen
$oTable = _IEGetObjById($oIE, "bean")
If @error Then
    MsgBox(16, "Error", '_IEGetObjById($oIE, "bean") error - ' & @error)
EndIf
$aTableData = _IETableWriteToArray ($oTable)
_ArrayDisplay($aTableData)
$var = StringStripWS($atabledata[2][1], 3)     ; <----- row 2 (offset[1]) column 4 (offset[3])  arrays are zero based
MsgBox(0, "$var", $var)

;_IEFormElementCheckBoxSelect($oForm, ClipGet(), "_chk", 1, "byIndex", 0) ;; checkbox vom terminal setzen
_IEFormElementCheckBoxSelect($oForm, $var, "_chk", 1, "byValue", 0) ;; checkbox vom terminal setzen
If @error Then
    MsgBox(16, "Error", '_IEFormElementCheckBoxSelect($oForm, $var, "_chk", 1, "byValue", 0) error - ' & @error & ' - extended: ' & @extended)
EndIf

Even if not working you will get a clear view of what went wrong. Either the table will not get found or you will know why the select failed.

Edited by Seminko
Link to comment
Share on other sites

On 8/2/2019 at 7:42 PM, Seminko said:

Again, it's hard to work on a problem where I'm not able to see the "live version" of a site.

However, I have a hunch that on the live page the table you were looking for was not in fact the last table. Even if it was, if you can, always pick a specific element instead of relying on indexes which can change quite often.

Anyways, try this:

;;;ergebnis auslesen
$oTable = _IEGetObjById($oIE, "bean")
If @error Then
    MsgBox(16, "Error", '_IEGetObjById($oIE, "bean") error - ' & @error)
EndIf
$aTableData = _IETableWriteToArray ($oTable)
_ArrayDisplay($aTableData)
$var = StringStripWS($atabledata[2][1], 3)     ; <----- row 2 (offset[1]) column 4 (offset[3])  arrays are zero based
MsgBox(0, "$var", $var)

;_IEFormElementCheckBoxSelect($oForm, ClipGet(), "_chk", 1, "byIndex", 0) ;; checkbox vom terminal setzen
_IEFormElementCheckBoxSelect($oForm, $var, "_chk", 1, "byValue", 0) ;; checkbox vom terminal setzen
If @error Then
    MsgBox(16, "Error", '_IEFormElementCheckBoxSelect($oForm, $var, "_chk", 1, "byValue", 0) error - ' & @error & ' - extended: ' & @extended)
EndIf

Even if not working you will get a clear view of what went wrong. Either the table will not get found or you will know why the select failed.

Thanks i gonna try this one : )

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...