|
一个实例:- 1. Action()
- 2. {
- 3. int flen;
- 4. long filedes;
- 5. char filename[1024];
- 6.
- 7. web_add_cookie("seraph.os.cookie=ElKlHkQmJlOkFjGjJi; DOMAIN=172.20.16.4");
- 8.
- 9. web_set_max_html_param_len("1024000");
- 10. web_url("172.20.16.4:8080",
- 11. "URL=http://172.20.16.4:8080/",
- 12. "Resource=0",
- 13. "RecContentType=text/html",
- 14. "Referer=",
- 15. "Snapshot=t4.inf",
- 16. "Mode=HTML",
- 17. EXTRARES,
- 18. "Url=/styles/global.css", "Referer=http://172.20.16.4:8080/secure/Dashboard.jspa", ENDITEM,
- 19. LAST);
- 20.
- 21. web_link("TEST-306",
- 22. "Text=TEST-306",
- 23. "Snapshot=t5.inf",
- 24. EXTRARES,
- 25. "Url=../styles/global.css", ENDITEM,
- 26. LAST);
- 27.
- 28. web_reg_save_param("fcontent", "LB=", "RB=", "SEARCH=BODY", LAST);
- 29. web_link("test.xml",
- 30. "Text=test.xml",
- 31. "Snapshot=t6.inf",
- 32. LAST);
- 33.
- 34. //获取文本类型的文件大小
- 35. flen = strlen(lr_eval_string("{fcontent}"));
- 36. //获取二进制文件类型的文件大小
- 37. //flen = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
- 38. lr_message("-----------------flen:%d",flen);
- 39.
- 40. //生成随机的文件名称,便于并发
- 41. strcpy(filename,"d:\\123\\aa_");
- 42. strcat(filename,lr_eval_string("{Num}"));
- 43. strcat(filename,".xml");
- 44.
- 45. if(flen > 0)
- 46. {
- 47. //以写方式打开文件
- 48. if((filedes = fopen(filename, "wb")) == NULL)
- 49. {
- 50. lr_output_message("Open File Failed!");
- 51. return -1;
- 52. }
- 53. //写入文件内容
- 54. fwrite(lr_eval_string("{fcontent}"), flen, 1, filedes);
- 55. //关闭文件
- 56. fclose(filedes);
- 57. }
- 58.
- 59. return 0;
- 60. }
复制代码 |
|