使用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中的super()方法使用简介
Aug 14 Python
对python 各种删除文件失败的处理方式分享
Apr 24 Python
Python实现在某个数组中查找一个值的算法示例
Jun 27 Python
pycharm远程开发项目的实现步骤
Jan 20 Python
python3 enum模块的应用实例详解
Aug 12 Python
python使用PIL和matplotlib获取图片像素点并合并解析
Sep 10 Python
Python常用模块logging——日志输出功能(示例代码)
Nov 20 Python
使用Keras中的ImageDataGenerator进行批次读图方式
Jun 17 Python
Python selenium实现断言3种方法解析
Sep 08 Python
python如何控制进程或者线程的个数
Oct 16 Python
Python Web项目Cherrypy使用方法镜像
Nov 05 Python
matplotlib部件之矩形选区(RectangleSelector)的实现
Feb 01 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工具型代码之印章抠图
2018/07/18 PHP
PHP bin2hex()函数基础实例讲解
2019/02/11 PHP
PHP常用函数之获取汉字首字母功能示例
2019/10/21 PHP
js String对象中常用方法小结(字符串操作)
2012/01/27 Javascript
多种方式实现JS调用后台方法进行数据交互
2013/08/20 Javascript
JS匀速运动演示示例代码
2013/11/26 Javascript
jquery 鼠标滑动显示详情应用示例
2014/01/24 Javascript
js数组操作常用方法
2014/05/08 Javascript
JS实现动态表格的添加,修改,删除功能(推荐)
2016/06/15 Javascript
bootstrap下拉列表与输入框组结合的样式调整
2016/10/08 Javascript
Bootstrap源码解读标签、徽章、缩略图和警示框(8)
2016/12/26 Javascript
js实现漫天星星效果
2017/01/19 Javascript
JS正则替换去空格的方法
2017/03/24 Javascript
js实现扫雷小程序的示例代码
2017/09/27 Javascript
nodejs初始化init的示例代码
2018/10/10 NodeJs
vue+webpack 更换主题N种方案优劣分析
2019/10/28 Javascript
JavaScript实现PC端横向轮播图
2020/02/07 Javascript
[01:42:49]DOTA2-DPC中国联赛 正赛 iG vs PSG.LGD BO3 第一场 2月26日
2021/03/11 DOTA
python爬虫教程之爬取百度贴吧并下载的示例
2014/03/07 Python
Python获取脚本所在目录的正确方法
2014/04/15 Python
Python3学习笔记之列表方法示例详解
2017/10/06 Python
Python 查看文件的编码格式方法
2017/12/21 Python
Django使用Mysql数据库已经存在的数据表方法
2018/05/27 Python
python3读取excel文件只提取某些行某些列的值方法
2018/07/10 Python
Python实现Linux监控的方法
2019/05/16 Python
社区版pycharm创建django项目的方法(pycharm的newproject左侧没有项目选项)
2020/09/23 Python
python实现定时发送邮件
2020/12/23 Python
使用sublime text3搭建Python编辑环境的实现
2021/01/12 Python
Sofft鞋官网:世界知名鞋类品牌
2017/03/28 全球购物
美味咖啡的顶级烘焙师:Cafe Britt
2018/03/15 全球购物
数控专业自荐书范文
2014/03/16 职场文书
开学典礼演讲稿
2014/05/23 职场文书
写给医护人员的一封感谢信
2019/09/16 职场文书
深入理解Pytorch微调torchvision模型
2021/11/11 Python
Python循环之while无限迭代
2022/04/30 Python
详解Go语言中配置文件使用与日志配置
2022/06/01 Golang