Jump to content

Recommended Posts

Posted

So I've got some code together that grabs the text from an already existing webpage. The problem I'm having is that sometimes the page refreshes, and I end up with this error:

C:\Program Files (x86)\AutoIt3\Include\IE.au3 (1964) : ==> Variable must be of type "Object".:
Return SetError($_IEStatus_Success, 0, $o_object.document.body.innerText)
Return SetError($_IEStatus_Success, 0, $o_object.document.body^ ERROR
->12:16:25 AutoIT3.exe ended.rc:1

The code simply is:

$oIE = _IEAttach ($sURL, "URL")
        $sBody = _IEBodyReadText ($oIE)

The attach happens fine, but the ReadText fails. And I guess since its failing inside the IE.au3 script, none of my error checking seems to be working. Suggestions on what Im doing wrong?

Posted

Do you really need the ie?

If you just need to get the source of the webpage you can use:

$dom = InetRead("URL", 1) ; 1 ~ Force reload of the webpage.

Posted

Do you really need the ie?

If you just need to get the source of the webpage you can use:

$dom = InetRead("URL", 1) ; 1 ~ Force reload of the webpage.

Yes, I need to use the IE window already loaded on the machine. :)
Posted (edited)

Yes, I need to use the IE window already loaded on the machine. :)

You could try checking if $oIE is an object before reading anything from it.

Dunno if it helps, but its probably worth a shot.

$oIE = _IEAttach ($sURL, "URL")

If IsObj($oIE) Then

$sBody = _IEBodyReadText ($oIE)

EndIf

EDIT: That wouldn't help at all -__-

try this:

If IsObj($oIE.document.body) Then

$sBody = _IEBodyReadText ($oIE)

EndIf

Edited by Miniz
Posted

You could try checking if $oIE is an object before reading anything from it.

Dunno if it helps, but its probably worth a shot.

$oIE = _IEAttach ($sURL, "URL")

If IsObj($oIE) Then

$sBody = _IEBodyReadText ($oIE)

EndIf

EDIT: That wouldn't help at all -__-

try this:

If IsObj($oIE.document.body) Then

$sBody = _IEBodyReadText ($oIE)

EndIf

The problem is that the Attach works fine, if the page refreshes while its actually reading the text tho - things blow up.
Posted

Add _IELoadWait($oIE) before your _IEBodyReadText to insure the refresh has completed prior.

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

Posted

Add _IELoadWait($oIE) before your _IEBodyReadText to insure the refresh has completed prior.

Dale

I totally missed that option. I think that resolved it. Thank you!!!
Posted

The problem is that the Attach works fine, if the page refreshes while its actually reading the text tho - things blow up.

Thats caused by that "body" isn't a object while refreshing the page. Because it's not loaded yet.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...