美文网首页
Python解析音悦台MV视频地址与封面

Python解析音悦台MV视频地址与封面

作者: Trojx | 来源:发表于2017-01-13 10:55 被阅读109次

音悦台的MV网页链接是连续的,形如http://v.yinyuetai.com/video/2770558,最后面的id最多由七位数字组成.参考网上Java版本的抓取代码,现用Python实现如下:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2017/1/12 0012 下午 4:24# @Author : Trojx
# @File : yinyuetai.py
import requests
import re
def get_mv_info(video_id): 
  params = {'flex': True, 'videoId': video_id} 
  res = requests.get('http://www.yinyuetai.com/insite/get-video-info', params) 
  # print res.content 
  qualities = ['sh', 'he', 'hd', 'hc'] 
  qualities_cn = ['VIP专享MV', '超清MV', '高清MV', '流畅MV'] 
  for q, q_cn in zip(qualities, qualities_cn): 
    result = re.findall('.+(http://' + q + '.yinyuetai.com/uploads/videos/common/[a-zA-Z0-9]+\\.flv).+',     res.content) 
    if len(result) > 0:
      print q_cn + ':' + result[0] 
    covers = re.findall('.+(http://img[0-9].yytcdn.com/video/mv/[0-9]+/[0-9]+/.+\\.jpe?g).+', res.content) 
    if len(covers) > 0: 
      print '封面:' + covers[0]
if __name__ == '__main__':
  for i in range(2000000,2000010): 
    print i get_mv_info(i)

解析结果如下:

2000000
超清MV:http://he.yinyuetai.com/uploads/videos/common/180E0144714AA06BDC7285DD738989A7.flv
高清MV:http://hd.yinyuetai.com/uploads/videos/common/AECB0144713DCF2CF7C41E940E7DF33A.flv
流畅MV:http://hc.yinyuetai.com/uploads/videos/common/67850144712E3ECA363E61435F9BFB7D.flv
封面:http://img4.yytcdn.com/video/mv/140227/2000000/94AB014471317FB865E22018482DA924_240x135.jpeg
2000001
超清MV:http://he.yinyuetai.com/uploads/videos/common/7E5B01447146F6EB4639EE6596685AB0.flv
高清MV:http://hd.yinyuetai.com/uploads/videos/common/8AE00144713DCF821E4342BB0FE7A848.flv
流畅MV:http://hc.yinyuetai.com/uploads/videos/common/815301447134A76953CCE2B49A59FB5F.flv
封面:http://img2.yytcdn.com/video/mv/140227/2000001/1F870144713968D3B501FFC592CDCA4F_640x360.jpeg
2000002
超清MV:http://he.yinyuetai.com/uploads/videos/common/9D4F01447146F7A5B400F2DA20D1C6A8.flv
高清MV:http://hd.yinyuetai.com/uploads/videos/common/5E15014471408F01EF0981F2C14E8080.flv
流畅MV:http://hc.yinyuetai.com/uploads/videos/common/C6B90144713592A0A63361B57D09BF67.flv
封面:http://img1.yytcdn.com/video/mv/161116/2724994/-M-b072a7fbe78fb03119343e23e250519b_120x67.jpg
......

原文地址:http://www.trojx.me/2017/01/13/python-yinyuetai-mv/

相关文章

网友评论

      本文标题:Python解析音悦台MV视频地址与封面

      本文链接:https://www.haomeiwen.com/subject/uytsbttx.html