Search for text on a website

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
gilly
Newbie
Posts: 1
Joined: Sun Mar 01, 2009 6:39 am

Search for text on a website

Post by gilly » Tue Feb 22, 2011 6:17 am

Hello, its been a while since I ve made any scripts so just need a few tips in the right direction. Was wondering if I can do the following.

1. Search a website for specific text present
2 if the text if present on the page. >> Return a variable ( if needed) that will allow further steps to be taken with that text.
3. if not present just time loop.

Its the text search and return if that I m stuck on.

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Feb 22, 2011 7:12 am

With WebRecorder you can use the ContainsText function to do this.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Tue Feb 22, 2011 12:35 pm

Here is a simple example to get you started which uses the HTTPRequest> command and simple parsing techniques.

Code: Select all

// Show the results of a parsed webpage inside a Dialog

Dialog>Dialog1
   Caption=Dialog1
   Width=403
   Height=301
   Top=150
   Left=31
   Edit=msEdit1,80,40,81,
   Label=ZipCode,24,40,true
   Button=Go,232,40,75,25,3
   Memo=msMemo1,40,96,273,113,
   Label=Get Weather Info,64,8,true
EndDialog>Dialog1


Show>Dialog1

Label>MainLoop
   GetDialogAction>Dialog1,result
   If>result=2,End
   If>result=3,GetWeather
   Wait>0.01
Goto>MainLoop

SRT>GetWeather
   Let>zip_code=Dialog1.msEdit1
   Let>URL=http://www.briansutton.com/wx/weather.html?id=%zip_code%&length=10&unit=s&#current
   HTTPRequest>URL,,GET,,HTMLResponse

   Let>String1=<td width="41%" height="24" align="center" valign="top">
   Let>String2=</td>

   Length>String1,String1_length

   Position>String1,HTMLResponse,1,StartAt
   Add>StartAt,String1_length
   Position>String2,HTMLResponse,StartAt,EndAt,FALSE

   Let>myLen=EndAt-StartAt

   MidSTr>HTMLResponse,StartAt,myLen,myWeather
   Let>Dialog1.msMemo1=The current weather for zipcode %zip_code% is %CRLF%%CRLF%%myWeather%
   ResetDialogAction>Dialog1
END>GetWeather

Label>End


Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts