视频网站地址解析下载

360影视视频的地址解析下载

2016-11-01  本文已影响798人  Maslino

以360影视播放页地址http://v.360kan.com/sv/cIPmaWPqUBT5TC.html 为例,说说如何得到视频的真实地址。

同样,我们使用浏览器的开发者工具观察页面视频加载过程中出现了哪些值得关注的网络请求,然后分析这些请求之间的关联关系。

第一步,请求接口 http://v.360kan.com/Shortvideo/ajaxApi?id=cIPmaWPqUBT5TC&_=1478005639801 返回如下JSON数据:

{
  "errno": 0,
  "error": "ok",
  "result": {
    "discuss": {
      "unikey": "cIPmaWPqUBT5TC"
    },
    "share": {
      "title": "歼20亮相珠海航展",
      "url": "http://v.360kan.com/sv/cIPmaWPqUBT5TC.html",
      "desc": "歼20亮相珠海航展",
      "pic": "http://p4.qhimg.com/t01d2a7df91a54e3b5e.jpg"
    },
    "midbar": {
      "h5": "http://m.v.360kan.com/sv/cIPmaWPqUBT5TC.html",
      "playNumber": "22.4万",
      "date": "2016-11-01"
    },
    "topbar": {
      "title": "歼20亮相珠海航展",
      "type": [
        "歼20",
        "亮相"
      ],
      "bread": [
        {
          "text": "360影视",
          "url": "http://www.360kan.com/"
        },
        "现场"
      ]
    },
    "video": {
      "recommend": [
        {
          "title": "网爆何炅小腿骨折受伤入院",
          "cover": "http://p3.qhimg.com/t013dc0d59b2c28549e.jpg",
          "url": "http://v.360kan.com/sv/bYbqcmPqUBT6SS.html"
        },
        {
          "title": "相恋结婚9年 丈夫竟然变妻子?",
          "cover": "http://p7.qhimg.com/t01359b0b35aa2b187b.gif",
          "url": "http://v.360kan.com/sv/cIPocWPqUBT6Sy.html"
        },
        {
          "title": "反转!曝马蓉将告宋喆强奸",
          "cover": "http://p4.qhimg.com/t0184ab1ceb64d990ab.jpg",
          "url": "http://v.360kan.com/sv/coTkamPqUBH3Ti.html"
        },
        {
          "title": "爆笑!盘点那些奇葩的开门方式",
          "cover": "http://p1.qhimg.com/t015fa4d2fd82b0d944.jpg",
          "url": "http://v.360kan.com/sv/b4TqaWPqUBT5Si.html"
        },
        {
          "title": "网曝两女子和狗围攻老人 老人被打倒在地猛踹",
          "cover": "http://p2.qhimg.com/dmb/380_220_/t019c94eb2edd62b7fe.gif",
          "url": "http://v.360kan.com/sv/cobpbWPqUBTyUS.html",
          "date": "2016110101"
        },
        {
          "title": "印度村庄现神秘“笑脸蛇”",
          "cover": "http://p1.qhimg.com/t015fb97534120d13e9.jpg",
          "url": "http://v.360kan.com/sv/cYLjbGPqUBT6SC.html"
        }
      ],
      "relate": [
        {
          "title": "歼20亮相珠海航展",
          "id": "cIPmaWPqUBT5TC",
          "cover": "http://p4.qhimg.com/t01d2a7df91a54e3b5e.jpg",
          "url": "http://info.play.tvfanqie.com/video/getplay?mid=1b190d3186c3d889102d9eebcd2274e1&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006714&_sign=bb308556dd4d97ab9d57b4689c36ed38",
          "duration": "00:42",
          "playNum": "22.4万"
        },
        {
          "title": "男女偷情被抓双双遭暴打 女子衣服惨被扒光",
          "id": "c4TocmPoShX7TC",
          "cover": "http://p5.qhimg.com/t01b64185b8a0ac1a5e.jpg",
          "url": "http://info.play.tvfanqie.com/video/getplay?mid=fed04ada224cccac803a7d9f9cc6fddf&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006714&_sign=bb55de39b3eef0e60f7f874888a3887e",
          "duration": "02:12",
          "playNum": "3.2万"
        },
        {
          "title": "实拍小偷行窃当街被抓 上演“铁头功”连撞公交站台",
          "id": "cIfqcWLrThD1TS",
          "cover": "http://p7.qhimg.com/t015201256458b2c68b.jpg",
          "url": "http://info.play.tvfanqie.com/video/getplay?mid=21503944ec58fdcc1dea9be60e094c04&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006714&_sign=6bdfdedbe3323d3974c780023aa63d6f",
          "duration": "02:55",
          "playNum": "15.2万"
        },
        {
          "title": "实拍奇葩男子冒雨碰瓷 先敬个礼再摔倒",
          "id": "corjaWPqUBL4TC",
          "cover": "http://p0.qhimg.com/t01c44f03d525093473.jpg",
          "url": "http://info.play.tvfanqie.com/video/getplay?mid=1bb8d4ed28679604ba852eadfa6c36cb&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006714&_sign=92c9d4c442c041f0579cebc8f640288e",
          "duration": "01:32",
          "playNum": "5.4万"
        },
        {
          "title": "实拍生产化机器杀猪过程 批量从活猪到猪肉让屠夫都看傻眼了",
          "id": "b4XlbWPqUBn3SS",
          "cover": "http://p5.qhimg.com/t01af562aad8863daf7.jpg",
          "url": "http://info.play.tvfanqie.com/video/getplay?mid=e4b8aa7a337f1e1f22e0addf5ee9dc1f&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006714&_sign=17c71712da094ef5b439a6423b7549ce",
          "duration": "04:55",
          "playNum": "4.6万"
        },
        {
          "title": "贵圈真乱!游戏嫩模自曝拍完照与摄影师发生关系",
          "id": "cYLrbmPqURf6UC",
          "cover": "http://p0.qhimg.com/t019fd8d88f6baae719.jpg",
          "url": "http://info.play.tvfanqie.com/video/getplay?mid=2e0653a8de5cfa885530f940fc62e45b&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006714&_sign=1c287b903f08233b373280ca02d98861",
          "duration": "00:58",
          "playNum": 1991
        },
        {
          "title": "太魔性了!来自妈妈的爱 劝你穿秋裤时操老心了",
          "id": "b4Xna2PqURf6US",
          "cover": "http://p9.qhimg.com/t01275df3055c38a7fc.jpg",
          "url": "http://info.play.tvfanqie.com/video/getplay?mid=2dfcc594cdb83f5c6433e1d1790538e0&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006714&_sign=c9ac226d357c89e2b32ffe99aa975122",
          "duration": "00:48",
          "playNum": 1408
        },
        {
          "title": "外围女花巨资整容陪吸毒月入80万 00后最吃香",
          "id": "c4Lla2PqURf7Sy",
          "cover": "http://p2.qhimg.com/t0169ebc7fbe667f305.jpg",
          "url": "http://info.play.tvfanqie.com/video/getplay?mid=3d18abe70354ed86a6394838d7937aee&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006714&_sign=4bc227ef8b79a940c391be5dd2ba8b33",
          "duration": "01:26",
          "playNum": 1540
        },
        {
          "title": "男子带瓶眼镜蛇坐火车 安检喊你喝一口",
          "id": "bofmcWPqURf7TC",
          "cover": "http://p9.qhimg.com/t0188d8de26e95b29c7.jpg",
          "url": "http://info.play.tvfanqie.com/video/getplay?mid=d3cae0356d2d6b56efc8ea238e5bd7a6&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006714&_sign=e584122bb32e76a55b6661ff819430be",
          "duration": "00:58",
          "playNum": 1367
        },
        {
          "title": "3D还原重庆煤矿瓦斯爆炸“气流扑来像龙卷风”",
          "id": "dofmamPqURj0TS",
          "cover": "http://p1.qhimg.com/t0151466a9f86c514e3.jpg",
          "url": "http://info.play.tvfanqie.com/video/getplay?mid=208feb8616d56696b3ad1d02a30b7b25&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006714&_sign=a6df809a529d48ca155fb7d82e40e3d5",
          "duration": "02:15",
          "playNum": 860
        },
        {
          "title": "毛骨悚然!实拍成群浣熊伸手寻找食物 上演现实版鬼片",
          "id": "cYTpamPqURj2SS",
          "cover": "http://p4.qhimg.com/t013328b2cea49c24d8.jpg",
          "url": "http://info.play.tvfanqie.com/video/getplay?mid=7f76f93350c115ea4e3be22a385c3bd8&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006714&_sign=0a9ae326fda916764309dd2dc0999ae2",
          "duration": "01:11",
          "playNum": 1342
        },
        {
          "title": "这不是电影!罕见纪实影像揭秘二战战场残酷历史瞬间",
          "id": "cYTlcmPqURj6UC",
          "cover": "http://p6.qhimg.com/t01bc2dd91caebfb8a3.jpg",
          "url": "http://info.play.tvfanqie.com/video/getplay?mid=9f398dbe5b946ed403454d5337b63c34&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006714&_sign=2df037734dc115ae81324e8382c69965",
          "duration": "03:26",
          "playNum": 646
        },
        {
          "title": "2016马云现场对话李连杰和马化腾,全场笑声一波接一波!",
          "id": "b4bmaWPqURj7UC",
          "cover": "http://p2.qhimg.com/t01a3a16cc9dfaa4246.jpg",
          "url": "http://info.play.tvfanqie.com/video/getplay?mid=4067c7d8db40ae057c5175923bf6ad82&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006714&_sign=1b84e860cb553fc41a009d2c1e3beba9",
          "duration": "17:32",
          "playNum": 1400
        },
        {
          "title": "皮条客揭外围圈内幕:花巨资整容 00后最吃香",
          "id": "doXobGPqURn0SC",
          "cover": "http://p2.qhimg.com/t01c9b6639786204e68.jpg",
          "url": "http://info.play.tvfanqie.com/video/getplay?mid=9383b8c70292100ff9b7349678b2111c&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006714&_sign=0e7e60413ff5b6d02bd22612c4792d5e",
          "duration": "02:08",
          "playNum": "3.1万"
        },
        {
          "title": "圆状UFO飞进日本村庄 被公路上的监控拍了下来\n",
          "id": "boPkcWPrSBD4SC",
          "cover": "http://p6.qhimg.com/t01a94e5f559687391a.jpg",
          "url": "http://info.play.tvfanqie.com/video/getplay?mid=401f877c136365c6750b5ef50005efbe&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006714&_sign=e3982a9e2d432e2774470c333e99044d",
          "duration": "02:42",
          "playNum": 771
        },
        {
          "title": "萌cry!馋嘴的小贝壳 偷偷伸出舌头偷盐吃",
          "id": "cYLmaWPrSBD4SS",
          "cover": "http://p6.qhimg.com/t01da8d3f400a1ff300.jpg",
          "url": "http://info.play.tvfanqie.com/video/getplay?mid=406f930631e7fa3505e695d5717a7151&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006714&_sign=1a1b8dd34287ba29c3b02bda54440a6b",
          "duration": "00:38",
          "playNum": 280
        },
        {
          "title": "姐弟俩为争房产 互向对方租客泼屎尿",
          "id": "c4Tsa2PrSBD4Sy",
          "cover": "http://p9.qhimg.com/t010e876a6ae8591f8f.jpg",
          "url": "http://info.play.tvfanqie.com/video/getplay?mid=641d13dd42ac8b75472336c9c6ae4065&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006714&_sign=79b02c835c13e97999909d4b237283e9",
          "duration": "01:34",
          "playNum": 626
        },
        {
          "title": "贵圈真乱!游戏嫩模自曝拍完照与摄影师发生关系",
          "id": "c4TjbGPrSBD6UC",
          "cover": "http://p5.qhimg.com/t013d881b0eeb5beee6.jpg",
          "url": "http://info.play.tvfanqie.com/video/getplay?mid=af9795712c811ac927662bfd25a61f4f&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006714&_sign=9d3cdc50c6b28ca44ffe4429008b07b7",
          "duration": "01:02",
          "playNum": "2.8万"
        },
        {
          "title": "惊心动魄!夫妻酒店泳池嬉戏遭鳄鱼闯入袭击 丈夫第一时间逃离",
          "id": "dYTmaWPrSBL5US",
          "cover": "http://p4.qhimg.com/t01f66efc1a341141c2.jpg",
          "url": "http://info.play.tvfanqie.com/video/getplay?mid=5a273a1f0858c077b216f21991347ddb&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006714&_sign=3f0233cd1c9beb8b28797a0e55bd3a6a",
          "duration": "01:10",
          "playNum": 110
        },
        {
          "title": "罗马尼亚老师掌掴5岁学童 夸张画面让人不忍直视",
          "id": "doblbGPrSBL6Si",
          "cover": "http://p3.qhimg.com/t01ed2df3949305e343.jpg",
          "url": "http://info.play.tvfanqie.com/video/getplay?mid=0f7de783e8ac374ae65360eef075d2c9&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006714&_sign=a92857cb0a890d76417c1ca956a75dfc",
          "duration": "01:14",
          "playNum": 576
        }
      ]
    },
    "guess": [
      {
        "title": "男子微信摇来女网友 不想对方竟是男儿身",
        "id": "dYjqb2PqURf7SS",
        "cover": "http://p6.qhimg.com/t01bda779e5aaa4af9d.jpg",
        "url": "http://v.360kan.com/sv/dYjqb2PqURf7SS.html",
        "duration": "00:40",
        "playNum": 976
      },
      {
        "title": "外围女花巨资整容陪吸毒月入80万 00后最吃香",
        "id": "c4Lla2PqURf7Sy",
        "cover": "http://p2.qhimg.com/t0169ebc7fbe667f305.jpg",
        "url": "http://v.360kan.com/sv/c4Lla2PqURf7Sy.html",
        "duration": "01:26",
        "playNum": 1540
      },
      {
        "title": "男子带瓶眼镜蛇坐火车 安检喊你喝一口",
        "id": "bofmcWPqURf7TC",
        "cover": "http://p9.qhimg.com/t0188d8de26e95b29c7.jpg",
        "url": "http://v.360kan.com/sv/bofmcWPqURf7TC.html",
        "duration": "00:58",
        "playNum": 1367
      },
      {
        "title": "这不是电影!罕见纪实影像揭秘二战战场残酷历史瞬间",
        "id": "cYTlcmPqURj6UC",
        "cover": "http://p6.qhimg.com/t01bc2dd91caebfb8a3.jpg",
        "url": "http://v.360kan.com/sv/cYTlcmPqURj6UC.html",
        "duration": "03:26",
        "playNum": 646
      },
      {
        "title": "2016马云现场对话李连杰和马化腾,全场笑声一波接一波!",
        "id": "b4bmaWPqURj7UC",
        "cover": "http://p2.qhimg.com/t01a3a16cc9dfaa4246.jpg",
        "url": "http://v.360kan.com/sv/b4bmaWPqURj7UC.html",
        "duration": "17:32",
        "playNum": 1400
      },
      {
        "title": "圆状UFO飞进日本村庄 被公路上的监控拍了下来\n",
        "id": "boPkcWPrSBD4SC",
        "cover": "http://p6.qhimg.com/t01a94e5f559687391a.jpg",
        "url": "http://v.360kan.com/sv/boPkcWPrSBD4SC.html",
        "duration": "02:42",
        "playNum": 771
      },
      {
        "title": "少女晚上跟爸爸哥哥同住一屋 竟发生了可怕的事",
        "id": "bYbmb2PrSBD4Si",
        "cover": "http://p2.qhimg.com/t01cf0960afcbacdab6.jpg",
        "url": "http://v.360kan.com/sv/bYbmb2PrSBD4Si.html",
        "duration": "04:37",
        "playNum": 1358
      },
      {
        "title": "实拍丰田违停4男子猛砸宝马车  宝马车气不过连续猛撞丰田",
        "id": "dYjmaWPrSBD6Ty",
        "cover": "http://p0.qhimg.com/t01ff4baf0f2d10eced.jpg",
        "url": "http://v.360kan.com/sv/dYjmaWPrSBD6Ty.html",
        "duration": "02:02",
        "playNum": 2540
      },
      {
        "title": "惊心动魄!夫妻酒店泳池嬉戏遭鳄鱼闯入袭击 丈夫第一时间逃离",
        "id": "dYTmaWPrSBL5US",
        "cover": "http://p4.qhimg.com/t01f66efc1a341141c2.jpg",
        "url": "http://v.360kan.com/sv/dYTmaWPrSBL5US.html",
        "duration": "01:10",
        "playNum": 110
      },
      {
        "title": "实拍恩施一奇葩男子冒雨碰瓷有礼貌 先敬个礼再摔倒",
        "id": "cYrnbWPrSBL6TS",
        "cover": "http://p4.qhimg.com/t017fd9fe803a973a99.jpg",
        "url": "http://v.360kan.com/sv/cYrnbWPrSBL6TS.html",
        "duration": "01:35",
        "playNum": 985
      }
    ],
    "todayHot": [
      {
        "title": "张雨绮称老公未婚",
        "desc": "但有人却晒了他的结婚照",
        "cover": "http://p6.qhimg.com/t014495cdef1c986575.jpg",
        "url": "http://v.360kan.com/sv/cITnbGPqTBj6US.html"
      },
      {
        "title": "印度村庄现神秘“笑脸蛇”",
        "cover": "http://p1.qhimg.com/t015fb97534120d13e9.jpg",
        "url": "http://v.360kan.com/sv/cYLjbGPqUBT6SC.html"
      },
      {
        "title": "贾静雯全家过万圣节",
        "desc": "咘咘梧桐妹大眼软萌",
        "cover": "http://p0.qhimg.com/t0150b403e057674f4e.jpg",
        "url": "http://v.360kan.com/sv/dYXmbmPqSxj0SS.html"
      },
      {
        "title": "心疼!何炅急送医院手术 疑因金属异物插入小腿",
        "desc": "何炅意外被异物扎伤 不愿轻易下火线 被赞中国好主持!",
        "cover": "http://p0.qhimg.com/t011b2b8a18af8d3b17.jpg",
        "url": "http://v.360kan.com/sv/coPma2PqUBH1UC.html"
      },
      {
        "title": "董明珠因进门没掌声怒骂股东",
        "cover": "http://p4.qhimg.com/t0174bf89dcd8a46e61.jpg",
        "url": "http://v.360kan.com/sv/cYLoamPqShPyUS.html"
      },
      {
        "title": "萌娃扮无脸男酷到没朋友 网友:妈妈下手太重了",
        "cover": "http://p0.qhimg.com/dmb/380_220_/t01fa84b47e6de625d4.jpg",
        "url": "http://v.360kan.com/sv/c4fkcmPqSxH2US.html",
        "date": "2016103104"
      },
      {
        "title": "杨幂嗲音被批恶心",
        "desc": "回应:严重鼻炎",
        "cover": "http://p9.qhimg.com/t018df898ae578d33cd.jpg",
        "url": "http://v.360kan.com/sv/bYXjbWPqTBj4UC.html"
      },
      {
        "title": "土豪怒甩50万现金砸碎店里iPhone",
        "cover": "http://p3.qhimg.com/t01f998610d1cffae18.jpg",
        "url": "http://v.360kan.com/sv/coflbGPqSRj1Ty.html"
      },
      {
        "title": "惨!实拍公路桥被车重压垮塌",
        "cover": "http://p2.qhimg.com/t018f25cf6682b46e73.gif",
        "url": "http://v.360kan.com/sv/dInmbWPqUBTyTi.html"
      },
      {
        "title": "新买iPhone7相册存陌生人照片",
        "cover": "http://p3.qhimg.com/t01f04fee7bd224af4b.jpg",
        "url": "http://v.360kan.com/sv/bYjobWPqUBT6TC.html"
      },
      {
        "title": "20岁林允曝性感照",
        "desc": "晒美胸美背好诱人",
        "cover": "http://p3.qhimg.com/t01938e1dd299bb1cf5.jpg",
        "url": "http://v.360kan.com/sv/b4nkbGPqSxnzSi.html"
      },
      {
        "title": "摩的司机占道不听劝亮刀打交警",
        "cover": "http://p4.qhimg.com/t012b069fa44b11a5bf.gif",
        "url": "http://v.360kan.com/sv/cYbnaWPqUBT2SC.html"
      },
      {
        "title": "爆笑!盘点那些奇葩的开门方式",
        "cover": "http://p1.qhimg.com/t015fa4d2fd82b0d944.jpg",
        "url": "http://v.360kan.com/sv/b4TqaWPqUBT5Si.html"
      },
      {
        "title": "奇葩男子冒雨碰瓷 先敬礼再摔倒",
        "cover": "http://p0.qhimg.com/t01c44f03d525093473.jpg",
        "url": "http://v.360kan.com/sv/corjaWPqUBL4TC.html"
      },
      {
        "title": "网曝两女子和狗围攻老人 老人被打倒在地猛踹",
        "cover": "http://p2.qhimg.com/dmb/380_220_/t019c94eb2edd62b7fe.gif",
        "url": "http://v.360kan.com/sv/cobpbWPqUBTyUS.html",
        "date": "2016110101"
      },
      {
        "title": "相恋结婚9年 丈夫竟然变妻子?",
        "cover": "http://p7.qhimg.com/t01359b0b35aa2b187b.gif",
        "url": "http://v.360kan.com/sv/cIPocWPqUBT6Sy.html"
      }
    ],
    "wemedia": {
      "wmid": "c4LiQHkwQWn58g",
      "wm_url": "http://wemedia.360kan.com/wm/c4LiQHkwQWn58g.html?from=v",
      "name": "车祸实拍",
      "head_img": "http://p0.qhimg.com/t01c341f9415acebca7.jpg",
      "video_count": "2",
      "fans_count": "12",
      "upload_time": "2016-10-28 19:25",
      "desc": "歼20亮相珠海航展",
      "tags": [
        "歼20",
        "亮相"
      ],
      "judgeAttention": -1
    },
    "log": {
      "vid": 678474,
      "catid": "1700",
      "sub_catid": null
    }
  }
}

