Jump to content
Sign in to follow this  
Zeotrope

IETagNameGetCollection overcharged?

Recommended Posts

Hello Guys,

 

At the moment im working on a internet - Bot.

He should do this:

 

While 1


            _IELoadWait( $create, 1000)

            $bannerfind = _IETagNameGetCollection($create, "span")
            _IELoadWait( $create, 100)
            For $banner In $bannerfind
            If String($banner.id) = "banner" Then
            $getbanner = String($banner.innerText)
            EndIf
            Next


            GUICtrlSetData( $labellast1, $getbanner)


            $get = ""
            _IELoadWait( $create, 1000)

            $chat = _IETagNameGetCollection($create, "div")
            _IELoadWait( $create, 100)
            For $reload In $chat
            IF String($reload.outerTExt) = "Connection Lost..." Then
            $get = String($reload.outerText)
            EndIf
            Next
            If String($get) == "Connection lost..." Then
            _IEAction($create, "refresh")
            EndIf


        WEnd

 

But after 50 Seconds and without the Loadwaits after 6 Seconds he comes with the error:

 

Quote

IE.au3" (1811) : ==> The requested action with this object has failed.:
Return SetError($_IESTATUS_Success, $oTemp.GetElementsByTagName($sTagName).length, $oTemp.GetElementsByTagName($sTagName))
Return SetError($_IESTATUS_Success, $oTemp^ ERROR

 

Is he overloaded? What can i do to fix this?

 

Thank you

 

 

 

Share this post


Link to post
Share on other sites
14 minutes ago, MichaelHB said:

If all you need from the website is information in the html, why not use _IEDocReadHTML ? It would be fast to work with the string.

I don't want to read every line of html code, just specific string and if this string appears then he sell do something else

Share this post


Link to post
Share on other sites

Please do it a test. If information is all you need from the html is faster this way.

Just test it, i don't know how many elements the "$chat = _IETagNameGetCollection($create, "div")", but why loop through each element if you can easly get the information you want with 1-2 line code ?

Share this post


Link to post
Share on other sites
27 minutes ago, MichaelHB said:

Please do it a test. If information is all you need from the html is faster this way.

Just test it, i don't know how many elements the "$chat = _IETagNameGetCollection($create, "div")", but why loop through each element if you can easly get the information you want with 1-2 line code ?

But how can i then search for a specific String like in the code:

Connection Lost...

And do an action then?

Share this post


Link to post
Share on other sites

Like this:

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

Local $oIE = _IECreate("https://www.autoitscript.com/forum/topic/181589-ietagnamegetcollection-overcharged/")
Local $sHTML = _IEDocReadHTML($oIE)
Sleep(15000) ;make sure the website is completely loaded

Local $Text_inside_element = StringRegExp($sHTML, '(?i)<meta content="(.*?)" property="og:title">', 3) ;global
_ArrayDisplay($Text_inside_element) ;results inside array

if isarray($Text_inside_element) then MsgBox(0, "", $Text_inside_element[0])

Exit

In this example you are getting the data inside a tag "meta". Read about the StringRegExp and you will understand how to grab that the data you want.

Share this post


Link to post
Share on other sites

Thats nice didnt know that.

15 Seconds quite long, i want to check like every 1-2 seconds, because the text is dynamic and if some specific textappear then he shell do something.

But the specific Text only appears for ~ 1-2 seconds, 15 seconds would be to long.

Does it work with 1-2 seconds aswell?

Share this post


Link to post
Share on other sites

Do you use COM Error handler ?
Read and use this: How to use IE.au3  UDF with  AutoIt v3.3.14.x  

And post here your example code and also SciTE console output.

 


In IE inspect this item:
 

IF String($reload.outerTExt) = "Connection Lost..." Then

and post here Html snippet for this object.

 

EDIT:

I suppose that this:

3 hours ago, Zeotrope said:

Is he overloaded? What can i do to fix this?

is related to the lack of COM Error Handler

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
Include Dependency Tree (Tool for analyzing script relations)
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

PDF Related:https://www.autoitscript.com/forum/topic/177368-how-to-get-reference-to-pdf-object-embeded-in-ie/ *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2020-09-20

Share this post


Link to post
Share on other sites

 

23 hours ago, MichaelHB said:

Like this:

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

Local $oIE = _IECreate("https://www.autoitscript.com/forum/topic/181589-ietagnamegetcollection-overcharged/")
Local $sHTML = _IEDocReadHTML($oIE)
Sleep(15000) ;make sure the website is completely loaded

Local $Text_inside_element = StringRegExp($sHTML, '(?i)<meta content="(.*?)" property="og:title">', 3) ;global
_ArrayDisplay($Text_inside_element) ;results inside array

if isarray($Text_inside_element) then MsgBox(0, "", $Text_inside_element[0])

Exit

In this example you are getting the data inside a tag "meta". Read about the StringRegExp and you will understand how to grab that the data you want.

 

This works for me thanks! For the standard non-dynamic html it works, but if i have this:

Local $oIE = _IECreate("csgodouble.com")
                Local $sHTML = _IEDocReadHTML($oIE)
                Sleep(4000) ;make sure the website is completely loaded

                Local $Text_inside_element = StringRegExp($sHTML, '<span id="banner">(.*?)</span>', 3) ;global

                _ArrayDisplay($Text_inside_element) ;results inside array

                if IsArray($Text_inside_element) then MsgBox(0, "", $Text_inside_element[0])

It returns an empty field, the content in the bracket >< changes every few milliseconds, he doesnt show me the text, what can i do here? I tried some other Characters like ++ but it didnt work

 

 

22 hours ago, mLipok said:

Do you use COM Error handler ?
Read and use this: How to use IE.au3  UDF with  AutoIt v3.3.14.x  

And post here your example code and also SciTE console output.

 


In IE inspect this item:
 

IF String($reload.outerTExt) = "Connection Lost..." Then

and post here Html snippet for this object.

 

EDIT:

I suppose that this:

is related to the lack of COM Error Handler

 

My Code:

Global $create = _IECreate("www.csgodouble.com", 1, 1, 10 )

        While 1


            $get = ""
            _IELoadWait( $create)

            $chat = _IETagNameGetCollection($create, "div")
            _IELoadWait( $create, 100)
            For $reload In $chat
            IF String($reload.outerTExt) = "Connection Lost..." Then
            $get = String($reload.outerText)
            EndIf
            Next
            If String($get) == "Connection lost..." Then
            _IEAction($create, "refresh")
            EndIf
            
            
            _IELoadWait( $create, 100)
             $getobj = ""
             $getobj = _IEGetObjById( $create, "banner")

        

            GUICtrlSetData( $labellast1, $getobj.outerText)


            If String( $getobj.outerText ) == "***ROLLING***" Then

                Sleep(8000)
                $amounts = _IETagNameGetCollection($create, "input")
            For $amount In $amounts
            If String($amount.id) = "betAmount" Then
            _IEAction($amount, "focus")
            $amount.value = 100
            EndIf
            Next

            $oLinks = _IETagNameGetCollection($create, "button")
            For $oLink In $oLinks
            If String($oLink.outerText) = "0" Then
            _IEAction($oLink, "click")

            EndIf
            Next

            EndIf

            $get = ""
            _IELoadWait( $create)

            $chat = _IETagNameGetCollection($create, "div")
            _IELoadWait( $create, 100)
            For $reload In $chat
            IF String($reload.outerTExt) = "Connection Lost..." Then
            $get = String($reload.outerText)
            EndIf
            Next
            If String($get) == "Connection lost..." Then
            _IEAction($create, "refresh")
            EndIf


WEnd

 

It works some seconds but then it terminates itself by giving:

Quote

IE.au3" (1811) : ==> The requested action with this object has failed.:
Return SetError($_IESTATUS_Success, $oTemp.GetElementsByTagName($sTagName).length, $oTemp.GetElementsByTagName($sTagName))
Return SetError($_IESTATUS_Success, $oTemp^ ERROR

=(

 

Edited by Zeotrope
Missing Text

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By learner123
      Hi All,
       
      I am new to this AUTO IT and I have created a script that will open an app,enter pin and copy the code generated to clipboard. My java code call this autoIT script and use the copied generated code from clipboard.
      This works fine when server  window is on focus. My server is an windows server. 
      But when I minimize or disconnect the server, the script opens the app.exe but doesn't copy any value to clipboard.  
      Can anyone help me on this 😐
       
      Run("C:\Program Files (x86)\RSA SecurID Software Token\SecurID.exe")
      Local $hWnd=WinWait("abc - RSA SecurID Token") ; waits until the window is the active window
      $hWin = WinGetHandle("abc - RSA SecurID Token");
      ControlSend($hWnd,"","","1111") ; simulates pressing the Home key
      ControlSend($hWnd,"","","{ENTER}");
      ControlSend($hWnd,"","","^c");
      Sleep(1000) ;
      ControlSend($hWnd,"","","^c");
       
    • By learner123
      Hi All,
      So I have created a small autoIT script to enter pin into a RSA token(app which generate new code every 30 second), and copy the generated code.
      I have a java application which requires this code so every time my java-code requires this RSA code, it runs the autoIT script and the copied generated code is then used in my java application. 
      I have deployed this code on a windows server and it works fine when I am logged in and the window is on focus, But as soon as I schedule task and disconnect the server (not logged out only disconnect), or even minimize the server window, the autoIT scripts fails and its not able to copy the value.
       
      Please find below the code for AUTOIT.
       
      WinActivate("rsa - RSA SecurID Token") ; activates the window that has old in the tilte bar
      WinWaitActive("rsa - RSA SecurID Token") ; waits until the window is the active window
      Send("1111") ; simulates pressing the Home key, enters password to get the code
      Send("{ENTER}") ; simulates pressing the Enter key
      Sleep(1000) ;
      Send("^c") ; simulates pressing the CTRL+c keys (copy)
       
      Also I saw some post regarding that WINACTIVE only works when window is active. But my below AUTO IT script to handle windows pop up  works perfectly fine when the server is disconnected. 
       
      Opt("WinTitleMatchMode", 1)
      WinWait("https://url","","10")
      WinWaitActive("https://url","","10")
      Sleep(2000)
      Send("userid")
      Sleep(1000)
      Send("{TAB}")
      Sleep(1000)
      Send("passwrd")
      Send("{TAB}")
      Sleep(500)
      Send("{ENTER}")
       
       
    • By JuanFelipe
      Hello gyus, I try to make a code to login in a web page in my job, buy i can’t understand why my form is blocked, this is my code: 
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <StringConstants.au3> #include <WindowsConstants.au3> #include <WinAPIFiles.au3> #include <FileConstants.au3> #include <File.au3> #include <Array.au3> #include <IE.au3> #include <Excel.au3> #include <GuiEdit.au3> #include <GuiStatusBar.au3> #include <DateTimeConstants.au3> #include <Date.au3> #Region ### START Koda GUI section ### Form=C:\noentry\koda_1.7.3.0\Forms\spoa.kxf $Form1 = GUICreate("Eva y Vehículos", 1200, 1000, 10, 10) $prueba = GUICtrlCreateButton("Prueba",10,990,50,20) ;VARIABLES ========================================================================================== $psi = "https://psi.policia.gov.co/PSI/Login.aspx?ReturnUrl=%2fPSI#no-back-button" $chequeVehiculos = "https://psi.policia.gov.co/PSI/frm_lista_chk.aspx" $evaluacionEva = "https://psi.policia.gov.co/PSI/eva_frmver.aspx" $oIE = ObjCreate("Shell.Explorer.2") $GUIActiveX = GUICtrlCreateObj ($oIE, 10, 10, 1180, 980) ;GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW) $oIE.navigate($psi) ;_IELoadWait($oIE) _InicioSesion() #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $prueba _InicioSesion() EndSwitch WEnd Func _InicioSesion() Local $username = _IEGetObjByName($oIE, "txtUsuario") Local $pass = _IEGetObjByName($oIE, "txtClave") Local $logina = _IEGetObjByName($oIE, "btnIngresar") $username.value="example" $pass.value="examplepass" _IEAction($logina, 'click') _IELoadWait($oIE) MsgBox(16,"","") EndFunc  
    • By shelly
      Here is the below code for handling pop-up when window is  inactive ..but I don't know how to change sleep and when i run this script it runs sometimes and sometimes it stops .
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{SPACE}")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{DOWN}")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{ENTER}")
      --- these 3 lines never worked while TAB lines works sometimes but not in accurate way
      I am new too AutoIt .. help me out why this script behaves in strange way
      ControlFocus("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1")
      Sleep(3000)
      ControlSend("Policy Decisions -- Webpage Dialog", "", "Internet Explorer_Server1","1")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      ControlSend("Policy Decisions -- Webpage Dialog", "", "Internet Explorer_Server1","the request is send")
      Sleep(3000)
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      Sleep(3000)
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      Sleep(3000)
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{SPACE}")
      Sleep(3000)
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      Sleep(3000)
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      Sleep(3000)
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{DOWN}")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      Sleep(3000)
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{TAB}")
      ControlSend("Policy Decisions -- Webpage Dialog","","Internet Explorer_Server1","{ENTER}")
       
×
×
  • Create New...