web_convert_param 函数应用
[原创] web_convert_param 函数应用选取web 协议,用html方式录制baidu.com查询”linux技巧”,则在runtime-viewer回放看到查询关键词并非”linux技巧”而是URL编码结果。
改用url 模式录制,代码如后:
web_url("s",
"URL=http://www.baidu.com/s?wd=linux%BC%BC%C7%C9&cl=3",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.baidu.com/",
"Snapshot=t4.inf",
"Mode=HTTP",
LAST);
web_url("c.gif",
"URL=http://c.baidu.com/c.gif?t=0&q=linux%BC%BC%C7%C9",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.baidu.com/s?wd=linux%BC%BC%C7%C9&cl=3",
"Mode=HTTP",
LAST);
回放出错,经ethreal截包,确有:http 204错误。
Action.c(28): Error -26563: Non-empty response body is invalid with HTTP Status Code 204 (No Content) for "http://c.baidu.com/c.gif?t=0&q=linux%BC%BC%C7%C9"
Action.c(28): t=1560ms: 1-byte response body for "http://c.baidu.com/c.gif?t=0&q=linux%BC%BC%C7%C9" (RelFrameId=1)
Action.c(28):
\x00
Action.c(28): Warning -26652: Response body length (1) does not match the Content-Length header specification (0) for "http://c.baidu.com/c.gif?t=0&q=linux%BC%BC%C7%C9"
Action.c(28): web_url("c.gif") highest severity level was "ERROR", 1 body bytes, 112 header bytes
。
为了参数化以及更正错误,正确的代码如后:
web_convert_param("encoderesult", "SourceString={keyword}","SourceEncoding=HTML",
"TargetEncoding=URL", LAST);
lr_log_message("encode=%s",lr_eval_string("{encoderesult}"));
web_url("s",
"URL=http://www.baidu.com/s?wd={encoderesult}&cl=3",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.baidu.com/",
"Snapshot=t4.inf",
"Mode=HTTP",
LAST);
lr_continue_on_error(LR_ON_ERROR_CONTINUE );
web_url("c.gif",
"URL=http://c.baidu.com/c.gif?t=0&q=linux%BC%BC%C7%C9",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.baidu.com/s?wd=linux%BC%BC%C7%C9&cl=3",
"Mode=HTTP",
LAST);
选取web 协议,用html方式录制baidu.com查询”linux技巧”,则在runtime-viewer回放看到查询关键词并非”linux技巧”而是URL编码结果。
改用url 模式录制,代码如后:
web_url("s",
"URL=http://www.baidu.com/s?wd=linux%BC%BC%C7%C9&cl=3",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.baidu.com/",
"Snapshot=t4.inf",
"Mode=HTTP",
LAST);
web_url("c.gif",
"URL=http://c.baidu.com/c.gif?t=0&q=linux%BC%BC%C7%C9",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.baidu.com/s?wd=linux%BC%BC%C7%C9&cl=3",
"Mode=HTTP",
LAST);
回放出错,经ethreal截包,确有:http 204错误。
Action.c(28): Error -26563: Non-empty response body is invalid with HTTP Status Code 204 (No Content) for "http://c.baidu.com/c.gif?t=0&q=linux%BC%BC%C7%C9"
Action.c(28): t=1560ms: 1-byte response body for "http://c.baidu.com/c.gif?t=0&q=linux%BC%BC%C7%C9" (RelFrameId=1)
Action.c(28):
\x00
Action.c(28): Warning -26652: Response body length (1) does not match the Content-Length header specification (0) for "http://c.baidu.com/c.gif?t=0&q=linux%BC%BC%C7%C9"
Action.c(28): web_url("c.gif") highest severity level was "ERROR", 1 body bytes, 112 header bytes
。
为了参数化以及更正错误,正确的代码如后:
web_convert_param("encoderesult", "SourceString={keyword}","SourceEncoding=HTML",
"TargetEncoding=URL", LAST);
lr_log_message("encode=%s",lr_eval_string("{encoderesult}"));
web_url("s",
"URL=http://www.baidu.com/s?wd={encoderesult}&cl=3",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.baidu.com/",
"Snapshot=t4.inf",
"Mode=HTTP",
LAST);
lr_continue_on_error(LR_ON_ERROR_CONTINUE );
web_url("c.gif",
"URL=http://c.baidu.com/c.gif?t=0&q=linux%BC%BC%C7%C9",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.baidu.com/s?wd=linux%BC%BC%C7%C9&cl=3",
"Mode=HTTP",
LAST); 直接用URL_BASE方式 直接用URL_BASE方式 在最前面 可否对几个LR函数做下简单的描述呢?有的都没接触过 呵呵
页:
[1]