|
使用关联函数后取得不到里面的值。写到文件中的内容为空 。是不是哪里写错了
脚本如下:
Action()
{
int flen; //定义一个整型变量保存获得文件的大小
int length;
long filedes; //保存文件句柄
char file[256]="\0"; //保存文件路径及文件名
char buffer[700]="";
web_set_max_html_param_len("9999999");//设置页面接收最大的字节数,该设置应大于下载文件的大小
web_reg_save_param("filecontent",
"LB=<body>",
"RB=</body>",
"Search=ALL",
LAST);
lr_output_message(lr_eval_string("{filecontent}"));
flen = 650;
web_url("www.baidu.com",
"URL=http://www.baidu.com/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
EXTRARES,
"Url=/img/i2.png", ENDITEM,
"Url=/img/arr.gif", ENDITEM,
"Url=/js/bdsug.js?v=1.0.3.0", ENDITEM,
"Url=/favicon.ico", "Referer=", ENDITEM,
LAST);
lr_save_string(lr_eval_string("{filecontent}"),"buffer");
lr_output_message("%s",buffer);
lr_output_message("%d",flen);
if(flen > 0)
{
if((filedes = fopen("d:\\test.txt", "wb")) == NULL)
{
lr_output_message("Open File Failed!", lr_eval_string("{filecontent}"));
return -1;
}
fwrite(buffer,flen,10,filedes );
fclose( filedes );
}
return 0;
}
日志结果如下:
Starting action Action.
Action.c(10): web_set_max_html_param_len was successful [MsgId: MMSG-26392]
Action.c(11): Registering web_reg_save_param was successful [MsgId: MMSG-26390]
Action.c(16): {filecontent}
Action.c(20): Found resource "http://www.baidu.com/img/baidu_sylogo1.gif" in HTML "http://www.baidu.com/" [MsgId: MMSG-26659]
Action.c(20): Found resource "http://gimg.baidu.com/img/gs.gif" in HTML "http://www.baidu.com/" [MsgId: MMSG-26659]
Action.c(20): Downloading resource "http://www.baidu.com/img/i2.png" (specified by argument number 9) [MsgId: MMSG-26577]
Action.c(20): Downloading resource "http://www.baidu.com/img/arr.gif" (specified by argument number 11) [MsgId: MMSG-26577]
Action.c(20): Downloading resource "http://www.baidu.com/js/bdsug.js?v=1.0.3.0" (specified by argument number 13) [MsgId: MMSG-26577]
Action.c(20): Downloading resource "http://www.baidu.com/favicon.ico" (specified by argument number 15) [MsgId: MMSG-26577]
Action.c(20): web_url("www.baidu.com") was successful, 9439 body bytes, 2232 header bytes [MsgId: MMSG-26386]
Action.c(34):
Action.c(35): 650
Ending action Action. |
|