Jump to content
Sign in to follow this  

Searching for a line in Internet Explorer <body>?

Recommended Posts



I hope to get some sort of direction of you people that knows this better, so i hope you will have the possibility to point me in the right direction here.

I get a webpage displayed in IE, it contains some random text , its like an invoice. What I need to do is to find a line that will look something like this:

somename 1000


somename (1000)

it does contain alot of spaces between the name and number. (that isnt showing here in this forum post)

what i need to do is to lokate this specific name and then find out what number it is and if it is surrounded of the () or not.

I have found the _IEBodyReadText so i get all of the body of the document. Is that the right way to begin? Can i put that info in a variable and search that somehow or do i need to put that in a textfile and then use filereadline ?

The "somename" im searching for in the document is know, the spaces and the size of the number varies.

Any ides maybe on how to deal with this the best way??

Best Regards


Edited by kungperra

Share this post

Link to post
Share on other sites

From Welcome to Autoit 1-2-3

; demonstration to find chracters that change between to standard points
; or just find a string
#include <IE.au3>
#include <String.au3>

#Region --- IE-Builder generated code Start ---

$oIE = _IECreate()

;------------- User input --------------
_IENavigate($oIE, "http://www.autoitscript.com/") ; web address
$Find = "Welcome to the "  ; my info shows after this line... or just find this line
$Before = "- the home "     ; my info shows before this line... or set as ""
; ------------ End User input -------------
$body = _IEBodyReadHTML($oIE)
$sloc = @TempDir & "\stest.txt" 
FileWrite($sloc, $body)
$sfile = FileOpen($sloc, 0)
$num = 0
While 2
    $num = $num + 1
    $sline = FileReadLine($sfile, $num)
    If @error Then
        MsgBox(262208, "Fail", "The string was NOT found   ")
    If StringInStr($sline, $Find) Then
        MsgBox(64, "Success", "The string " & $Find & " was found    " & @CRLF & " on line # " & $num, 5)
        If $Before = "" Then ExitLoop
        $Found = _StringBetween($sline, $Find, $Before)
        MsgBox(64, "Found", "The string is *" & $Found[0] & "*    ", 5)

#EndRegion --- IE-Builder generated code End ---



Share this post

Link to post
Share on other sites

Thank you! I will have a look at this, seems to be the beginning on what i need!


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