前几篇简单的介绍了怎么具体来操作以捕获手机访问应用服务时产生的真实数据,然后导入LR通过分析自动生成脚本的过程,今天我们就一起来看一个实际的例子。其实跟传统的类似,主要是怎么获取真实的数据来模拟。
以下为访问手机访问百度后生成的脚本
Action()
{
/* Correlation comment - Do not change! Original value='0C91CF80CDC525DAE788207F50FC4651:FG=1' Name ='CorrelationParameter' */
web_reg_save_param_regexp(
"ParamName=CorrelationParameter",
"RegExp=BAIDUID=(.*?);",
SEARCH_FILTERS,
"Scope=Cookies",
"IgnoreRedirections=Yes",
"RequestUrl=*/m.baidu.com/*",
LAST);
web_url("r",
"URL=http://miui.com/r?url=httpXXXXXXXXXXXXXXXXX", '特殊处理
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t7.inf",
"Mode=HTML",
EXTRARES,
"Url=http://m.baidu.com/static/index/innovation/cache.manifest", "Referer=", ENDITEM,
"Url=http://m.baidu.com/static/index/i.gif", "Referer=", ENDITEM,
"Url=http://m.baidu.com/static/index/logo_index2.png", "Referer=", ENDITEM,
"Url=http://m.baidu.com/static/hb/hot.gif", "Referer=", ENDITEM,
"Url=http://m.baidu.com/static/tj.gif?prod=default&type=loadpagetime_350&time=1357630293617&from=index", "Referer=http://m.baidu.com/?from=1269a", ENDITEM,
"Url=http://m.baidu.com/static/tj.gif?prod=default&type=pv&pt=index&time=1357630293653&from=index", "Referer=http://m.baidu.com/?from=1269a", ENDITEM,
"Url=http://m.baidu.com/static/index/baisou_android.png", "Referer=", ENDITEM,
"Url=http://m.baidu.com/static/index/baisou_iphone.png", "Referer=", ENDITEM,
"Url=http://a.m.baidu.com/rtstatic/index?&module=index&session=baiduapp&item=show", "Referer=http://m.baidu.com/?from=1269a", ENDITEM,
"Url=http://m.baidu.com/favicon.ico", "Referer=http://m.baidu.com/?from=1269a", ENDITEM,
"Url=http://m.baidu.com/su?p=3&ie=utf-8&from=wise_web&wd=%E5%A4%A9%E6%B0%94&t=1357630299189", "Referer=http://m.baidu.com/?from=1269a", ENDITEM,
LAST);
web_add_cookie("BAIDUID={CorrelationParameter}; DOMAIN=m.baidu.com");
web_add_cookie("BAIDUID={CorrelationParameter}; DOMAIN=wap.baidu.com");
web_add_cookie("BAIDUID={CorrelationParameter}; DOMAIN=opendata.baidu.com");
web_add_cookie("BAIDUID={CorrelationParameter}; DOMAIN=a.m.baidu.com");
web_add_cookie("lsv=2012122801; DOMAIN=a.m.baidu.com");
web_url("s",
"URL=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://m.baidu.com/?from=1269a",
"Snapshot=t8.inf",
"Mode=HTML",
EXTRARES,
"Url=/static/index/innovation/resultLogo2.png", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
"Url=/static/ala/weather_app/wa_weather_app_header_icon.png", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
"Url=/static/ala/weather_app/3.png", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
"Url=/static/ala/weather_app/7.png", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
"Url=/static/ala/weather_app/8.png", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
"Url=/static/ala/ui/foot/ala_icon.gif", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
"Url=/static/search/touch.gif", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
"Url=http://wap.baidu.com/static/freeapp/search/star01.png", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
"Url=/static/tj.gif?wise_app_ex_deg=0&wise_app_ex_type=4&wise_app_ex_order=6&da=1357630296", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
"Url=http://opendata.baidu.com/weatherSubscribe/getWeather?srcid=13269&wd=%E4%B8%8A%E6%B5%B7%E5%A4%A9%E6%B0%94&cb=wa_weather_app_jcb1357630301880", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
"Url=http://a.m.baidu.com/rtstatic/index?&module=se&session=baiduapp&item=show", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
"Url=http://wap.baidu.com/static/freeapp/search/star03.png", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
LAST);
web_add_cookie("lsv=2012122801; DOMAIN=m.baidu.com");
web_url("tc",
"URL=http://m.baidu.com/tc?tcreq4log=1&clk_type=1&vit=osres&l=1&w=0_10_%E5%A4%A9%E6%B0%94&t=iphone&ref=www_iphone&from=1269a&ssid=0&uid=E3069D4BD4613DEE9DEA2B5623E37775&lid=10632124265246805627&bd_page_type=1&pu=sz%401320_1001%2Cusm%403&fm=alop&order=1&ala_clk=3yT_1_0_10_b1&ala_mon=3yT_1_0_10_f_1357630301695_1357630303608&src=http%3A%2F%2Fm.weathercn.com%2F%3Fcid%3D01012601&ala_clk_t=%E6%9B%B4%E6%8D%A2&sec=1357630303608",
"Resource=0",
"Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=",
"Snapshot=t9.inf",
"Mode=HTML",
EXTRARES,
"Url=/static/ala/ui/city/city-3.js", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
"Url=/static/ala/ui/city/images/sprite.png", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
"Url=/static/ala/ui/city/images/loading.gif", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
LAST);
web_submit_data("sdk.php",
"Action=http://loc.map.baidu.com/sdk.php",
"Method=POST",
"RecContentType=text/plain",
"Referer=",
"Snapshot=t11.inf",
"Mode=HTML",
ITEMDATA,
/* "Name=bloc", "Value=4anu-KXsr6yu9fL8t_a-9-u8v6Hp4-jo8bDo3qK5r7LBhNW6ltfd04bW0t_b1dLTyZuc256WiMDDxZTdwdiUkLSxpbG7vrn84rm_uL22_rHk-fquq-aor66juPKh__b1l9vJ2ZSZn5aPlZ2YntqQmp6Mh4CPnMzP2NfZj93K09Fxfnx_ISUhbnQuKysnI2wgNmt7MjQ-cjE4MGV1OGtsf0EUXQ5fWEJTFQILAxlbFQYLFx1bFBdBRUFEFBdFFBMXNTNpMDM9Km0xPElFKzQkbmtyCHN5aHN0cyJyZ2Iyf3cJFlcUDyqsddj.|tp=3", ENDITEM, */
"Name=bloc","value=??'",ENDITEM,
LAST);
web_url("tc_2",
"URL=http://m.baidu.com/tc?tcreq4log=1&clk_type=1&vit=osres&l=1&w=0_10_%E5%A4%A9%E6%B0%94&t=iphone&ref=www_iphone&from=1269a&ssid=0&uid=E3069D4BD4613DEE9DEA2B5623E37775&lid=10632124265246805627&bd_page_type=1&pu=sz%401320_1001%2Cusm%403&ala_mon=Wg_3_0_10_l_1357630301892_1357630301937%7C3yT_1_0_10_l_1357630301695_1357630301889&src=m.baidu.com&sec=1357630305129",
"Resource=0",
"Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=",
"Snapshot=t10.inf",
"Mode=HTML",
EXTRARES,
"Url=http://miserupdate.aliyun.com/data/brfversion.xml", "Referer=", ENDITEM,
"Url=http://miserupdate.aliyun.com/data/brf.dat", "Referer=", ENDITEM,
LAST);
web_url("tc_3",
"URL=http://m.baidu.com/tc?tcreq4log=1&clk_type=1&vit=osres&l=1&w=0_10_%E5%A4%A9%E6%B0%94&t=iphone&ref=www_iphone&from=1269a&ssid=0&uid=E3069D4BD4613DEE9DEA2B5623E37775&lid=10632124265246805627&bd_page_type=1&pu=sz%401320_1001%2Cusm%403&fm=alop&order=1&ala_clk=3yT_1_0_10_b1&src=http%3A%2F%2Fm.weathercn.com%2F%3Fcid%3D01012601&ala_clk_t=%E6%9B%B4%E6%8D%A2&sec=1357630335810",
"Resource=0",
"Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=",
"Snapshot=t12.inf",
"Mode=HTML",
EXTRARES,
"Url=http://opendata.baidu.com/weatherSubscribe/getWeather?srcid=13269&wd=%E6%AD%A6%E6%B1%89%E5%A4%A9%E6%B0%94&cb=wa_weather_app_jcb1357630339472", "Referer=http://m.baidu.com/ssid=0/from=1269a/bd_page_type=1/uid=E3069D4BD4613DEE9DEA2B5623E37775/s?word=%E5%A4%A9%E6%B0%94&st=11104i&tj=i_sbtn0_6001_inp&sugv=1&hisv=0&tn=iphone&pu=sz%401320_1001&rawqs=&sug_edit=0&stime=1357630300923&loadtime=7656&mobile_se=0&showdirtype=", ENDITEM,
LAST);
return 0;
}
可以看出与我们传统录制的区别不是特别大。
但在这里需要注意两个问题:
1.可能会出现显示乱码问号的情况
这种情况网上说的很多其它办法可能都试过还不能解决,甚至是参数化显示正常,回话检查失败情况,先信誉度网上说的修改编码,最后还是不行就修改区域为中国就OK了。
2.通过IP筛选的时候,通常建议输入服务端地址,但这里没有通配功能,只能写准确地址,如果一个脚本中服务端有多个IP的时候再选择通过本地筛选。(具体wireshark可以看到每一个请求和应答报文)
下一篇将用一个实例来介绍关联处理。