第一篇我们介绍了如何通过LR来捕获手机发出的真实访问数据,这一篇我们将介绍捕获数据之后的操作。
  接第一篇:
  1. 用wireshark 捕获手机访问的数据后,可以根据协议来筛选仅HTML或者不筛选让LR自己分析。选择另存将wireshark 获取的数据包保存为.pcap格式。
  2. 打开LR11.5(至少是以上版本才支持此协议)。选择 mobile http/html协议。
  2.选择录制
  3.选择导出的.pcap文件,并选择第二项,通过分析数据以生成脚本,其它用默认即可。
  4.导入后我们来看一下生成的脚本代码
Action()
{
web_add_cookie("QN48=tc_f39fc2c153a007a1_13c29f5c48b_90e7; DOMAIN=touch.qunar.com");
web_add_cookie("QN1=wKgZEVDwHiZ0pjsMBcTaAg==; DOMAIN=touch.qunar.com");
web_add_cookie("QN48=tc_f39fc2c153a007a1_13c29f5c48b_90e7; DOMAIN=bc.qunar.com");
web_add_cookie("QN1=wKgZEVDwHiZ0pjsMBcTaAg==; DOMAIN=bc.qunar.com");
web_url("touch.qunar.com",
"URL=http://touch.qunar.com/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
EXTRARES,
"Url=http://bc.qunar.com/wap?utmwv=0.1&t=0.7578790553379804&utmsr=720*1280&utmr=-1&utmp=http%3A%2F%2Ftouch.qunar.com%2F&utmhn=touch.qunar.com&s=266&a=tw_index", ENDITEM,
LAST);
web_link("SelectFlight",
"Text=SelectFlight",
"Snapshot=t2.inf",
EXTRARES,
"Url=http://bc.qunar.com/wap?utmwv=0.1&t=0.4847093583084643&utmsr=720*1280&utmr=http%3A%2F%2Ftouch.qunar.com%2F&utmp=http%3A%2F%2Ftouch.qunar.com%2Fflight.jsp%3Fbd_source%3Dqunar%26backUrl%3D%252F&utmhn=touch.qunar.com&s=254&a=tw_flightIndex", "Referer=http://touch.qunar.com/flight.jsp?bd_source=qunar&backUrl=%2F", ENDITEM,
"Url=/filghtCitySuggest.jsp?city=%25E4%25B8%258A%25E6%25B5%25B7&_=1357913752957", "Referer=http://touch.qunar.com/flight.jsp?bd_source=qunar&backUrl=%2F", ENDITEM,
"Url=/filghtCitySuggest.jsp?city=%25E6%25AD%25A6%25E6%25B1%2589&_=1357913758311", "Referer=http://touch.qunar.com/flight.jsp?bd_source=qunar&backUrl=%2F", ENDITEM,
LAST);
web_add_cookie("QN48=tc_f39fc2c153a007a1_13c29f5c48b_90e7; DOMAIN=source.qunar.com");
web_add_cookie("QN1=wKgZEVDwHiZ0pjsMBcTaAg==; DOMAIN=source.qunar.com");
web_url("flightList.jsp",
"URL=http://touch.qunar.com/flightList.jsp?startDate=2013-01-13&backDate=2013-01-16&flightType=oneWay&bd_source=qunar&backUrl=%2Fflight.jsp%3FbackUrl%3D%252F%26bd_source%3Dqunar&startCity=%e6%88%90%e9%83%bd&destCity=%E6%AD%A6%E6%B1%89",
"Resource=0",
"RecContentType=text/html",
"Referer=http://touch.qunar.com/flight.jsp?bd_source=qunar&backUrl=%2F",
"Snapshot=t3.inf",
"Mode=HTML",
EXTRARES,
"Url=http://bc.qunar.com/wap?utmwv=0.1&t=0.8687613171059638&utmsr=720*1280&utmr=http%3A%2F%2Ftouch.qunar.com%2Fflight.jsp%3Fbd_source%3Dqunar%26backUrl%3D%252F&utmp=http%3A%2F%2Ftouch.qunar.com%2FflightList.jsp%3FstartDate%3D2013-01-13%26backDate%3D2013-01-16%26flightType%3DoneWay%26bd_source%3Dqunar%26backUrl%3D%252Fflight.jsp%253FbackUrl%253D%25252F%2526bd_source%253Dqunar%26startCity%3D%25E4%25B8%258A%25E6%25B5%25B7%26destCity%3D%25E6%25AD%25A6%25E6%25B1%2589&utmhn=touch.qunar.com&s=255&a="
"tw_flightList", "Referer=http://touch.qunar.com/flightList.jsp?startDate=2013-01-13&backDate=2013-01-16&flightType=oneWay&bd_source=qunar&backUrl=%2Fflight.jsp%3FbackUrl%3D%252F%26bd_source%3Dqunar&startCity=%e6%88%90%e9%83%bd&destCity=%E6%AD%A6%E6%B1%89", ENDITEM,
"Url=http://source.qunar.com/site/images/wap/touch/images/sp.v.png", "Referer=http://touch.qunar.com/flightList.jsp?startDate=2013-01-13&backDate=2013-01-16&flightType=oneWay&bd_source=qunar&backUrl=%2Fflight.jsp%3FbackUrl%3D%252F%26bd_source%3Dqunar&startCity=%E4%B8%8A%E6%B5%B7&destCity=%E6%AD%A6%E6%B1%89", ENDITEM,
"Url=http://source.qunar.com/site/images/wap/touch/images/icon.r.png", "Referer=http://touch.qunar.com/flightList.jsp?startDate=2013-01-13&backDate=2013-01-16&flightType=oneWay&bd_source=qunar&backUrl=%2Fflight.jsp%3FbackUrl%3D%252F%26bd_source%3Dqunar&startCity=%E4%B8%8A%E6%B5%B7&destCity=%E6%AD%A6%E6%B1%89", ENDITEM,
"Url=http://source.qunar.com/site/images/wap/touch/images/icon.top.png", "Referer=http://touch.qunar.com/flightList.jsp?startDate=2013-01-13&backDate=2013-01-16&flightType=oneWay&bd_source=qunar&backUrl=%2Fflight.jsp%3FbackUrl%3D%252F%26bd_source%3Dqunar&startCity=%E4%B8%8A%E6%B5%B7&destCity=%E6%AD%A6%E6%B1%89", ENDITEM,
"Url=http://source.qunar.com/site/images/wap/touch/images/icon.asc.png", "Referer=http://touch.qunar.com/flightList.jsp?startDate=2013-01-13&backDate=2013-01-16&flightType=oneWay&bd_source=qunar&backUrl=%2Fflight.jsp%3FbackUrl%3D%252F%26bd_source%3Dqunar&startCity=%E4%B8%8A%E6%B5%B7&destCity=%E6%AD%A6%E6%B1%89", ENDITEM,
LAST);
return 0;
}
  5.通过以上我们可以看出生成的脚本是基于手机版的,去哪网的数据。
  如果你对lr 操作比较了解的话,上面一步之后可能会想到参数化,如果在尝试后可能会发现有一个问题出现。如:
  url=http://touch.qunar.com/flightList.jsp?startDate=2013-01-13&backDate=2013-01-16&flightType=oneWay&bd_source=qunar&backUrl=%2Fflight.jsp%3FbackUrl%3D%252F%26bd_source%3Dqunar&startCity=%e6%88%90%e9%83%bd&destCity=%E6%AD%A6%E6%B1%89",
  通过观察我们知道这里面提交数据是通过get方式,URL传递数据的,所以在参数化的过程中需要对这里面的参数进行修改。
  日期和单程往返都很好操作,问题是出发地点和目的地中文是经过编码的,这个时候怎么办呢?
  几种办法解决:
  1.好是自己编写中文转utf-8的dll加载,是好的方式。
  2.如果借助其它工具好编码后,填在参数表里面。
  下面我们来看一下借助工具解码后,上面URL中所包含的信息
  到这里相信大家知道怎么在这种情况下对此进行参数化了。
  下面我们来看一下手动关联后的脚本情况:
  好不要用自动关联,虽然LR11.5已经准确了不少,但还是会出现截取不准确的情况。
  C代码
1 <span>Action()
2 {
3 char  DistrictName[15]={NULL},
4         CityCode[20]={NULL},
5         ProvinceCode[20]={NULL},
6         DistrictCode[20]={NULL};
7 int     DistrictSequence=0;
8 web_add_cookie("JSESSIONID=6B75C5017659AA3BFB2C89746A16D20F; DOMAIN=m.weathercn.com");
9 </span>
type url,the default city code is shanghai, you can parameterize it
这里默认定位是上海,可通过后面的关联将省代码获取到,然后进行参数化避免每次打开都是上海C代码
10 <span style="font-family: 'Microsoft YaHei',微软雅黑,SimHei,tahoma,arial,helvetica,sans-serif;">web_url("m.weathercn.com",
11         "URL=http://m.weathercn.com/?cid=01012601",
12         "Resource=0",
13         "RecContentType=text/html",
14         "Referer=",
15         "Snapshot=t1.inf",
16         "Mode=HTTP",
17         LAST);
18
19 </span>
20 <span>
21 /*select province*/
22