Visual Web Ripper Logo Visual Web Ripper Logo

Highlighted features

Condition script example

added: 2/10/2010 Version: 2.31.0

This article deals with an unusual requirement to only extract data from the last web page in a search result.

I'll setup a project that uses a page area template to extract data from each page in a search result, but I'll cancel the page area template if it is not on the last page.

In order to cancel the page area template I add a condition script to the template. The condition script checks if there is a next page link on the web page and cancels the template element if the next page link is found. The last web page will not have a next page link, so the template will not get cancelled on the last web page.
 
  1. using System;   
  2. using mshtml;   
  3. using VisualWebRipper;   
  4. public class Script   
  5. {   
  6.     //See help for a definition of WrConditionArguments.   
  7.     public static bool IsCondition(WrConditionArguments args)   
  8.     {   
  9.         try  
  10.         {   
  11.             if(args.DataRow["navigationLink"] != "")   
  12.                 return false;   
  13.             return true;   
  14.         }   
  15.         catch(Exception exp)   
  16.         {   
  17.             args.WriteDebug(exp.Message);   
  18.             return true;   
  19.         }   
  20.     }   
  21. }  
 
You'll see the script uses the data column "navigationLink". I have added a content element that selects the next page link and reset the "Save content" option so the content doesn't appear in the output data. The content is still available during processing, so I can check if the element exists by checking the corresponding data column.

Download sample project and data extract Yellowpages.zip

Comments

  Required Field - required field
Comment Required Field
Attachement
Loading...
Add
  • Very user friendly visual project designer.
  • Extract complete data structures, such as product catalogues.
  • Repeatedly submit forms for all possible input values.
  • Extract data from highly dynamic web sites including AJAX web sites.
  • Web data extraction scheduler with email notifications and logging.
  • Custom post-processing and comprehensive API.
  • Only $299 including 1 year maintenance.

© 2009-2010 Sequentum  |  Terms & Conditions  |  Privacy Statement  |  Login