首先小米源代码的一部分是一个非常非常大的字符串数组,分析它非常耗费时间,但是要搞明白必须去做。。
var _$ = [
//数组0位置,是空。
"",
//2位置,是抢购的开始日期的字符串“11/19/2013 12:00:00”
"\x31\x31\x2f\x31\x39\x2f\x32\x30\x31\x33\x20\x31\x32\x3a\x30\x30\x3a\x30\x30",
//3位置,是一个奇怪的网址:http://p.www.xiaomi.com/m/zt/open/index.htm
"\x68\x74\x74\x70\x3a\x2f\x2f\x70\x2e\x77\x77\x77\x2e\x78\x69\x61\x6f\x6d\x69\x2e\x63\x6f\x6d\x2f\x6d\x2f\x7a\x74\x2f\x6f\x70\x65\x6e\x2f\x69\x6e\x64\x65\x78\x2e\x68\x74\x6d\x6c",
"\x68\x74\x74\x70\x3a\x2f\x2f\x74\x63\x2e\x68\x64\x2e\x78\x69\x61\x6f\x6d\x69\x2e\x63\x6f\x6d\x2f\x68\x64\x67\x65\x74\x3f\x63\x61\x6c\x6c\x62\x61\x63\x6b\x3d\x68\x64\x63\x6f\x6e\x74\x72\x6f\x6c\x26\x5f\x3d",
//4位置,http://tc.hd.xiaomi.com/hdinfo?callback=hdinfo&_= 这样一个网址,估计是查看活动内容的
"\x68\x74\x74\x70\x3a\x2f\x2f\x74\x63\x2e\x68\x64\x2e\x78\x69\x61\x6f\x6d\x69\x2e\x63\x6f\x6d\x2f\x68\x64\x69\x6e\x66\x6f\x3f\x63\x61\x6c\x6c\x62\x61\x63\x6b\x3d\x68\x64\x69\x6e\x66\x6f\x26\x5f\x3d",
//5位置,http://t.hd.xiaomi.com/r/?_a=payment_check 这个是查看是否支付的
"\x68\x74\x74\x70\x3a\x2f\x2f\x74\x2e\x68\x64\x2e\x78\x69\x61\x6f\x6d\x69\x2e\x63\x6f\x6d\x2f\x72\x2f\x3f\x5f\x61\x3d\x70\x61\x79\x6d\x65\x6e\x74\x5f\x63\x68\x65\x63\x6b",
//6位置,http://t.hd.xiaomi.com/r/?_a=payment_check_tv 继续是payment_check_tv这个是电视的
"\x68\x74\x74\x70\x3a\x2f\x2f\x74\x2e\x68\x64\x2e\x78\x69\x61\x6f\x6d\x69\x2e\x63\x6f\x6d\x2f\x72\x2f\x3f\x5f\x61\x3d\x70\x61\x79\x6d\x65\x6e\x74\x5f\x63\x68\x65\x63\x6b\x5f\x74\x76",
//7位置,http://t.hd.xiaomi.com/r/?_a=payment_check_box 盒子的支付检验
"\x68\x74\x74\x70\x3a\x2f\x2f\x74\x2e\x68\x64\x2e\x78\x69\x61\x6f\x6d\x69\x2e\x63\x6f\x6d\x2f\x72\x2f\x3f\x5f\x61\x3d\x70\x61\x79\x6d\x65\x6e\x74\x5f\x63\x68\x65\x63\x6b\x5f\x62\x6f\x78",
//8,http://t.hd.xiaomi.com/r/?_a=20131105&_op=check 有个日期,不知道check什么,不过日期是5号的。
"\x68\x74\x74\x70\x3a\x2f\x2f\x74\x2e\x68\x64\x2e\x78\x69\x61\x6f\x6d\x69\x2e\x63\x6f\x6d\x2f\x72\x2f\x3f\x5f\x61\x3d\x32\x30\x31\x33\x31\x31\x30\x35\x26\x5f\x6f\x70\x3d\x63\x68\x65\x63\x6b",
分析到第9行,我开始犯懒了,写个程序来偷懒。。
list = []; for (var i = 0, l = arr.length; i < l; i++) { list[list.length] = '<li>' +i+': '+ arr[i] + ''; } list = '<ul>' + list.join('') + '</ul>'; document.getElementById("copyright").innerHTML=list;
解析的结果如下:
其中218行显示失败了,单独处理一下0:
1: 11/19/2013 12:00:00
2: http://p.www.xiaomi.com/m/zt/open/index.html
3: http://tc.hd.xiaomi.com/hdget?callback=hdcontrol&_=
4: http://tc.hd.xiaomi.com/hdinfo?callback=hdinfo&_=
5: http://t.hd.xiaomi.com/r/?_a=payment_check
6: http://t.hd.xiaomi.com/r/?_a=payment_check_tv
7: http://t.hd.xiaomi.com/r/?_a=payment_check_box
8: http://t.hd.xiaomi.com/r/?_a=20131105&_op=check
9: http://t.hd.xiaomi.com/r/?_a=20131105_tv&_op=check
10: http://t.hd.xiaomi.com/c/?_a=20131119_phone&_op=check
11: http://t.hd.xiaomi.com/c/?_a=20131119_tv&_op=check
12: http://t.hd.xiaomi.com/c/?_a=20131119_box&_op=check
13: http://t.hd.xiaomi.com/r/?_a=20131119&_op=book
14: http://t.hd.xiaomi.com/r/?_a=20131119_tv&_op=book
15: http://t.hd.xiaomi.com/r/?_a=20131119&_op=book
16: http://p.www.xiaomi.com/zt/xm_account/limitfacade.html?third=http%253A%252F%252Forder.xiaomi.com%252Flogin%252Fcallback%253Ffollowup%253Dhttp%25253A%25252F%25252Fp.www.xiaomi.com%25252Fopen%25252Findex.html%2526sign%253DYWY4NjlhMmExNzkzNGE5YTBjYjAzNzVjZTc1MmE5OTYwYmVlODc4NA%252C%252C%26sid%3Deshop&sid=eshop&callback=http%253A%252F%252Forder.xiaomi.com%252Flogin%252Fcallback%253Ffollowup%253Dhttp%25253A%25252F%25252Fp.www.xiaomi.com%25252Fopen%25252Findex.html%2526sign%253DYWY4NjlhMmExNzkzNGE5YTBjYjAzNzVjZTc1MmE5OTYwYmVlODc4NA%252C%252C&sign=9ZAFXvlDKGxSJhEBqKdOtQp633c%253D
17: orgin
18: xm_xt_prex
19: userId
20: xm_firbut_hd
21: DOMContentLoaded
22: onreadystatechange
23: DOMContentLoaded
24: onreadystatechange
25: left
26: string
27: [object Object]
28: number
29: =
30: ; expires=
31:
32: ; path=
33:
34: ; domain=
35:
36: ; secure
37:
38:
39: (?:^|; )
40: =([^;]*)
41: on
42: (^|&)
43: =([^&]*)(&|$)
44: i
45: -cache
46:
47: script
48: loaded
49: complete
50:
51: -cache
52: head
53: http://m.xiaomi.com
54: mapp
55: /
56: .xiaomi.com
57: Android
58: iPhone
59: iPod
60: Symbian
61:
62: http://t.hd.xiaomi.com/s/
63: /
64: .xiaomi.com
65: phone
66: box
67: tv
68: preLoad
69: none
70: hdTipInfo
71: none
72: showMore
73: none
74: tv
75: phone
76: box
77:
78: -reg
79: preLoad
80: none
81: hdTipInfo
82: none
83: showMore
84: none
85: hdinfo
86: undefined
87: preLoad
88: none
89: preLoad
90: <p>抱歉,网络拥堵无法连接服务器。由于访问人数太多导致服务器压力山大,请刷新页面重试~
91: preLoad
92: background:none;
93: hdTipInfo
94: none
95: showMore
96: none
97: <span>
98: </ins>小时
99: </ins>分
100: </ins>秒后开始
101: <span>
102: </ins>分
103: </ins>秒后开始
104: <span>
105: </ins>秒后开始
106: surTime
107: surTime
108: surTime
109: 正在加载中...
110:
111: boxbg
112: box
113: px
114: block
115: block
116: LoadingAnimate
117: none
118: none
119: hdget
120: hdBtns
121: hdSubTitle
122: hdLnks
123: hdMsg
124: mi3btn
125: mitvbtn
126: linksCon-span
127: 购买查询
128: <a class="btn" onClick="Util.showBox('phone');">购买手机
129: <a class="btn" onClick="Util.showBox('tv');">购买电视
130: <a class="btn" onClick="Util.showBox('box');">购买盒子
131: xm_pf_wl
132: <a class="btn" href="
133: " onClick="return Util.bookedPop('phone',this);">支付手机</a>
134: <a class="btn" href="
135: " target="_blank">预约手机</a>
136: xm_pft_wl
137: <a class="btn" href="
138: " onClick="return Util.bookedPop('tv',this);">支付电视</a>
139: <a class="btn" href="
140: " target="_blank">预约电视</a>
141: xm_pfb_wl
142: <a class="btn" href="
143: " onClick="return Util.bookedPop('box',this);">支付盒子</a>
144: <a class="btn" href="
145: " target="_blank">预约盒子</a>
146: <span class="untime">正在加载中...
147: <a class="btn" href="
148: " title="提前登录" >提前登录</a>
149: 11月19日星期二中午12点开放购买<br>小米3、小米电视、小米2S、红米手机、小米盒子
150: 开放购买所有产品已售罄,成功购买用户请尽快支付<br>下午3点将进行剩余订单专场
151: <a href="
152: " target="_blank">手机预约查询</a>
155: <a href="
156: " target="_blank">手机购买查询</a>
159: 购买成功用户请在2小时内下单,下单后2小时内支付<br/>购买成功用户支付通道:160: " onClick="return Util.bookedPop('phone',this);">支付手机</a>
163: 成功购买用户请在2小时内下单,下单后2小时内支付<br/>红米手机联通合约版首发,¥999起。立即购买
164:
165: <p class="btn-noStart">1999元(16GB)即将开始
166: <a onClick="Util.showBox('phone');" class="btn-mid" href="#">1999元(16GB)立即购买
167: <a class="btn-mid" href="
168: " onClick="return Util.bookedPop('phone',this);"><span>1999元(16GB)立即支付
169: <p class="btn-noStart">2999元即将开始
170: <a onClick="Util.showBox('tv');" class="btn-mid" href="#">2999元立即购买
171: <a class="btn-mid" href="
172: " onClick="return Util.bookedPop('tv',this);"><span>2999元立即支付
173:
174:
175:
176: <h3>对不起,
177: 都售罄了</h3>都是我不好,人数太多,机器太少。
别灰心,你可返回首页尝试购买
178: ,<br/>也可立即预约11月26日下轮开放购买。
返回活动首页
180: phone
181: 小米手机
182: 小米电视及小米盒子
183: tv
184: 小米电视
185: 小米手机及小米盒子
186: box
187: 小米盒子
188: 小米手机及小米电视
189: box-reg-wrap
190: box-reg-wrap
191: url(http://p.www.xiaomi.com/open/131101/images/mitu-2.png) no-repeat 5px 0
192: reback
193: box-close
194: X
195: 进入活动
196: reback_btn_next
197: 重新进入(<span id='initCount'>
198: </span>)
199: reback
200: hdget
201: _trackEvent
202: 活动
203: 抢购
204: 进入活动
205: box-close
206:
207: reback
208: reback_btn
209: top
210: topmitv
211: top
212: topmi3
213: undefined
214: videoBoxMask
215: px
216: px
217: block
218: <span class="close" onclick="Util.closeBox()" title="关闭">X
219: videoBox
220: data-url
221: {{videoUrl}}
222: block
223: videoBox
224: none
225: videoBox
226:
227: videoBoxMask
228: none
229:
230:
231:
232: <h3>很遗憾,您没有预约
233: 喔</h3>参与开放购买需要提前预约,别灰心,你可返回首页尝试购买
234: , 也可立即预约11月26日星期二开放购买</p>
返回活动首页
236: phone
237: 小米手机
238: 小米电视及小米盒子
239: tv
240: 小米电视
241: 小米手机及小米盒子
242: box
243: 小米盒子
244: 小米手机及小米电视
245: box-reg-wrap
246: box-reg-wrap
247: url(http://p.www.xiaomi.com/open/131101/images/mitu-1.png) no-repeat 5px 0
248:
249: phone
250: 购买手机
251: tv
252: 购买电视
253: box
254: 购买盒子
255: _trackEvent
256: 活动
257: 抢购
258: href
259: phone
260: tv
261: box
262: -reg
263: phone
264: tv
265: box
266: -reg
267: hdget
268: px 0
269: hdinfo
270:
271: XM_
272: _UN
273:
274:
275: script
276: https://account.xiaomi.com/pass/userInfoJsonP?userId=
277: &callback=loginInfo.getAccountInfo
278: text/javascript
279: head
280: LoginArea
281: LoginArea
282: 欢迎您
283: !<a href='http://order.xiaomi.com/site/logout'>退出
284: LoginArea
285: 12px
286: /
287: .xiaomi.com
288: XM_
289: _UN
290: box-cache-btn
291: hdget
292: linksCon
293: mouseover
294: hdLnks
295: block
296: linksCon-span
297: background-color:#fff;color:#333
298: linksCon
299: mouseout
300: hdLnks
301: none
302: linksCon-span
303: background:none;border:0;
304: _setAccount
305: UA-24946561-1
306: _addOrganic
307: baidu
308: word
309: _addOrganic
310: soso
311: w
312: _addOrganic
313: vnet
314: kw
315: _addOrganic
316: sogou
317: query
318: _addOrganic
319: youdao
320: q
321: _addOrganic
322: so
323: q
324: _setDomainName
325: xiaomi.com
326: _setAllowLinker
327: _trackPageview
328: script
329: text/javascript
330: https:
331: https://ssl
332: http://www
333: .google-analytics.com/ga.js
334: script
335: setDomainId
336: trackPageView
337: script
338: text/javascript
339: http://p.www.xiaomi.com/js/xmst.js
340: script
OK,第一篇完成。。
需要注意的是,其实我们点抢购按钮的时候,请求其实没有发送到服务器,而是被js给挡住了。
只有少数人的请求会通过js的限制,被提交到服务器。