Jump to content

Is this possible? Searching a webpage for text..


Recommended Posts

Hey, I'm new(ish) to AutoIt, and I was wondering, is it possible to make a program that will check a website for a certain text string and return true or false if it's there or not? Without opening a new browser window..

I know it can be done in other languages, but I have no idea about AutoIt, which is why I'm asking before trying and becoming disappointed ;p

Thanks for any answer you can give me muttley

~Darkei

Link to comment
Share on other sites

you could use embeded IE , too

_IENavigate($oIE, $url)
            $my_text = _IEBodyReadHTML($oIE)
                If StringInStr($my_text, "BLABLA") > 0 Then
Edited by nobbe
Link to comment
Share on other sites

you could use embeded IE , too

_IENavigate($oIE, $url)
            $my_text = _IEBodyReadHTML($oIE)
                If StringInStr($my_text, "BLABLA") > 0 Then
Okay thanks, I'll explain further what I'm wanting to do if it helps.

I want to have a GUI with a text box, and a "Submit" button that, when pressed, will check a certain webpage for the text string entered in that textbox.

I then want it to show a popup box for true/false.

What would you say is best to do that with? (If it's still possible?)

Link to comment
Share on other sites

try this

change to where you want to browse

$url="http://www.google.com";

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


Global $oIE = _IECreateEmbedded ()

#Region ### START Koda GUI section ### Form=
$Browser = GUICreate("Browser", 650, 450, 185, 145)

$GUIActiveX1 = GUICtrlCreateObj($oIE, 25, 50, 600, 160); or use 0,0,0,0 to make "invisible"

$First_Link_Input = GUICtrlCreateInput("", 48, 24, 225, 21)
$Surf1_Button = GUICtrlCreateButton("find", 538, 24, 80, 21, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$url="http://www.google.com";

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Surf1_Button
            
                _IENavigate ($oIE, $url); navigate 
        $my_text = _IEBodyReadHTML($oIE)
                
                $search = GUICtrlRead ($First_Link_Input)
                If StringInStr($my_text, $search) > 0 Then
                msgBox(0,"FOUND","FOUND " & $search);
                else
                msgBox(0,"no match","not FOUND " & $search);
                endif 
                
                
    EndSelect
WEnd



GUIDelete()
exit
Link to comment
Share on other sites

try this

change to where you want to browse

$url="http://www.google.com";

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


Global $oIE = _IECreateEmbedded ()

#Region ### START Koda GUI section ### Form=
$Browser = GUICreate("Browser", 650, 450, 185, 145)

$GUIActiveX1 = GUICtrlCreateObj($oIE, 25, 50, 600, 160); or use 0,0,0,0 to make "invisible"

$First_Link_Input = GUICtrlCreateInput("", 48, 24, 225, 21)
$Surf1_Button = GUICtrlCreateButton("find", 538, 24, 80, 21, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$url="http://www.google.com";

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Surf1_Button
            
                _IENavigate ($oIE, $url); navigate 
        $my_text = _IEBodyReadHTML($oIE)
                
                $search = GUICtrlRead ($First_Link_Input)
                If StringInStr($my_text, $search) > 0 Then
                msgBox(0,"FOUND","FOUND " & $search);
                else
                msgBox(0,"no match","not FOUND " & $search);
                endif 
                
                
    EndSelect
WEnd



GUIDelete()
exit

I <3 you.

(in a non-gay-thanks-for-helping type way muttley)

Will post if any further problems :)

Edited by darkei
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...