Input parameters can be supplied to web scraping projects and are available to all scripts within the project.
Input parameters can be used in conjunction with a project initialization script to initialize a web scraping project for a specific environment, such as setting the database connection to a test database when running in a test environment, and setting the connection to a production database when runnning in a production environment.
Specific input parameters can be defined in a web scraping project. All defined parameters can have a default value.

A parameter entry screen will appear when you run a web scraping project from the Visual Web Ripper designer if the project has any defined input parameters.

If you run a web scraping project from the command line you can supply any number of input parameters, both already defined parameters and new parameters. All the parameters will be available to scripts in the project. If you don't supply a value for a defined parameter, the default value will be used.

At this time, you cannot supply input parameters to a project that is run using the build-in scheduler.
Example 1 - Using input parameters to change the destination data sourceThis example shows how to configure a project initialization script to use input parameters to change the destination data source. The script will only change the database connection properties supplied, so if a username is not supplied for exmaple, the default username will be used.
A project initialization script is added in the project options advanced tab.

The following script checks if an input parameter exists and then sets the corresponding database connection property.
Example 2 - Setting a FixedValue content element with the value of an input parameterYou can use a simple Content Transformation script to set the content element with the value of an input parameter.
Code:using System;
using VisualWebRipper.Internal.SimpleHtmlParser;
using VisualWebRipper;
public class Script
{
public static string TransformContent(WrContentTransformationArguments args)
{
try
{
return args.InputParameters["par1"];
}
catch(Exception exp)
{
args.WriteDebug(exp.Message);
return "Custom script error";
}
}
}
Example 3 - Setting a FormField content element with the value of an input parameterYou can use a simple Input Transformation script to set FormField content element with the value of an input parameter.
Code:using System;
using VisualWebRipper.Internal.SimpleHtmlParser;
using VisualWebRipper;
public class Script
{
//See help for a definition of WrInputTransformationArguments.
public static string TransformInput(WrInputTransformationArguments args)
{
try
{
return args.InputParameters["par1"];
}
catch(Exception exp)
{
args.WriteDebug(exp.Message);
return "Custom script error";
}
}
}
Example 4 - Setting the project start URL to the value of an input parameterYou can use a simple project initialization script to set the project start URL to the value of an input parameter.
Code:using System;
using mshtml;
using VisualWebRipper;
public class Script
{
//See help for a definition of WrProjectInitializeArguments.
public static bool InitializeProject(WrProjectInitializeArguments args)
{
try
{
if(args.InputParameters.ContainsParameter("url"))
args.Project.StartUrl = args.InputParameters["url"];
return true;
}
catch(Exception exp)
{
args.WriteDebug(exp.Message);
return false;
}
}
}