http://www.tucao.tv/
吐槽彈幕網上的視頻資源和人氣已經不高,但是還是有些日劇會定期更新
以這個視頻網址為例:http://www.tucao.tv/play/h4075567/
網頁解析可以看到,是用 player.js 讀取一個異地的 mp4 file 來播放,而 mp4 file 的位置是從另外一個 json 文件裡讀取。
這個 json 的網址組成在 player.js 裡,所以解析就是先從網頁裡下載這個 player.js,然後打開這個 player.js 後
可以找到下面的 codes:
js 裡面建立這個 json 網址的邏輯相當單純,只是從網頁裡另外取出 type 和 vid 然後在網址最後加上 unix time,
組合後,再對照 chrome f12 過程裡的這個 json 網址是一致的。
接下來就是抓取 json 內容,不過因為是 ajax 調用,所以在 http header 除了 referrer 和 user-agent
需要填寫外,header origin 也需要再填入 origin 的 http://www.tucao.tv ,才能讀取到。
讀取到的 mp4 網址是:
https://gz189cloud2.oos-gz.ctyunapi.cn/10fc1963-7f15-44e7-8f7e-f5a1a5e1266d?response-content-type=video/mp4&Expires=1521156343&response-content-disposition=attachment%3Bfilename%3D%2299.9.Keiji.Senmon.Bengoshi.Season2.Ep08.Chi_Jap.HDTVrip.1280X720_%C3%A9%C2%87%C2%8D%C3%A5%C2%B0%C2%81%C3%A8%C2%A3%C2%85.mp4%22&AWSAccessKeyId=6667aad7f6576995b9ae&Signature=3HbvL6hRE0PM56GADHC2BF0buGo%3D
一般這樣異地的視頻檔案只要加上 http head 的 referer 頂多加個 user-agent 通常就可以下載成功了,這個 mp4 網址也不需要再作一次 url decode 直接下載即可。