【原创】LoadRunner自动发帖脚本_烟三
上一篇 / 下一篇 2008-03-23 18:46:58 / 个人分类:测试工具
概述:51Testing软件测试网;S(sgg*{
本文主要是学习web_reg_save_param、lr_eval_string、sprintf、strstr、strcpy、strncpy、strlen、strcat等函数,同时处理重复数据、敏感字的替换。
8zu Yk ~ Z0
9nzR }1E8X-`/}K0疑问:
5KA$V-P$LqV8R"|1Y._0如果两个网站默认的编码不一样,一个是GB2312,一个是UTF-8,如何解决呢?难道一定要进行编码转换吗?Loadrunner是否有现成的函数可以实现?51Testing软件测试网kd @xLegG
l%?/z4\2]f su;hd0脚本:51Testing软件测试网O.}BU-IAd
#include "web_api.h"
h`e(| w5v*vi"Vi*U|0Action()51Testing软件测试网$K\y3\
JW#WC
{
0T Q'N!aQ
p0 int i,j,g,f,e,offset;
\b:SzKy)I9b)A0 int NewsCount,ContentCount,h;51Testing软件测试网#{
egf0T@
char Str_Tem[100];51Testing软件测试网zC$p9q
{4F
I
char Str_NewsCount[100][100];51Testing软件测试网
v@a|pQnaX
char Str_NewsId[100],Str_NewsIdd[100];
/Nv"@/`#VG@0 char Str_NewsTitle[1000];51Testing软件测试网/@M
M z&E~&n_%l
char Str_NewsContent[2000];51Testing软件测试网g&|0U Z%f:} M&U2T.kI
char Str_News[2000],Str_temp[2000];
'U8e?JAvx'Jz0 char *position;
Kp&u6rR6M0 char search_str[] = "<";51Testing软件测试网$a/xtB7n
char search_title[] = "_";51Testing软件测试网3^2n6HI@%I}
//登录要发帖的网站51Testing软件测试网r^YiHrAYn
web_url("Login.aspx",
5~H`M5U7o8y0 "URL=http://WebPassport.com.com/Login.aspx",51Testing软件测试网WW,mrWk+d
"Resource=0",
8Hd+^X(L
a;{0 "RecContentType=text/html",51Testing软件测试网.K^
m9X
}si;D
"Referer=",51Testing软件测试网V+O&]J
?$i
"Snapshot=t2.inf",51Testing软件测试网T9r y)R|l:rg
"Mode=HTML",51Testing软件测试网`d1O k1`z0mA
EXTRARES,
.L)Z/WF0YaAW:zdf0 LAST);
W3lH\4\$b#R0 51Testing软件测试网?9z4j5H;O0IT8X
web_submit_form("Login.aspx_2",
#S-Q1oFf3s8Y0 "Snapshot=t3.inf",51Testing软件测试网;x
Ll%^K
w
o;ef[
ITEMDATA,
@.BZ["rzVS0 "Name=_username", "Value=烟三", ENDITEM,51Testing软件测试网Z*w*\"m{6I*yU)B-i-o
"Name=_password", "Value=541111", ENDITEM,51Testing软件测试网!e$s
KH B C[
"Name=CheckboxSaveInfo", "Value=<OFF>", ENDITEM,51Testing软件测试网;E L-_@WA
"Name=Login", "Value=登录", ENDITEM,
'e8t&w.^%|:[2H Q!W0 EXTRARES,
{@,zp5la0 LAST);
//从其他网站获取新闻
1i)ie({'z8O;H(v0 //1、获取新闻ID
mK:}(Z#z#^;q-m
q7r0 web_reg_save_param("NewsId","NOTFOUND=warning","LB=http://ent.ifeng.com/idolnews/hk/200803/","RB=.shtml","ORD=ALL",LAST);51Testing软件测试网(ZwU,G1S?Cb\
web_url("ent.ifeng.com",51Testing软件测试网SB#r)y"W9Bo4FK8D
"URL=http://ent.ifeng.com/",