Добрый день!
Есть такой вопрос.
Есть action, в котором открывается страница со случайным id:
http://******/pages/view/14/
http://******/pages/view/9/
http://******/pages/view/25/
[codebox] int r=fRandInteger(10, 20);
char pageurl[64], *suffix = "/";
sprintf(pageurl,"http://62.244.5.146:...ages/view/%d%s", r, suffix);
lr_output_message("URL is %s", pageurl);
// Save {URL} parameter
lr_save_string(pageurl, "URL");
web_url("ELGG Page Content",
"URL={URL}",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=",
"Mode=HTML",
EXTRARES,
"Url=/elgg/mod/theme_simplebluewhite/graphics/theme_pageback.gif", ENDITEM,
"Url=/elgg/mod/theme_simplebluewhite/graphics/theme_contentback.gif", ENDITEM,
"Url=/elgg/mod/theme_simplebluewhite/graphics/theme_footer.gif", ENDITEM,
"Url=/elgg/_graphics/icon_rss.gif", ENDITEM,
"Url=/elgg/_graphics/icon_gallery.gif", ENDITEM,
LAST);
web_find("ELGG Text Check",
"expect=found",
"matchcase=yes",
"onfailure=abort",
"report=failure",
"repeat=no",
"what=Pages home",
LAST);
lr_think_time(fRandInteger(2, 5));
return 0;[/codebox]
Как сделать так чтобы каждый VUSER открывал разный случайный url?
Так как сейчас у меня все VUSER открывают одинаковый случайный url.
Как сделать так чтобы каждый VUSER открывал разный случайный url
Автор Estrella, 12 июн 2009 11:47
Сообщений в теме: 3
#1
Отправлено 12 июня 2009 - 11:47
#2
Отправлено 13 июня 2009 - 00:55
Попробуйте определить в скрипте параметр (Vuser->Parameter List) типа Random Number. Как подставить его в URL вы и сами знаете, судя по приведенному коду.
#3
Отправлено 17 июня 2009 - 11:35
Проблема решена.
[codebox]ElggContent()
{
int p;
char pageurl[64];
// Save {text} parameter
lr_save_string(mytext, "text");
// Get page_rand parameter
p=atoi(lr_eval_string("{page_rand}"));
// Paste URL together
sprintf(pageurl, "%spg/pages/view/%d", site, p);
lr_output_message("URL is %s", pageurl);
// Save {URL} parameter
lr_save_string(pageurl, "URL");
// Open URL
web_url("ELGG Page",
"URL={URL}",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=",
"Mode=HTML",
EXTRARES,
"Url=/elgg/mod/theme_simplebluewhite/graphics/theme_pageback.gif", ENDITEM,
"Url=/elgg/mod/theme_simplebluewhite/graphics/theme_contentback.gif", ENDITEM,
"Url=/elgg/mod/theme_simplebluewhite/graphics/theme_footer.gif", ENDITEM,
"Url=/elgg/_graphics/icon_rss.gif", ENDITEM,
"Url=/elgg/_graphics/icon_gallery.gif", ENDITEM,
LAST);
// Check Text
web_find("ELGG Text Check",
"expect=found",
"matchcase=yes",
"onfailure=abort",
"report=failure",
"repeat=no",
"what={text}",
LAST);
return 0;
}[/codebox]
[codebox]vuser_end()
{
int think;
// Random think time
think=atoi(lr_eval_string("{time_rand}"));
lr_output_message("Think time is %d sec.", think);
// Thinking....
lr_think_time(think);
return 0;
}[/codebox]
globals.h
[codebox]//--------------------------------------------------------------------
// Include Files
#include "lrun.h"
#include "web_api.h"
#include "lrw_custom_body.h"
#define n 18200
// Site
char *site="http://62.244.5.146:2280/elgg/";
// Text to check on every page
char *mytext="Powered by Elgg, the leading open source social networking platform";
// Random Think time Function
int fRandInteger(minInt, maxInt, id)
{
int rndInt, offset;
//srand is called before rand
srand(time(NULL));
if (maxInt == 0)
return maxInt; // Caller must handle a 0 in order to prevent error.
offset = minInt;
rndInt = (((minInt) + rand() % (maxInt - offset + 1)));
return rndInt;
}[/codebox]
[codebox]ElggContent()
{
int p;
char pageurl[64];
// Save {text} parameter
lr_save_string(mytext, "text");
// Get page_rand parameter
p=atoi(lr_eval_string("{page_rand}"));
// Paste URL together
sprintf(pageurl, "%spg/pages/view/%d", site, p);
lr_output_message("URL is %s", pageurl);
// Save {URL} parameter
lr_save_string(pageurl, "URL");
// Open URL
web_url("ELGG Page",
"URL={URL}",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=",
"Mode=HTML",
EXTRARES,
"Url=/elgg/mod/theme_simplebluewhite/graphics/theme_pageback.gif", ENDITEM,
"Url=/elgg/mod/theme_simplebluewhite/graphics/theme_contentback.gif", ENDITEM,
"Url=/elgg/mod/theme_simplebluewhite/graphics/theme_footer.gif", ENDITEM,
"Url=/elgg/_graphics/icon_rss.gif", ENDITEM,
"Url=/elgg/_graphics/icon_gallery.gif", ENDITEM,
LAST);
// Check Text
web_find("ELGG Text Check",
"expect=found",
"matchcase=yes",
"onfailure=abort",
"report=failure",
"repeat=no",
"what={text}",
LAST);
return 0;
}[/codebox]
[codebox]vuser_end()
{
int think;
// Random think time
think=atoi(lr_eval_string("{time_rand}"));
lr_output_message("Think time is %d sec.", think);
// Thinking....
lr_think_time(think);
return 0;
}[/codebox]
globals.h
[codebox]//--------------------------------------------------------------------
// Include Files
#include "lrun.h"
#include "web_api.h"
#include "lrw_custom_body.h"
#define n 18200
// Site
char *site="http://62.244.5.146:2280/elgg/";
// Text to check on every page
char *mytext="Powered by Elgg, the leading open source social networking platform";
// Random Think time Function
int fRandInteger(minInt, maxInt, id)
{
int rndInt, offset;
//srand is called before rand
srand(time(NULL));
if (maxInt == 0)
return maxInt; // Caller must handle a 0 in order to prevent error.
offset = minInt;
rndInt = (((minInt) + rand() % (maxInt - offset + 1)));
return rndInt;
}[/codebox]
#4
Отправлено 17 июня 2009 - 13:16
Хоть убейте, но я не понимаю, в чем была проблема рандомным образом выбирать линки и зачем нужно было для этого писать свой код.
При том, что для статических параметров есть опция Select Next Row - random, а для динамических неплохо работает метод lr_paramarr_random().
При том, что для статических параметров есть опция Select Next Row - random, а для динамических неплохо работает метод lr_paramarr_random().
Количество пользователей, читающих эту тему: 0
0 пользователей, 0 гостей, 0 анонимных