Loadrunder Script-associative array (parameter array)

Source: Internet
Author: User
Tags array length ord

Introduction

Previously said can be associated with the server to remove some of the dynamic changes in the information, the previous also mentioned in Web_reg_save_param can be set Ord=all, represents a list from the server is an array, the trial scene is when I visit a posting site, there are many posts, We get an array of IDs for all posts on this page by associative arrays, and then randomly take a value of the array with a lr_paramarr_random function, and then randomly click on a post to simulate the user Then the randomly obtained value to click on a post jump page of the URL inside, so that the simulation users randomly click on the post and then jump to the specific post details page, this article will explain in detail through the script to achieve this problem!

1. Associative arrays obtained from the server

Simply adding "Ord=all" to the associated function represents an array of all the data that satisfies the condition. Examples are as follows:

Action ()
{
Web_reg_save_param ("id",
"Lb=\" _id\ ": \" ",
"Rb=\" ",
"Ord=all",
last);

Web_custom_request ("Web_custom_request",
"Url=http://192.168.1.126:3000/apixxxxxxx",
"Method=get",
"Targetframe=",
"Resource=0",
"Referer=",
"Body=",
last);

return 0;
}

Operation Result:

As seen from the above results, we named the ID is not an array, is an array, he satisfies the following two conditions:

1. The parameters must be assigned in the order of the same name, followed by an underscore and a number.

2. The parameter array must have a parameter named _count to record the length of the array

Related functions:

LR_PARAMARR_IDX ()//Gets the value of the specified number parameter in the parameter array

Lr_paramarr_len ()//Get the length of the parameter array

Lr_paramarr_random ()//Get a random parameter from the parameter list

2. Save the content as a parameter array

Example: To create an array of parameters to access a Web site, you can write the following code



Description: A parameter array named website was created with a script, and the value of the parameter with number 2 was obtained.

Operation Result:


here: Web_site = lr_paramarr_idx ("website", 2), equivalent: Lr_eval_string ("{website_2}");

Get parameter array length

Example:

Action2 ()

{

int array_size = 0;

char *arr_size_str = NULL;

Lr_save_string ("www.google.com", "website_1");

Lr_save_string ("www.google.com", "website_2");

Lr_save_string ("www.google.com", "website_3");

Lr_save_string ("www.google.com", "website_4");

Lr_save_string ("4", "Website_count");

Array_size = Lr_paramarr_len ("website");

Output integer

1. Save the result array_size as a parameter

Lr_save_int (Array_size, "arr_size");

2. Get the string representation of a parameter

Arr_size_str = Lr_eval_string ("{arr_size}");

Output results

Lr_output_message (ARR_SIZE_STR);

return 0;

}

Operation Result:


Get a random parameter from the parameter list

Example:

Action2 ()

{

char *web_site = NULL;

Lr_save_string ("www.google.com", "website_1");

Lr_save_string ("www.google.com", "website_2");

Lr_save_string ("www.google.com", "website_3");

Lr_save_string ("www.google.com", "website_4");

Lr_save_string ("4", "Website_count");

Web_site = lr_paramarr_random ("website");

return 0;

}

Operation Result:

Example: output each parameter sequentially

Action2 ()

{

int i = 0;

Lr_save_string ("www.google.com", "website_1");

Lr_save_string ("www.google.com", "website_2");

Lr_save_string ("www.google.com", "website_3");

Lr_save_string ("www.google.com", "website_4");

Lr_save_string ("4", "Website_count");

for (i=0; i<4;i++)

{

Lr_output_message (Lr_paramarr_idx ("website", I));

}

return 0;

}

Output results



Storing parameters with pointer variables

Action2 ()

{

char *pt = NULL;

Lr_save_string ("Hello World", "Param");

pt = "{param}";

Lr_output_message (PT);

Lr_output_message (Lr_eval_string (PT));

return 0;

}

Operation Result:

3. Application in real combat

Example:

Action ()
{
Web_reg_save_param ("id",
"Lb=\" _id\ ": \" ",
"Rb=\" ",
"Ord=all",
last);

Web_custom_request ("Web_custom_request",
"Url=http://192.168.1.126:3000/apixxxxxxx",
"Method=get",
"Targetframe=",
"Resource=0",
"Referer=",
"Body=",
last);

Lr_save_string (Lr_paramarr_random ("id"), "Ramid");

Web_custom_request ("Web_custom_request",
"Url=http://1xxxxxxx/detail?_id={ramid}",
"Method=get",
"Targetframe=",
"Resource=0",
"Referer=",
"Body=",
last);

return 0;
}

Operation Result:

Loadrunder Script-associative array (parameter array)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.