该接口请求中的id参数值可以从播放页地址中提取得到。从返回的JSON数据中,我们发现相关视频(result/video/relate)列表中的第一项就是要找的视频信息。其中的id正好是播放页地址中的id,url就是接下来要请求的东西。

请求 http://info.play.tvfanqie.com/video/getplay?mid=1b190d3186c3d889102d9eebcd2274e1&cli=web&act=play&sid=fanqie_web&_rate=&pver=1.0&ckts=1&source=1&ts=1478006691&_sign=c05ee59bfb518ec70fea8664227042e1 返回如下JSON数据:

{
  "errno": 0,
  "error": "ok",
  "result": {
    "vid": "1b190d3186c3d889102d9eebcd2274e1",
    "site": "360shipin",
    "duration": 42,
    "title": "682804",
    "pic": "http://p4.qhimg.com/t01d2a7df91a54e3b5e.jpg",
    "currqua": {
      "key": "xd",
      "value": "超清"
    },
    "quality": [
      {
        "key": "xd",
        "value": "超清"
      },
      {
        "key": "hd",
        "value": "高清"
      },
      {
        "key": "sd",
        "value": "标清"
      }
    ],
    "vrtype": {
      "key": 0,
      "value": "普通视频"
    },
    "drmtype": "non",
    "stype": "m3u8",
    "usep2p": 0,
    "sid": "fanqie_web",
    "videos": [
      {
        "duration": 42,
        "url": "http://g.play.tvfanqie.com/video/getplay?mid=1b190d3186c3d889102d9eebcd2274e1&dtype=non&stype=m3u8&_rate=xd&sid=fanqie_web&source=1&ts=1478007132&_sign=69e115781ac007e9df87a0c3425afa53"
      }
    ]
  }
}

