checkAvailability

Checks the availability of the specified page. Terminates performing of the task, if the page was unavailable.

Syntax

checkAvailability = function(aPage, aExpectedIP, aIncludedText, aUserAgent);
checkAvailability = function(aCheckItems);

Parameters

  • aPage
    • functions: verified page
  • aExpectedIP
    • functions: supposed IP host on which the page is situated
  • aIncludedText
    • functions: text contained in the source code of the checked page
  • aUserAgent
    • functions: User-agent, which will be specified when loading the source code of the checked page
  • aCheckItem
    • functions: record containing the information required to verify the page
  • aCheckItems
    • functions: array of records to check multiple pages

Notes

  • To test the page goes through the following algorithm:
    1. verified the availability of the host on which the page is situated. If the host is available, then
    2. if IP host coincides with aExpectedIP or aExpectedIP and equals '0 .0.0.0 ', then
    3. if aIncludedText not empty, the source code of the page is loaded using aUserAgent (redirects are not supported!). If aUserAgent empty, then used User-agent, installed for your browser. If the source code of the page contains aIncludedText or aIncludedText - empty string, then
    4. test passes, the script continues to execute
  • If the test fails, the script will stop execution
  • The procedure may be performed only once, and only being the first method that performed by a script. If there were performed other methods before, the software will ignore CheckAvailability.
  • If you check the array pages, will be checked only the first five elements of array

Examples

  1. checkAvailability('habrahabr.ru');
  2. checkAvailability('habrahabr.ru', '178.248.233.33');
  3. checkAvailability('habrahabr.ru', '178.248.233.33', 'habr');
  4. checkAvailability([
      {"page":"habrahabr.ru","expectedIP":"178.248.233.33","includedTextt":"habr"},
      {"page":"liveinternet.ru","includedText":"stat","userAgent":"my ua"}
    ]);