Jump to content

_iebodyreadhtml Search?


Recommended Posts

im trying to search for a specific line of text in a result of _IEBodyReadHTML.. trying to figure out how to search for the text.

I have been searching the functions list on autoit website and the only thing ive come up with is WinGetText but i am unsure if this function will get text out of a variable or just out of a windows window.

Any help would be great.

Thanks in advance.

Link to comment
Share on other sites

im trying to search for a specific line of text in a result of _IEBodyReadHTML.. trying to figure out how to search for the text.

I have been searching the functions list on autoit website and the only thing ive come up with is WinGetText but i am unsure if this function will get text out of a variable or just out of a windows window.

Any help would be great.

Thanks in advance.

If you want just the text you can look at the source for _IEBodyReadHTML and create your own function that uses .innerText instead of .innerHTML

Dale

edit: typo

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

Link to comment
Share on other sites

thanks for the tip, the problem is i need the script to search for a specific string of text once it has read it and that is what i dont know how to do.

im pretty much an autoit noob :)

well i did some playing around and came up with this.

$html = _IEBodyReadText($oIE)
$var = StringInStr( $html, "the SunTrust web site will be temporarily unavailable")
;Msgbox(0,"Value of", $var)
If $var = 177 Then
    _IEQuit($oIE)
    BlockInput(0)
    MsgBox (4096, "SunTrust", "Suntrust Website Currently Down for maintenance", 20 )
    Exit
Else
EndIf

Func _IEBodyReadText($o_object)
    If IsObj($o_object.document) Then
        SetError(0)
        Return $o_object.document.body.innerText
    Else
        SetError(1)
        Return 0
    EndIf
EndFunc

prob not the best way to do it but it works. any tips for future use would be great.

thanks again dale for the text tip.

Edited by anyday
Link to comment
Share on other sites

thanks for the tip, the problem is i need the script to search for a specific string of text once it has read it and that is what i dont know how to do.

im pretty much an autoit noob :)

well i did some playing around and came up with this.

$html = _IEBodyReadText($oIE)
$var = StringInStr( $html, "the SunTrust web site will be temporarily unavailable")
;Msgbox(0,"Value of", $var)
If $var = 177 Then
    _IEQuit($oIE)
    BlockInput(0)
    MsgBox (4096, "SunTrust", "Suntrust Website Currently Down for maintenance", 20 )
    Exit
Else
EndIf

Func _IEBodyReadText($o_object)
    If IsObj($o_object.document) Then
        SetError(0)
        Return $o_object.document.body.innerText
    Else
        SetError(1)
        Return 0
    EndIf
EndFunc

prob not the best way to do it but it works. any tips for future use would be great.

thanks again dale for the text tip.

StringInStr is probably the best function to use -- as you have.

I'd be concerned about using a specific character position though as the slightest page change can break that. StringInStr will return 0 if it does not find the substring (and 0 evaluates as False, any other value to True) so you could do:

If $var Then

Also, if you are looking for a specific substring like that you shouldn't need that custom _IEBodyReadText function -- _IEBodyReadHTML should be usable just as well.

Dale

edit: typo

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

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