Check webpages for text in REBOL

October 13th, 2008

A guy asked at some forum that I frequent where he can find some apps that test a list of webpages if some text exists on them. Well I don’t know for such programs but this shouted for few quick lines of REBOL so I posted them to him, and here too if I am already writing..

check: func [ url text ] [ if/else find read url text [ "ok" ] [ "OOPS!" ] ]
check-sites: func [ sites ] [ foreach site sites [ print join site/1 [ ": " check site/1 site/2 ] ] ]

so you go to rebol console and use it like this:

check-sites [ [ http://www.najdi.si "najdi.si" ] [ http://www.google.com "microsoft" ] ]

and console says:

connecting to: www.najdi.si
http://www.najdi.si : ok
connecting to: www.google.com
http://www.google.com : OOPS!

Of course this is very simple example script, but it can be a basis for adding logging, sending emails on errors, checking multiple strings per page .. whatever.

Reblog this post [with Zemanta]
Read and let read :)
  • del.icio.us
  • Reddit
  • Digg
  • DZone
  • email
  • Facebook
  • HackerNews
  • Twitter
  • StumbleUpon

Leave a Reply