参数说明
1、REQUEST,用于提取完整的请求头信息。
2、RESPONSE,用于提取完整的响应头信息。
3、ResponseBody ,用于提取完整的响应体信息。
注意,这两个变量仅在请求前使用web_save_header注册使用。示例如下:
Action()
{
// 默认最大长度为256
web_set_max_html_param_len("262144");
//自定义截取字符串,根据左右字符串获取数据
web_reg_save_param("ResponseBody", "LB=", "RB=", "Search=Body", LAST);
// REQUEST为内置变量,保存请求的头信息,需在发送URL请求前注册使用,将请求头信息存入字符串RequestHeader中
web_save_header(REQUEST, "RequestHeader");
// 将RESPONSE保存响应的头信息在字符串ResponseHeader中
web_save_header(RESPONSE, "ResponseHeader");
web_url("blog",
"URL=http://blog.sina.com.cn/bestfeiyong",
"Resource=0",
"RecContentType=text/html",
"Mode=HTTP",
LAST);
//字符转码
lr_convert_string_encoding(lr_eval_string("{RequestHeader}"),LR_ENC_UTF8 ,LR_ENC_SYSTEM_LOCALE,"RequestHeaderUTF8");
lr_convert_string_encoding(lr_eval_string("{ResponseHeader}"),LR_ENC_UTF8 ,LR_ENC_SYSTEM_LOCALE,"ResponseHeaderUTF8");
lr_convert_string_encoding(lr_eval_string("{ResponseBody}"),LR_ENC_UTF8 ,LR_ENC_SYSTEM_LOCALE,"ResponseBodyUTF8");
//输出信息
lr_output_message("# 请求头信息:\n %s", lr_eval_string("{RequestHeaderUTF8}"));
lr_output_message("# 响应头信息:\n %s", lr_eval_string("{ResponseHeaderUTF8}"));
lr_output_message("# 响应内容体:\n %s", lr_eval_string("{ResponseBodyUTF8}"));
return 0;
}
输出:
Action.c(19): # 请求头信息:
GET /bestfeiyong HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT)
Accept-Encoding: gzip, deflate
Accept: */*
Connection: Keep-Alive
Host: blog.sina.com.cn
Action.c(20): # 响应头信息:
HTTP/1.1 200 OK
Server: nginx/1.0.8
Date: Mon, 30 Jul 2012 02:49:19 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"
Cache-Control: no-cache
Expires: Mon, 30 Jul 2012 02:49:18 GMT
Last-Modified: Mon, 30 Jul 2012 10:45:10 GMT+8
DPOOL_HEADER: 10.55.27.46
Age: 249
X-Cache: HIT from sh-223-36.squid.blog.sina.com.cn
X-debug: 114.80.223.58
Content-Encoding: gzip
请求体略....