使用Python实现下载网易云音乐的高清MV


Posted in Python onMarch 16, 2015

Python下载网易云音乐的高清MV,没有从首页进去解析,直接循环了....

downPage1.py

#coding=utf-8

import urllib

import re

import os

def getHtml(url):

    page = urllib.urlopen(url)

    html = page.read()

    return html

def getVideo(html):

    reg = r'hurl=(.+?\.jpg)'

    imgre = re.compile(reg)

    imglist = re.findall(imgre,html)

    return imglist

for num in range(28000,1000000):

    print num

    html = getHtml("http://music.163.com/mv?id=%s"%num)

    parsed = getVideo(html)

    if  len(parsed)==0:

        continue

    vedioUrls = parsed[0].split("&")

    artist = vedioUrls[4].split("=")[1].decode('utf-8').strip()

    song = vedioUrls[3].split("=")[1].decode('utf-8').strip()

    if  len(vedioUrls[0])==0:

        continue

    filename = '%s/%s.mp4' %(artist,song)

    if "/" in song:

        continue

    if os.path.exists(filename):

        print 'the MV file exists.%s'%num

    else:

        print 'the MV is downloding.%s'%num

        if  os.path.exists(artist):

            print ""

        else:

            os.makedirs(artist)

        urllib.urlretrieve(vedioUrls[0],filename)

以上就是本文分享的全部代码了,希望大家能够喜欢。

Python 相关文章推荐
Python常用模块用法分析
Sep 08 Python
Python标准库之循环器(itertools)介绍
Nov 25 Python
Python中的if、else、elif语句用法简明讲解
Mar 11 Python
Django中利用filter与simple_tag为前端自定义函数的实现方法
Jun 15 Python
TensorFlow实现AutoEncoder自编码器
Mar 09 Python
matplotlib 输出保存指定尺寸的图片方法
May 24 Python
解决pip install的时候报错timed out的问题
Jun 12 Python
python学习之hook钩子的原理和使用
Oct 25 Python
python实现静态服务器
Sep 05 Python
Python 读取xml数据,cv2裁剪图片实例
Mar 10 Python
pyinstaller将含有多个py文件的python程序做成exe
Apr 29 Python
Windows安装Anaconda3的方法及使用过程详解
Jun 11 Python
python使用点操作符访问字典(dict)数据的方法
Mar 16 #Python
python用来获得图片exif信息的库实例分析
Mar 16 #Python
python通过pil模块获得图片exif信息的方法
Mar 16 #Python
使用Python抓取模板之家的CSS模板
Mar 16 #Python
Python实现竖排打印传单手机号码易撕条
Mar 16 #Python
python通过exifread模块获得图片exif信息的方法
Mar 16 #Python
python通过pil模块将raw图片转换成png图片的方法
Mar 16 #Python
You might like
php面向对象编程self和static的区别
2016/05/08 PHP
PHP图片添加水印功能示例小结
2016/10/03 PHP
将json当数据库一样操作的javascript lib
2013/10/28 Javascript
字段太多jquey快速清空表单内容方法
2014/08/21 Javascript
基于javascript实现的搜索时自动提示功能
2014/12/26 Javascript
javascript实现的图片切割多块效果实例
2015/05/07 Javascript
JS Attribute属性操作详解
2016/05/19 Javascript
JQuery Mobile 弹出式登录框的实现方法
2016/05/28 Javascript
jQuery弹出窗口打开链接的实现代码
2016/12/24 Javascript
JavaScript实现瀑布流图片效果
2017/06/30 Javascript
Intellij IDEA搭建vue-cli项目的方法步骤
2018/10/20 Javascript
4 种滚动吸顶实现方式的比较
2019/04/09 Javascript
原生js+canvas实现贪吃蛇效果
2020/08/02 Javascript
[48:53]2014 DOTA2华西杯精英邀请赛 5 25 LGD VS VG第一场
2014/05/26 DOTA
[01:05:29]DOTA2-DPC中国联赛 正赛 PSG.LGD vs Aster BO3 第二场 1月24日
2021/03/11 DOTA
Python与Redis的连接教程
2015/04/22 Python
Python中利用sqrt()方法进行平方根计算的教程
2015/05/15 Python
python好玩的项目—色情图片识别代码分享
2017/11/07 Python
Python自动化运维_文件内容差异对比分析
2017/12/13 Python
tensorflow建立一个简单的神经网络的方法
2018/02/10 Python
详解django三种文件下载方式
2018/04/06 Python
详解小白之KMP算法及python实现
2019/04/04 Python
Django 拆分model和view的实现方法
2019/08/16 Python
python如何保证输入键入数字的方法
2019/08/23 Python
如何完美的建立一个python项目
2020/10/09 Python
python的setattr函数实例用法
2020/12/16 Python
python 基于PYMYSQL使用MYSQL数据库
2020/12/24 Python
美国社交购物市场:MassGenie
2019/02/18 全球购物
如何将无状态会话Bean发布为WEB服务,只有无状态会话Bean可以发布为WEB服务?
2015/12/03 面试题
个人找工作求职简历的自我评价
2013/10/20 职场文书
公司培训欢迎词
2014/01/10 职场文书
妈妈的账单教学反思
2014/02/06 职场文书
小区物业门卫岗位职责
2014/04/10 职场文书
暂住证明怎么写
2015/06/19 职场文书
研讨会致辞
2015/07/31 职场文书
用Python爬虫破解滑动验证码的案例解析
2021/05/06 Python