从这串JSON数据可以推知,currqua是当前清晰度的意思,quality列表表示该视频有哪些清晰度。重点在于videos列表中的url,请求该地址,得到的是一个m3u8文件内容:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-QIHU-RUID:900b2f1b2d2f99a16353e5d4abda38d6
#EXT-X-CDN_DOMAIN:y.play.360kan.com
#EXT-X-TARGETDURATION:10
#EXT-X-QIHU-SZ:1639736
#EXTINF:8.166,
http://y.play.360kan.com/vod/143/141/900b2f1b2d2f99a16353e5d4abda38d6/1b190d3186c3d889102d9eebcd2274e1_1280_640_1200_128_900b2f1b2d2f99a16353e5d4abda38d6_mp4_3gb15523d_0.ts?time=1478007357&sign=13479111e10e131dc8dd6ea2720fea49
#EXT-X-QIHU-SZ:1143792
#EXTINF:6.250,
http://y.play.360kan.com/vod/143/141/900b2f1b2d2f99a16353e5d4abda38d6/1b190d3186c3d889102d9eebcd2274e1_1280_640_1200_128_900b2f1b2d2f99a16353e5d4abda38d6_mp4_3gb1d40ae_1.ts?time=1478007357&sign=3d7e66b1b13c52db597eabbf02bffd72
#EXT-X-QIHU-SZ:882284
#EXTINF:6.250,
http://y.play.360kan.com/vod/143/141/900b2f1b2d2f99a16353e5d4abda38d6/1b190d3186c3d889102d9eebcd2274e1_1280_640_1200_128_900b2f1b2d2f99a16353e5d4abda38d6_mp4_3gb1fab8e_2.ts?time=1478007357&sign=6be2a1c97c1110942f5358a9a190716e
#EXT-X-QIHU-SZ:1175564
#EXTINF:6.250,
http://y.play.360kan.com/vod/143/141/900b2f1b2d2f99a16353e5d4abda38d6/1b190d3186c3d889102d9eebcd2274e1_1280_640_1200_128_900b2f1b2d2f99a16353e5d4abda38d6_mp4_3gb158a8d_3.ts?time=1478007357&sign=fb790212297512ceb6f21e28069d5eca
#EXT-X-QIHU-SZ:962560
#EXTINF:6.250,
http://y.play.360kan.com/vod/143/141/900b2f1b2d2f99a16353e5d4abda38d6/1b190d3186c3d889102d9eebcd2274e1_1280_640_1200_128_900b2f1b2d2f99a16353e5d4abda38d6_mp4_3gb1379bb_4.ts?time=1478007357&sign=1f1cf07d2231e5f951319f530b1044a4
#EXT-X-QIHU-SZ:861980
#EXTINF:4.750,
http://y.play.360kan.com/vod/143/141/900b2f1b2d2f99a16353e5d4abda38d6/1b190d3186c3d889102d9eebcd2274e1_1280_640_1200_128_900b2f1b2d2f99a16353e5d4abda38d6_mp4_3gb19a24f_5.ts?time=1478007357&sign=27b20b0fec49b61fcab804a3ffbf727f
#EXT-X-QIHU-SZ:521136
#EXTINF:4.000,
http://y.play.360kan.com/vod/143/141/900b2f1b2d2f99a16353e5d4abda38d6/1b190d3186c3d889102d9eebcd2274e1_1280_640_1200_128_900b2f1b2d2f99a16353e5d4abda38d6_mp4_3gb10f11b_6.ts?time=1478007357&sign=fc13fb4ba30872643e5b2c5e6916a513
#EXT-X-ENDLIST

从m3u8文件中提取出各个视频分段的地址,分别下载完成后合并成完整视频即可。

Python代码示例

import re
import requests
import json

url = 'http://v.360kan.com/sv/cIPmaWPqUBT5TC.html'
vid = re.search('/(\w+).html', url).group(1)
r = requests.get('http://v.360kan.com/Shortvideo/ajaxApi?id=%s' % vid)
data = json.loads(r.content)
relate_videos = data['result']['video']['relate']
for v in relate_videos:
    if v['id'] == vid:
        r = requests.get(v['url'])
        data = json.loads(r.content)
        m3u8_url = data['result']['videos'][0]['url']
        r = requests.get(m3u8_url)
        segments = re.findall(r'^[^#][^\r][^\n]*', r.content, re.MULTILINE)
        for seg in segments:
            print seg
        break
上一篇下一篇

猜你喜欢

热点阅读