51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 2732|回复: 3
打印 上一主题 下一主题

[原创] 新手,帮忙看一段代码

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2009-10-27 20:43:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我是想实现这样一个功能:在下面这个网站上:http://www.fjgsgl.com/,我想在它主页右侧的费率查询栏目中查询所有两两站点之间的距离(数据量大概有5000条左右),并把结果输出到一个文件中,一位朋友帮我写了段代码,如下:
  1. Action()
  2. {

  3. int m,n;
  4. char leon[512];
  5. int leon1;
  6. web_url( "www.fjgsgl.com ",
  7. "URL=http://www.fjgsgl.com/ ",
  8. "TargetFrame= ",
  9. "Resource=0 ",
  10. "RecContentType=text/html ",
  11. "Referer= ",
  12. "Snapshot=t1.inf ",
  13. "Mode=HTML ",
  14. EXTRARES,
  15. "URL=/focus.swf ",ENDITEM,
  16. "URL=/main.files/105x75.jpg ",ENDITEM,
  17. "URL=/main.files/fqgs002.gif ",ENDITEM,
  18. "URL=/main.files/fqgs001.jpg ",ENDITEM,
  19. "URL=/Foosun_Plus/Ads/CreateJs/RightBottom.js ",ENDITEM,
  20. LAST);

  21. web_custom_request("urs.asmx ",
  22. "URL=https://urs.microsoft.com/urs.asmx?MSPRU-Client-Key=S4uXVHsMw2lMYlhTRRlyXA%3d%3d&MSPRU-Patented-Lock=ts5iAr%2b/rnw%3d ",
  23. "Method=POST ",
  24. "TargetFrame= ",
  25. "Resource=0 ",
  26. "RecContentType=text/xml ",
  27. "Referer= ",
  28. "Snapshot=t2.inf ",
  29. "Mode=HTML ",
  30. "EncType=text/xml;charset=utf-8 ",
  31. "Body= <soap:Envelope xmlns:soap=\ "http://schemas.xmlsoap.org/soap/envelope/\ "   xmlns:xsi=\ "http://www.w3.org/2001/XMLSchema-instance\ "   xmlns:xsd=\ "http://www.w3.org/2001/XMLSchema\ "   xmlns:soapenc=\ "http://schemas.xmlsoap.org/soap/encoding/\ "> <soap:Body> <Lookup   xmlns=\ "http://Microsoft.STS.STSWeb/\ "> <r   soapenc:arrayType=\ "xsd:string[1]\ "> <string> http://www.fjgsgl.com </string> </r> <ID> {A0AB7674-8D67-4F4D-B5E1-96FAEADFB79D} </ID> <v   soapenc:arrayType=\ "xsd:string[5]\ "> <string> 7.0.6004.6 </string> <string> 7.00.6000.16730 </string> <string> 7.0.5730.13 </string> <string> 5.1.2600.2.0 </string> <string> zh-cn </string> </v> </Lookup> </soap:Body> </soap:Envelope> ",
  32. LAST);

  33. web_custom_request("urs.asmx_2 ",
  34. "URL=https://urs.microsoft.com/urs.asmx?MSPRU-Client-Key=uOt2PA6dKVA1gk9vIGgXLg%3d%3d&MSPRU-Patented-Lock=OaIDEoRE/yI%3d ",
  35. "Method=POST ",
  36. "TargetFrame= ",
  37. "Resource=0 ",
  38. "RecContentType=text/xml ",
  39. "Referer= ",
  40. "Snapshot=t3.inf ",
  41. "Mode=HTML ",
  42. "EncType=text/xml;charset=utf-8 ",
  43. "Body= <soap:Envelope xmlns:soap=\ "http://schemas.xmlsoap.org/soap/envelope/\ "   xmlns:xsi=\ "http://www.w3.org/2001/XMLSchema-instance\ "   xmlns:xsd=\ "http://www.w3.org/2001/XMLSchema\ "   xmlns:soapenc=\ "http://schemas.xmlsoap.org/soap/encoding/\ "> <soap:Body> <Lookup   xmlns=\ "http://Microsoft.STS.STSWeb/\ "> <r   soapenc:arrayType=\ "xsd:string[1]\ "> <string> http://www.fjgsgg.com/zfbz.asp </string> </r> <ID> {A0AB7674-8D67-4F4D-B5E1-96FAEADFB79D} </ID> <v   soapenc:arrayType=\ "xsd:string[5]\ "> <string> 7.0.6004.6 </string> <string> 7.00.6000.16730 </string> <string> 7.0.5730.13 </string> <string> 5.1.2600.2.0 </string> <string> zh-cn </string> </v> </Lookup> </soap:Body> </soap:Envelope> ",
  44. EXTRARES,
  45. "URL=http://www.fjgsgl.com/files/2009/60.jpg ","Referer=http://www.fjgsgl.com/focus.swf ",ENDITEM,
  46. "URL=http://www.fjgsgl.com/Files/2009/DSC00600.JPG ","Referer=http://www.fjgsgl.com/focus.swf ",ENDITEM,
  47. "URL=http://www.fjgsgl.com/Files/W020080103316475157468.jpg ","Referer=http://www.fjgsgl.com/focus.swf ",ENDITEM,
  48. "URL=http://www.fjgsgl.com/Files/kxfzg090328.jpg ","Referer=http://www.fjgsgl.com/focus.swf ",ENDITEM,
  49. "URL=http://www.fjgsgl.com/Files/slogan1024.jpg ","Referer=http://www.fjgsgl.com/focus.swf ",ENDITEM,
  50. "URL=http://www.fjgsgl.com/main.files/lihoulin400x215.jpg ","Referer=http://www.fjgsgl.com/focus.swf ",ENDITEM,
  51. LAST);

  52. web_url("show.asp ",
  53. "URL=http://www.fjgsgl.com/Foosun_Plus/Ads/show.asp?Location=5 ",
  54. "TargetFrame= ",
  55. "Resource=0 ",
  56. "RecContentType=text/html ",
  57. "Referer=http://www.fjgsgl.com/ ",
  58. "Mode=HTML ",
  59. LAST);

  60. /*页面显示完毕
  61. */

  62. lr_think_time(48);
  63. for(m=1;m <=10;m++)   
  64.   {
  65.     lr_save_string(   lr_eval_string( "{name1} "), "tmp ");
  66.     for(n=1;n <=10;n++)
  67.       {
  68.         web_reg_save_param("leon","LB=距离为","RB=公里",LAST);
  69.         lr_message("value:%s",lr_eval_string("{leon}"));   
  70.         web_submit_data("zfbz.asp ",
  71.         "Action=http://www.fjgsgg.com/zfbz.asp?zf=submit ",
  72.         "Method=POST",
  73.         "TargetFrame=",
  74.         "RecContentType=text/html",
  75.         "Referer=http://www.fjgsgg.com/zfbz.asp",
  76.         "Snapshot=t4.inf",
  77.         "Mode=HTML",
  78.         ITEMDATA,
  79.         "Name=names1","Value={tmp}",ENDITEM,
  80.         "Name=names2","Value={name2}",ENDITEM,
  81.         "Name=B1","Value=查询",ENDITEM,LAST);
  82.         leon1=(int)fopen("C:\\huoyanming.txt","at+");
  83.         fprintf(leon1, "从%s到%s距离为%s公里\n ",lr_eval_string("{name1}"),lr_eval_string("{name2}"),lr_eval_string("{leon}"));
  84.         fclose();
  85.       }
  86.   }

  87. /*查询完毕
  88. */

  89. return 0;
  90. }
