Sign in to follow this  
Followers 0
gritts

Use _IETableGetCollection against local files

6 posts in this topic

I was wondering if there is some way to process a local copy (on hard drive) copy of an html file that contain tables with _IETableGetCollection ? I've found that by retrieving a table from a website with _IECreate on a frequent basis seems to prevent my screen saver from enabling. I'd like to use _INETGetSource and then process the downloaded file with _IETableGetCollection or similar means.

Any suggestions?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Glancing at the help file I see that the _IETableGetCollection function requires an IE object to be passed in as the first parameter, so you're not going to be able to use that without first calling _IECreate. It is certainly possible to write code to parse the HTML without the use of the IE functions, but personally I'd rather deal with the IE UDF than reinvent the wheel.

I would suggest using _IECreate and just holding onto the window object for the duration of the script. Throw it an _IENavigate when you need to refresh.

From some quick testing, I can't seem to get either _IECreate or _IENavigate to have any effect on the system idle time. Is there perhaps something else in the script sending keystrokes or mouse movement?

Idle Time Test Script:

#include <IE.au3>
#Include <Timers.au3>

$oIE = _IECreate ("www.autoitscript.com",0,1,1,0)

For $i = 0 To 10
    
    _IENavigate($oIE, "www.autoitscript.com")
    Sleep(2000)
    ConsoleWrite("idle for: " & _Timer_GetIdleTime() & @CRLF)
    
Next

_IEQuit($oIE)
Edited by bwochinski

Share this post


Link to post
Share on other sites

Glancing at the help file I see that the _IETableGetCollection function requires an IE object to be passed in as the first parameter, so you're not going to be able to use that without first calling _IECreate. It is certainly possible to write code to parse the HTML without the use of the IE functions, but personally I'd rather deal with the IE UDF than reinvent the wheel.

I would suggest using _IECreate and just holding onto the window object for the duration of the script. Throw it an _IENavigate when you need to refresh.

From some quick testing, I can't seem to get either _IECreate or _IENavigate to have any effect on the system idle time. Is there perhaps something else in the script sending keystrokes or mouse movement?

Idle Time Test Script:

#include <IE.au3>
#Include <Timers.au3>

$oIE = _IECreate ("www.autoitscript.com",0,1,1,0)

For $i = 0 To 10
    
    _IENavigate($oIE, "www.autoitscript.com")
    Sleep(2000)
    ConsoleWrite("idle for: " & _Timer_GetIdleTime() & @CRLF)
    
Next

_IEQuit($oIE)

Thank you for the reply. Yes there is this..

If WinExists("Internet Explorer") Then
        ControlClick("Internet Explorer", "", "Button2")
    EndIf

Which I use to get rid of the "Make IE your default" window prompt. I prefer Firefox. I haven't researched it yet but perhaps there is a way to not be prompted to change the default. Your question has made me think that might be an option. I like the idea of keeping the session open. I'll tweak my script and see how that works out. I am running IE hidden as well. Here's a snip of my code...

$oIE = _IECreate("http://192.168.1.254/xslt?PAGE=C_2_0", 0, 0, 1, 0)
    If WinExists("Internet Explorer") Then
        ControlClick("Internet Explorer", "", "Button2")
    EndIf
    $oTable = _IETableGetCollection($oIE, 4)
    $aTableData = _IETableWriteToArray($oTable)

...parsing of data in array here...

    _IEQuit($oIE)
    Sleep(60000) ;Sleep till next interval

The code is in a function whose call is in a While...Wend loop (might be sloppy but works for what I am looking for. If you think you need more of my code, let me know. I figured the main IE function would suffice. The rest is calculation and placing array values in variables.

Share this post


Link to post
Share on other sites

Which I use to get rid of the "Make IE your default" window prompt. I prefer Firefox. I haven't researched it yet but perhaps there is a way to not be prompted to change the default.

Tools menu > Internet options... > "Programs" tab

- Uncheck the "tell me if internet explorer is not the default web browser" option

(on IE8 anyways)

As for your code, looks fine to me as long as it does the job. :)

I'd imagine that click was actually the thing resetting the idle timer, so hopefully that's solved.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

You can start an instance of IE to use as a rendering engine and then read your files from disk and write them in turn to the IE instance.

$oIE = _IECreate()

[start loop]

$sHTML = [read contents of file]

_IEDocWriteHTML($oIE, $sHTML)

[process the tables]

[loop back and do it again]

Dale

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

I disabled the "Prompt if IE is not default" option. I had forgotten about it.

I also left the browser session open and used the IE navigation refresh to update the page. This has been working fine. I'm now further tweaking my script for neatness and added functionality.

In case you are curious, this script is to parse the data from my internet gateway in the hope to learn just how much data I am pulling. I have a suspicion that I will exceed the cap my ISP intends to impose and I want to see what I am doing with my normal daily usage.

Thank you for your input!

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