Jump to content
Sign in to follow this  
darkei

Is this possible? Searching a webpage for text..

Recommended Posts

darkei

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

Share this post


Link to post
Share on other sites
TomZ

Look into INetGet (cleaner) or _INetGetSource (easier) and StringInStr.

Share this post


Link to post
Share on other sites
darkei

Look into INetGet (cleaner) or _INetGetSource (easier) and StringInStr.

Thanks muttley

I'll take a look, but I can't seem to find _INetGetSource anywhere :\

Share this post


Link to post
Share on other sites
nobbe

you could use embeded IE , too

_IENavigate($oIE, $url)
            $my_text = _IEBodyReadHTML($oIE)
                If StringInStr($my_text, "BLABLA") > 0 Then
Edited by nobbe

Share this post


Link to post
Share on other sites
darkei

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?)

Share this post


Link to post
Share on other sites
nobbe

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

Share this post


Link to post
Share on other sites
darkei

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

Share this post


Link to post
Share on other sites
nobbe

do you need a login or is it a valid link? i mean can you open it just without login in regular internet explorer or firefox`?

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.