复制代码
我运行的时候提示如下错误:
vuser_init.c (33): warning: unrecognized character escape sequence `\ '
vuser_init.c (33): syntax error; found `http' expecting `)'
vuser_init.c (33): syntax error; found `http' expecting `;'
vuser_init.c (34): syntax error; found `)' expecting `;'
vuser_init.c (34): illegal statement termination
vuser_init.c (34): skipping `)'
vuser_init.c (46): warning: unrecognized character escape sequence `\ '
vuser_init.c (46): syntax error; found `http' expecting `)'
vuser_init.c (46): syntax error; found `http' expecting `;'
vuser_init.c (46): redefinition of label `http' previously defined at vuser_init.c (33)
vuser_init.c (54): syntax error; found `)' expecting `;'
vuser_init.c (54): illegal statement termination
vuser_init.c (54): skipping `)'
Action.c (2): redefinition of `Action' previously defined at vuser_init.c (1)
c:\\documents and settings\\liupeng\\local settings\\temp\\noname4\\\\combined_noname4.c (5): 12 errors, not writing pre_cci.ci
之前没有接触过LoadRunner,完全看不懂啊,请各位朋友帮帮忙,感谢!
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 2009-10-28 09:51:30 | 只看该作者
没看明白  帮你顶了
回复 支持 反对

使用道具 举报

  • TA的每日心情
    慵懒
    2020-8-11 08:18
  • 签到天数: 114 天

    连续签到: 1 天

    [LV.6]测试旅长

    3#
    发表于 2009-10-28 22:56:01 | 只看该作者
    。。。不是有出错提示的么。。。

    从第一个开始检查。。。后面的错误有可能是第一个引起的。。。
    我稍微看了下  斜杠可能是引号转义之类的问题
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    4#
    发表于 2009-10-29 08:57:45 | 只看该作者
    你双击错误处,会自动定位到你脚本相应部分,都是语法问题。
    回复 支持 反对

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-11-19 00:32 , Processed in 0.071285 second(s), 27 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表