1.网站sohu视频
https://tv.sohu.com/v/cGwvOTM5MjYyNy85ODA0NzU4NS5zaHRtbA==.html
2.获取JS数据
GET https://js.tv.itc.cn/player/h5player_8563b2.js HTTP/1.1
Host: js.tv.itc.cnConnection: keep-alive*
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36Intervention:; level="warning"*
Accept: */*
Referer: https://tv.sohu.com/v/cGwvOTM5MjYyNy85ODA0NzU4NS5zaHRtbA==.html
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
3.分析JS数据
h5player_xxxx.js里面请求函数如下:
function(e) {
var t = e.vid,
i = e.resolution,
o = e.pwd,
a = "//my.tv.sohu.com/play/videonew.do?" + r.
default.stringify({
vid:
t,
ver: i,
ssl: 0 == window.location.href.indexOf("https") ? 1 : 2,
referer: window.location.href,
t: (new Date).getTime(),
passwd: o
});
return n.
vid参数可以从网页源代码获取,不再赘述。
实际请求结果:
GET https://my.tv.sohu.com/play/videonew.do?vid=98047585&ver=&ssl=1&referer=https%3A%2F%2Ftv.sohu.com%2Fv%2FcGwvOTM5MjYyNy85ODA0NzU4NS5zaHRtbA%3D%3D.html&t=1536333633784&passwd= HTTP/1.1
Host: my.tv.sohu.com
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
Accept: */*
Referer: https://tv.sohu.com/v/cGwvOTM5MjYyNy85ODA0NzU4NS5zaHRtbA==.html
请求数据返回Json字符串
{"prot":2,"ct":39,"allot":"vipbjyz.vod.tv.itc.cn","reserveIp":"vipgdbgp.vod.tv.itc.cn","vr":0,"vt":1,"tn":5,"sp":1024,"pid":9392627,"status":1,"play":1,"pL":10,"url":"http://my.tv.sohu.com/us/310340515/98047585.shtml","uS":-1,"fms":0,"isdl":1,"holiday":"0","catcode":127106,"systype":1,"cmscat":"10000001;10000001_127106","id":"98047585_1","p2pflag":1300,"nt":1,"tvid":98047585,"wm_data":{"wm_username":"\u5C0F\u7FD4XIANG","wm_userphoto":"http://001.img.pu.sohu.com.cn/group3/M10/A9/DA/MTAuMTAuODguODM=/MTAwMTE0XzE1MDQyNDcyNDcxMDc=/cut@m=crop,x=0,y=0,w=200,h=200.jpg","wm_video":1,"wm_isact":1,"wm_publisher":1,"wm_playtype":0,"ugu":"310340515","ugcode":"MTUkfdby2mtsz8QJo-zyC5mZGw6fecwX-XCawlk_JCwZ24G12sALibmxjt05F5POTyyVx0lGGj8ITzDrFSkbnxCyx-2xTAjGpjKL","wm_user":20,"fc_user":1,"fc_video":1,"wm_filing":""},"pay_data":{},"data":{"tvName":"\u4E09\u661FGalaxy S9/S9\uFF0B\u56DB\u8272\u63ED\u9732\uFF1F\u4E01\u9999\u7D2B\u5168\u65B0\u767B\u573A\uFF01","keyword":"\u79D1\u6280 \u5C0F\u7FD4XIANG \u6570\u7801 \u624B\u673A \u4E09\u661FS9/S9","tag":"\u79D1\u6280 \u5C0F\u7FD4XIANG \u6570\u7801 \u624B\u673A \u4E09\u661FS9/S9","ch":"pgc","cid":127106,"myTvUid":310340515,"fps":"","ipLimit":"","width":0,"height":0,"clipsURL":[""],"version":1,"clipsBytes":["9784487"],"num":1,"coverImg":"http://001.img.pu.sohu.com.cn/group3/M10/C5/5E/MTAuMTAuODguODM=/MTAwMTE0XzE1MTgxOTQ4NjYzMDk=.jpg","totalDuration":146,"totalBytes":9784487,"clipsDuration":[146],"relativeId":"","totalBlocks":1,"ck":["Y-6jMyOxnsY950v55Q2W6aEVAAJyWj98"],"hc":["TYV6KMPMKQ2XAOWBVE37BKE6M7OG4GG3"],"su":["/111/162/3D4U8DomJrNdKjM5g5DAJC.mp4"],"sT":0,"norVid":"","highVid":"98047585_1","superVid":"98047585_21","oriVid":"98047585_31","eT":0,"eP":null},"syst":1536333673479,"dm":0,"isSelf":0,"audited_level":0}
4.获取真实地址
继续分析h5player_xxxx.js里面请求函数如下
js请求
N.prototype.checkMovieInfo = function(e) {
if (void 0 === e.vid || void 0 === e.ch || void 0 === e.videos) return ! 1;
console.info(N.getTimeNow(), "start playing, vid is " + e.vid),
e.totalDuration = 0,
e.totalSize = 0;
for (var t = 0; t < e.videos.length; t++) {
var i = e.videos[t];
void 0 === i.dispatch && (i.dispatch = "https://data.vod.itc.cn/ip?new=" + i.fileName + "&num=1&key=" + i.key + "&ch=" + e.ch + "&pt=1&pg=2&prod=h5n"),
console.info(i.dispatch),
e.totalDuration += Number(i.duration),
e.totalSize += Number(i.size)
}
return ! 0
},
实际构造请求:
GET https://data.vod.itc.cn/ip?new=/111/162/3D4U8DomJrNdKjM5g5DAJC.mp4&num=1&key=Y-6jMyOxnsY950v55Q2W6aEVAAJyWj98&ch=pgc&pt=1&pg=2&prod=h5n HTTP/1.1
Host: data.vod.itc.cn
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36Referer: https://tv.sohu.com/v/cGwvOTM5MjYyNy85ODA0NzU4NS5zaHRtbA==.html
返回json结果
{"servers":[{"nid":644,"isp2p":1,"url":"http://58.211.10.165/sohu/v1/TmwGoEIsWGvHW4P48Dd6qV4l0EXAhtkWWM04b6KlPOXUyYbSoO27fSx.mp4?k=1xXyer&p=XfXIWJo70F2svmfCZM1mNOo70ScAZMx4gf&r=TUldziJCtpCmhWB3tSCGhWlvsmCUqpxWtWaizY&q=OpCGoKOyzSwWsSCAomrGhWqDXpCAoSvyoSxCTLwm0K7G0poWjpCAqSsdqSsAoEOgzSw3oY&cip=xxx.xxx.xxx.xxx"}]}
0
cip 结果我遮盖了。
整个流程结束。
大功告成!