with a help from Marco Wedel (thread) I got the below script which requests data from websites in a loop until the data is loaded (due to web server issues a load ends up with no data so needs to be loaded again). Now I need to tune the script as described below.
Table 'Rates' consists of sets of data from Links. Each Link set (except the last one) should have exactly 10 records including '*increase*' string. However, due to web server issue, a load from a Link happens to return less than 10 records with the string. In such cases I need to load the data again from this very Link. The last Link set may return less than 10 records and that's ok.