Sign in to follow this  
Followers 0
MattyGibbard

Saving a word from a webpage

3 posts in this topic

Hey again guys

I have a script that looks on a webpage for "<". It works fine and says if it has found it or not. But if it finds it, I want it to save what comes after it up to a ">". Example:

The webpage contains "<Hello There>"

I want it to save just "Hello There" in a txt file.

Here is my code:

#include <GUIConstants.au3>
#include <IE.au3>

GUICreate("Title", 300, 300)


$leech = GUICtrlCreateButton ("Check",  10, 40, 100)
$exit = GUICtrlCreateButton ( "Exit",  10, 70, 100)
$id = guictrlcreateinput ( "Enter ID Here", 10,10,170)





;--------------------------------------
GUISetState ()
While 1
    $msg = GUIGetMsg()
    Select
;--------------------------------------
        
        
    ;Red X
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    ;Red X Stop
        
;--------------------------------------
            
            
        Case $msg = $leech
            $idcheck = GUIctrlread ($id)
            If $idcheck = "Enter ID Here" Then
                MSgbox (0, "Error", "You didnt enter an ID")
            Else
            Msgbox (0, "ID Check", "The ID you entered was " & $idcheck)
            
            $oIE = _IECreate()
_IENavigate($oIE, "www.websitehere.com" & $idcheck)
        $sText = _IEBodyReadText($oIE)
        If StringInStr($sText, "<") Then
Msgbox (0, "", "Found")
Else
MSGbox (0, "", "NotFound")
EndIf
            
            
            
            
            Endif

    
            
            
        Case $msg = $exit
            exit
    EndSelect
Wend

Any help would be appreciated.

Matt Gibbard

Share this post


Link to post
Share on other sites



Look for StringBetween in the help file, it returns an array so your results will be in the elements such as

$aArray = _StringBetween(sText, "<", ">")

MsgBox(0, 0, $aArray[0])

MsgBox(0, 0, $aArray[1])

MsgBox(0, 0, $aArray[2])

etc...


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Thanks! Works like a treat!

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