Sign in to follow this  
Followers 0
testmeout

_IELoadWait until table loaded?

12 posts in this topic

Well I am trying to optimize my program that pulls some info from several different text based tables from different websites. So I am just trying to figure out a way to load the page without pictures.

Does anybody know of a way?

Thanks

Share this post


Link to post
Share on other sites



This does what you are wanting.

_IEToggleImages()

Thanks,

But it doesn't seem to be speeding up the program. Do I need to _IEToggleImages(False) before every _IECreate () and _IENavigate() or does it set it globally?

Is there any other suggestion you have to speed up the web browsing.

Is there a way to do _IELoadWait ($oTable) so that it only waits long enough to grab the table?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

For the last part of your question, you can navigate to the page with $f_wait=0 and then use _IEPropertyGet($oTable, "readyState") and loop until it changes to the readyState value you want -- propbably 4, but it could be "complete".

Dale

Edit: thinking about it a second longer, you'll also need to insure that the page load has completed sufficiently that the table is defined in the DOM or you'll simply get an error or a NOMATCH response.

What I would do would be to add _IEErrorHandlerRegister() to your code so that COM errors are not fatal, then loop trying to get the table object without an error and then finally do what I suggested above.

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Here is a working example of what Dale described.

#include <IE.au3>

_IEErrorHandlerRegister()
_IEToggleImages(False)
$oIE = _IECreate("www.ebay.com", 0, 1, 0)

$oTable = 0
While Not IsObj($oTable)
    $oTable = _IETableGetCollection($oIE, 0)
    Sleep(100)
WEnd
_IEToggleImages(True)
While $oTable.readyState <> "complete"
    Sleep(100)
WEnd
_IEAction($oIE, "stop")
ConsoleWrite($oTable.innerHTML & @CR)



;===============================================================================
;
; Function Name:   _IEToggleImages
; Description::    Toggles images on/off for IE.
; Parameter(s):    $f_State - Specifies whether images are turned on (Ture) or off (False).
; Author(s):       Bob Anthony (big_daddy)
;
;===============================================================================
;
Func _IEToggleImages($f_State = True)
    If $f_State Then
        $s_Status = "yes"
    Else
        $s_Status = "no"
    EndIf
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", _
            "Display Inline Images", "REG_SZ", $s_Status)
EndFunc   ;==>_IEToggleImages

Share this post


Link to post
Share on other sites

For the last part of your question, you can navigate to the page with $f_wait=0 and then use _IEPropertyGet($oTable, "readyState") and loop until it changes to the readyState value you want -- propbably 4, but it could be "complete".

Dale

Edit: thinking about it a second longer, you'll also need to insure that the page load has completed sufficiently that the table is defined in the DOM or you'll simply get an error or a NOMATCH response.

What I would do would be to add _IEErrorHandlerRegister() to your code so that COM errors are not fatal, then loop trying to get the table object without an error and then finally do what I suggested above.

Thanks Dale,

Here is what I have but it hasn't been working for me, would you mind giving me some direction?

_IEErrorHandlerRegister()
$oIE = _IECreate ("http://www.earnings.com/earning.asp?client=cb", 0, 0, 0)
While _IETableGetCollection ($oIE, 21) = 0
Sleep(50)
WEnd
$oTable = _IETableGetCollection ($oIE, 21)
While _IEPropertyGet($oTable, "readyState") < 2
Sleep(50)
WEnd
;~ READYSTATE_UNINITIALIZED = 0
;~ READYSTATE_LOADING = 1
;~ READYSTATE_LOADED = 2
;~ READYSTATE_INTERACTIVE = 3
;~ READYSTATE_COMPLETE = 4
MsgBox(0, "ReadyState", _IEPropertyGet($oTable, "readyState"))

Here is the error I get:

IE.au3 Error from function _IEPropertyGet, $_IEStatus_InvalidObjectType

Share this post


Link to post
Share on other sites

Here is a working example of what Dale described.

#include <IE.au3>

_IEErrorHandlerRegister()
_IEToggleImages(False)
$oIE = _IECreate("www.ebay.com", 0, 1, 0)

$oTable = 0
While Not IsObj($oTable)
    $oTable = _IETableGetCollection($oIE, 0)
    Sleep(100)
WEnd
_IEToggleImages(True)
While $oTable.readyState <> "complete"
    Sleep(100)
WEnd
_IEAction($oIE, "stop")
ConsoleWrite($oTable.innerHTML & @CR)
;===============================================================================
;
; Function Name:   _IEToggleImages
; Description::    Toggles images on/off for IE.
; Parameter(s):    $f_State - Specifies whether images are turned on (Ture) or off (False).
; Author(s):       Bob Anthony (big_daddy)
;
;===============================================================================
;
Func _IEToggleImages($f_State = True)
    If $f_State Then
        $s_Status = "yes"
    Else
        $s_Status = "no"
    EndIf
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", _
            "Display Inline Images", "REG_SZ", $s_Status)
EndFunc   ;==>_IEToggleImages
Thank you so much big daddy,

It works great!!

Is there a list of what the other readystates should be?

On the MSDN article linked to in help it had the following values

READYSTATE_UNINITIALIZED = 0

READYSTATE_LOADING = 1

READYSTATE_LOADED = 2

READYSTATE_INTERACTIVE = 3

READYSTATE_COMPLETE = 4

Is there another document besides the help file that has all of the property values?

I really appreciate all the help that the autoit forum gives out that's what makes autoit so great.

Thanks agian

Share this post


Link to post
Share on other sites

The readyState will be one of the values you listed, although it can also be the text value from each string after the READYSTATE_ -- why it is not consistent I cannot tell you.

If you want more info on the various states and what they mean, search MSDN.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Is there any way to use _IENavigate() instead of _IECreate() for big daddy's example script.

It doesn't work anytime I use _IENavigate() because without waiting the previous webpage is still in memory and it is read instead of the one that is suppose to be loaded. Which messes up all my table data.

Share this post


Link to post
Share on other sites

I don't understand your question.


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

I don't understand your question.

Sorry, let me try to explain agian.

Using big daddy's example it will not work using _IENavigate() instead of _IECreate() for instance:

#include <IE.au3>
_IEErrorHandlerRegister()
$oIE = _IECreate("www.ebay.com",0,1,0)
$oTable = 0
While Not IsObj($oTable)
    $oTable = _IETableGetCollection($oIE, 0)
    Sleep(100)
WEnd
While $oTable.readyState <> "complete"
    Sleep(100)
WEnd
_IEAction($oIE, "stop")
ConsoleWrite($oTable.innerHTML & @CR)

_IENavigate($oIE, "www.google.com",0)
$oTable = 0
While Not IsObj($oTable)
    $oTable = _IETableGetCollection($oIE, 0)
    Sleep(100)
WEnd
While $oTable.readyState <> "complete"
    Sleep(100)
WEnd
_IEAction($oIE, "stop")
ConsoleWrite($oTable.innerHTML & @CR)

In this example, instead of pulling the data from google it pulls it agian from ebay, which is not what it should do.

I could just use IECreate agian and try to attach, I know that works but I figured that _IENavigate() would make the script faster.

Whats the best way to do this?

Share this post


Link to post
Share on other sites

Add the following just before navigating to the next page.

_IENavigate($oIE, "about:blank")

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  
Followers 0