Create a variable running = true ( bool)
Then start while loop with that runing variable
Then set the running variable To ( Your desired number ! = number from site)
Inside the while loop not outside of it
Статьи, которые могут помочь:
http://wiki.bablosoft.com/doku.php?id=ru:functions
http://wiki.bablosoft.com/doku.php?id=ru:how_to_solve_captcha
http://wiki.bablosoft.com/doku.php?id=ru:how_to_check_if_page_element_exists