Sub Wsw_MergePages($sMem, $nPageNumber, $sUrl, ByRef $sNewUrl, ByRef $sNewPostData, ByRef $bChangeBookmarkUrl, ByRef $sStatusMessage, ByRef $iStatusCode)


This function is called during a bookmark check and allows you to merge multiple pages into a single page.


Parameters


  • $sMem ... String expression. HTML source code of the last checked page. All links are provided as absolute URLs.
  • $nPageNumber ... Integer value. Number of checked pages. The value starts at 1. Helps limit the number of merged pages. WebSite-Watcher can merge up to 10 pages.
  • $sUrl ... String expression. URL of the last checked page.
  • $sNewUrl ... String expression. Return value that contains the new URL to be checked and merged with the previously checked page. The initial value is an empty string. If an empty string is returned, the merge operation is terminated.
  • $sNewPostData ... String expression. Return value that contains PostData if the page should be checked using the POST command. If this parameter is empty, the page is checked using the GET command. The default value is an empty string.
  • $bChangeBookmarkUrl ... Boolean value. Return value. The default value is FALSE. Set this variable to TRUE if the bookmark URL should be replaced with the returned value in $sNewUrl. This is useful, for example, when monitoring a forum thread and always reading the latest posts or pages. In this case, the bookmark URL is updated to the last checked page. If you monitor a search result, do not assign a value to this parameter.
  • $sStatusMessage ... String expression. Status message that is displayed in the status column. The default value is an empty string.
  • $iStatusCode ... Integer value. Returns the success status of this function.


Valid values of $iStatusCode


  • 0 ... OK. The Event function was processed successfully.
    Default value. Must not be assigned manually.
  • 1 ... Error.
    Should be returned if an error is detected. The bookmark check will be aborted.


Example:

Sub Wsw_MergePages($sMem, $nPageNumber, $sUrl, ByRef $sNewUrl, ByRef $sNewPostData, ByRef $bChangeBookmarkUrl, ByRef $sStatusMessage, ByRef $iStatusCode)
   Dim $nPageParamNumber, $sPageParam, $sNewPageParam

   ' Limit the number of merged pages
   If $nPageNumber > 3 Then
      Return
   End If

   ' Extract page number
   $sPageParam = GetFirstRegexMatch($sUrl, "\&start=\d+")
   If $sPageParam = "" Then
      ' first page, continue with page 2 (solved with start=10)
      $sNewPageParam = "&start=10"
      $sUrl = $sUrl + $sNewPageParam
   Else
      ' increase page number
      $nPageParamNumber = CInt(ExtractDigits($sPageParam)) + 10
      $sNewPageParam = "&start=" + CStr($nPageParamNumber)
      $sUrl = Replace($sUrl, $sPageParam, $sNewPageParam)
   End If

   ' check (only) via Page-Param, if the next page is already available in the page source
   If Pos($sNewPageParam, $sMem) > 0 Then
      ' the next page exists
      $sNewUrl = $sUrl
      $sStatusMessage = "Merge pages via FOLLOW-Plugin"
   End If

End Sub


See also examples Merge search result pages and Merge pages in forum thread.