Jump to content
Sign in to follow this  
cmattb

Read entire line?

Recommended Posts

cmattb

So I need to search a webpage for a auto-install program im working on. Right now, its simply searching the page using StringinStr. What I need it to do is search the page for a variable, then keep reading the rest of the line to get the quantity

Sample of Web page:

Antec NSK2400 Black/Silver MicroATX Desktop 380W | 1

Seagate Barracuda 7200.10 250GB SATAII | 1

Gigabyte GeForce 7300GS 256MB Silent | 1

Asus 18x DVD-RW Lightscribe (black) | 1

MSI Theatre 550 Pro TV Tuner PCI | 1

a bit of the code im currently using:

$oIE = _IECreate ("WEBPAGE, 0,0,0,0);Checks invoice to find part data

WinWait("Simple Invoice - Windows Internet Explorer", "")
$orderdata = _IEBodyReadText ($oIE)
_IEQuit ($oIE)

        
    If StringInStr($orderdata, "GeForce 8500") or StringInStr($orderdata, "GeForce 8600") Then 
        GUICtrlCreateLabel("NVidia 8500/8600 detected", 10, $ltop)
        $ltop += 20
    
    ElseIf StringInStr($orderdata, "GeForce 8800") Then 
        GUICtrlCreateLabel("NVidia 8800 detected", 10, $ltop)
        $ltop += 20
    
    ElseIf StringInStr($orderdata, "GeForce 7") or StringInStr($orderdata, "GeForce 6")  Then 
        GUICtrlCreateLabel("NVidia 6200/7950 detected", 10, $ltop)
        $ltop += 20
    Else
        GUICtrlCreateLabel("Unknown video card", 10, $ltop)
        $ltop += 20
    EndIf   
    If StringInStr($orderdata, "Creative X-Fi") Then 
        GUICtrlCreateLabel("Creative X-Fi detected", 10, $ltop)
        $ltop += 20
    Endif
        If StringInStr($orderdata, "Plextor 16x DVD-RW Dual Layer Slot-loading") Then 
        GUICtrlCreateLabel("Plextor 16x Slot-Load detected", 10, $ltop)
        $ltop += 20
    Endif
    If StringInStr($orderdata, "AVG") Then
        GUICtrlCreateLabel("AVG detected", 10, $ltop)
        $ltop += 20
    Endif

Im thinking that this would be easier if I tuned the webpage into an array that seperates by line and by | , but i have no clue how to even get that going.

Thanks

Share this post


Link to post
Share on other sites
Valuater

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>

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

$oIE = _IECreate ()

;------------- User input --------------
_IENavigate ($oIE, "http://www.autoitscript.com/") ; web address
$Find = "LZ" ; my info shows after this line... or just find this line
$Before = "comp"    ; my info shows before this line... or set as ""
; ------------ End User input -------------
Sleep(1000)
$body =  _IEBodyReadHTML ($oIE)
$sloc = @TempDir & "\stest.txt"
FileDelete($sloc)
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   ")
        FileClose($sfile)
        Exit
    EndIf
    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 & "    ", 5)
        ExitLoop
    EndIf
WEnd

Func stringbetween($str, $start, $end)
    $pos = StringInStr($str, $start)
    If Not @error Then
        $str = StringTrimLeft($str, $pos + StringLen($start) - 1)
        $pos = StringInStr($str, $end)
        If Not @error Then
            $str = StringTrimRight($str, StringLen($str) - $pos + 1)
            Return $str
        EndIf
    EndIf
EndFunc   ;==>stringbetween

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

8)


NEWHeader1.png

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  

×