web_reg_save_param用法
录制百度,并通过web_reg_save_param获取返回数据,作为查询内容,但是老报错。求教该函数该如何使用。报错内容:
Action.c(32): Error -26377: No match found for the requested parameter "sou". Check whether the requested boundaries exist in the response data. Also, if the data you want to save exceeds 256 bytes, use web_set_max_html_param_len to increase the parameter size
Action.c(32): web_url("su") highest severity level was "ERROR", 133 body bytes, 223 header bytes
详细代码:
Action()
{
web_add_cookie("BAIDUID=3B58AB7A17883DB0AB960877EC454D17:FG=1; DOMAIN=www.baidu.com");
web_add_cookie("BD_UTK_DVT=1; DOMAIN=www.baidu.com");
web_add_cookie("BDLFONT=0; DOMAIN=www.baidu.com");
lr_think_time(4);
web_url("www.baidu.com",
"URL=http://www.baidu.com/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t2.inf",
"Mode=HTML",
EXTRARES,
"Url=/js/bdsug.js?v=1.1.0.3", ENDITEM,
LAST);
//web_set_max_html_param_len("1024");
web_reg_save_param("sou","LB/IC=<meta http-equiv=Content-Type content=\"text/html;charset=gb2312\"><title>","RB/IC=</title><style>body{","Search=body",LAST); web_add_cookie("BAIDUID=3B58AB7A17883DB0AB960877EC454D17:FG=1; DOMAIN=suggestion.baidu.com");
web_add_cookie("BD_UTK_DVT=1; DOMAIN=suggestion.baidu.com");
web_add_cookie("BDLFONT=0; DOMAIN=suggestion.baidu.com");
lr_think_time(4);
web_url("su",
"URL=http://suggestion.baidu.com/su?wd={sou}&p=3&t=1253852916312",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.baidu.com/",
"Snapshot=t3.inf",
"Mode=HTML",
LAST);
web_add_cookie("BAIDUID=3B58AB7A17883DB0AB960877EC454D17:FG=1; DOMAIN=s.baidu.com");
web_add_cookie("BD_UTK_DVT=1; DOMAIN=s.baidu.com");
web_add_cookie("BDLFONT=0; DOMAIN=s.baidu.com");
web_url("s",
"URL=http://www.baidu.com/s?wd={sou}",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.baidu.com/",
"Snapshot=t4.inf",
"Mode=HTML",
EXTRARES,
"Url=http://s.baidu.com/w.gif?q={sou}&fm=se&T=1253852884&y=FC93DFF7&path=http://www.baidu.com/s?wd=32&cid=9&qid=c56af6a5007fca0f&t=1253852920000", "Referer=http://www.baidu.com/s?wd=32", ENDITEM,
LAST);
return 0;
[ 本帖最后由 shiyi1022 于 2009-9-26 11:28 编辑 ] //web_set_max_html_param_len("1024");
web_reg_save_param("sou","LB/IC=<meta http-equiv=Content-Type content=\"text/html;charset=gb2312\"><title>","RB/IC=</title><style>body{","Search=body",LAST);
web_url("www.baidu.com",
"URL=http://www.baidu.com/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t2.inf",
"Mode=HTML",
EXTRARES,
"Url=/js/bdsug.js?v=1.1.0.3", ENDITEM,
LAST);
回覆
樓主試試 把web_reg_save_param放在web_url("s", 。。。。)前 ,並且確定要saveparam的左右邊界 web_reg_save_param是放在出现在查找内容的URL的前面的,你的右边界的设置,看上去应该不用设置那么长 原帖由 云层 于 2009-9-26 11:42 发表 http://bbs.51testing.com/images/common/back.gif//web_set_max_html_param_len("1024");
web_reg_save_param("sou","LB/IC=","RB/IC=body{","Search=body",LAST);
web_url("www.baidu.com",
"URL=http://www.baidu.com/",
...
云层老师你写这么一段代码在这里,跟楼主的问题赎我愚钝,不知道是什么意图 以前运行场景时也报过类似的错误,有时加入web_set_max_html_param_len("1024");再运行脚本就不报了,但有时候还是依然报错,一直不知道原因;
关注中。。。 第一,web_reg_save_param应该是放在要查找的动态值的页面之前的。
第二,试过边界太长,取不出值的情况,试着把边界字符长度缩小。如果边界长度缩小,查出的值有重复值。这个函数后加Ord=1或2。。。来控制你查找的值第几次出现是你想要的。
如果再不行,就取出一个包含你要的字符串的一个长字符串,然后用strncpy函数截取一下。
回复 7# 的帖子
已试过缩小边界,只留web_reg_save_param"sou","LB/IC=<title>","RB/IC=</title>","Search=body",LAST);在gereration log中,查找左右边界,有重复,但是执行报错信息仍然是
No match found for the requested parameter "sou". Check whether the requested boundaries exist in the response data. Also, if the data you want to save exceeds 256 bytes, use web_set_max_html_param_len to increase the parameter size
贴出response内容:
****** Response Body For Transaction With Id 11 ******
<html><head><meta http-equiv=Content-Type content="text/html;charset=gb2312"><title>百度一下,你就知道 </title><style……
回复 3# 的帖子
已调换位置,仍然不行。谢谢各位答复,但是问题依然没有解决:Q 我也遇到一样的问题了:Q,急啊。可我看网页源码中显示的是 // Escape any quotes
query = "null";
if ((query == "null") || (query == "")) {
query = timezoneInfo;
} else {
query = query + "&" + timezoneInfo;
}
var uri = "/im;jsessionid=46CC2DFDA64BF785CBA59AA69A273814" + "?" + query;
window.open(uri,"_self","",true);
}
</script>
</head>
这是在js代码中,web_reg_save_param怎么匹配得到呢?:Q web_reg_save_param应该要放在要抽取动态参数的函数前面,此外碰到",要用转义字符\",这样子来写左右边界
页:
[1]