LR中web_reg_save_param中使用ORD=ALL,无法提取出数据
下午做了个关联的实验,就是把一些参数输入BAIDU搜索框进行搜索,主要代码如下:
web_reg_save_param("keyword",
"LB=target=\"_blank\" mon=\"ct=1&a=30\">",
"RB=</a>",
"Ord=All",
"Search=Body",
LAST);
web_url("news.baidu.com",
"URL=http://news.baidu.com/",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.baidu.com/",
"Snapshot=t2.inf",
"Mode=HTML",
EXTRARES,
"URL=/img/icon.gif?v=1.1", ENDITEM,
"URL=/z/resource/r/image/2010-05-16/ef89e882b397fc61f328767cbc694791.jpg", ENDITEM,
"URL=/img/line.gif", ENDITEM,
"URL=/z/resource/r/image/2010-05-16/fe75c47a73255062ac367d7f1120099e.jpg", ENDITEM,
"URL=/z/resource/r/image/2010-05-16/a75faf970c7bdaaca473ec623be3de1f.jpg", ENDITEM,
"URL=/resource/img/bg.gif", ENDITEM,
"URL=/z/resource/r/image/2010-05-16/89963013baa4c31869218c7263519d35.jpg", ENDITEM,
"URL=/z/resource/r/image/2010-05-16/eaa41fed562be39cfdbf34e490178f88.jpg", ENDITEM,
"URL=/z/resource/r/image/2010-05-16/8ae8ef541cdce526752b815bb9bf0922.jpg", ENDITEM,
"URL=/z/resource/r/image/2010-05-15/982f5dff8553e9d2feb0c2d877e07c1a.jpg", ENDITEM,
"URL=http://eiv.baidu.com/other/ff.js", ENDITEM,
"URL=http://eiv.baidu.com/mapm2/up.gif", ENDITEM,
"URL=http://drmcmm.baidu.com/media/id=n10sPW64P6&gp=402&time=nHcLnWnvrjT1nf.swf", ENDITEM,
LAST);
lr_think_time(31);
web_add_cookie("BAIDUID=0BF7E80A5EBCDD6C921C0EF00C6006D4:FG=1; DOMAIN=nsclick.baidu.com");
web_add_cookie("BD_UTK_DVT=1; DOMAIN=nsclick.baidu.com");
web_add_cookie("vjuids=7497ae1ac.120dafd44e2.0.31f74bcd6a5d3; DOMAIN=nsclick.baidu.com");
web_add_cookie("vjlast=1240624613,1240624613,30; DOMAIN=nsclick.baidu.com");
web_add_cookie("Hm_lvt_eedec8cb8159470f2c25a22d1a9fef7c=1258474709921; DOMAIN=nsclick.baidu.com");
lr_start_transaction("搜索热点");
web_submit_form("ns",
"Snapshot=t3.inf",
ITEMDATA,
"Name=word", "Value={keyword}", ENDITEM,
"Name=tn", "Value=news", ENDITEM,
EXTRARES,
"URL=http://nsclick.baidu.com/v.gif?pid=7&url=&type=1&m=100&q=HTTP&img=0&vid=0&ra=1273999498062", "Referer=http://news.baidu.com/ns?word={keyword}&tn=news&from=news&cl=2&rn=20&ct=1", ENDITEM,
LAST);
lr_end_transaction("搜索热点", LR_AUTO);
return 0;
结果显示是直接把{keyword}输入到搜索框了。。。
还有以下提示:
Action.c(47): Notify: Saving Parameter "keyword_count = 20"
Action.c(47): web_url("news.baidu.com") highest severity level was "warning", 565524 body bytes, 14556 header bytes
Action.c(71): web_add_cookie was successful
Action.c(73): web_add_cookie was successful
Action.c(75): web_add_cookie was successful
Action.c(77): web_add_cookie was successful
Action.c(79): web_add_cookie was successful
Action.c(82): Notify: Transaction "搜索热点" started.
Action.c(84): Warning: The string 'keyword' with parameter delimiters is not a parameter.
我试过如果把Ord改成1或者2。。。的话,就可以成功输出信息了。。。
请教下大家这是什么原因。。。。 考虑了一下,终于弄成功了。。。我的做法是把数组里的数据一个一个取出来:
lr_start_transaction("搜索热点");
i=atoi(lr_eval_string("{keyword_count}"));
for(j=1;j<=i;j++)
{ sprintf(temp,"Value={keyword_%d}\0",j);
web_submit_form("ns",
"Snapshot=t3.inf",
ITEMDATA,
"Name=word", temp, ENDITEM,
"Name=tn", "Value=news", ENDITEM,
EXTRARES,
"URL=http://nsclick.baidu.com/v.gif?pid=7&url=&type=1&m=100&q=HTTP&img=0&vid=0&ra=1273999498062", "Referer=http://news.baidu.com/ns?word={keyword_j}&tn=news&from=news&cl=2&rn=20&ct=1", ENDITEM,
LAST);
lr_output_message("{keyword_%d}",j);
}
lr_end_transaction("搜索热点", LR_AUTO);
因为不知道还有什么其他办法,暂时这样做了,不知道大家有没有更好的办法能解决呢? 你用ord=all,得到的就是一个数组
如果你想直接使用,直接用ord=1 或者X ,X一个整数
另外LR9.1版本后有个新函数可以直接使用数组中的值,不用for循环 原来是这样,我现在用的是8.0的,是不是就只能用for去数组里取了?
页:
[1]