使用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创建系统目录的方法
Mar 11 Python
python检查序列seq是否含有aset中项的方法
Jun 30 Python
Python实现连接postgresql数据库的方法分析
Dec 27 Python
django 发送邮件和缓存的实现代码
Jul 18 Python
详解如何为eclipse安装合适版本的python插件pydev
Nov 04 Python
python实现文本界面网络聊天室
Dec 12 Python
Python 给屏幕打印信息加上颜色的实现方法
Apr 24 Python
python的turtle库使用详解
May 10 Python
图文详解python安装Scrapy框架步骤
May 20 Python
Django 项目通过加载不同env文件来区分不同环境
Feb 17 Python
python实现批量命名照片
Jun 18 Python
python实现网络五子棋
Apr 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对表单提交特殊字符的过滤和处理方法汇总
2014/02/18 PHP
讲解WordPress开发中一些常用的debug技巧
2015/12/18 PHP
浅谈PHP中new self()和new static()的区别
2017/08/11 PHP
让回调函数 showResponse 也带上参数的代码
2007/08/13 Javascript
js 小数取整的函数
2010/05/10 Javascript
jQuery 顺便学习下CSS选择器 奇偶匹配nth-child(even)
2010/05/24 Javascript
js 第二代身份证号码的验证机制代码
2011/05/12 Javascript
关于删除时的提示处理(确定删除吗)
2013/11/03 Javascript
Javascript 绘制 sin 曲线过程附图
2014/08/21 Javascript
JS实现Fisheye效果动感放大菜单代码
2015/10/21 Javascript
vue组件从开发到发布的实现步骤
2018/11/11 Javascript
你不知道的SpringBoot与Vue部署解决方案
2020/11/09 Javascript
Python模拟脉冲星伪信号频率实例代码
2018/01/03 Python
Python PyQt4实现QQ抽屉效果
2018/04/20 Python
python中property属性的介绍及其应用详解
2019/08/29 Python
python 实现从高分辨图像上抠取图像块
2020/01/02 Python
Python中sorted()排序与字母大小写的问题
2020/01/14 Python
python GUI库图形界面开发之PyQt5访问系统剪切板QClipboard类详细使用方法与实例
2020/02/27 Python
Python读取yaml文件的详细教程
2020/07/21 Python
pandas apply多线程实现代码
2020/08/17 Python
python中random模块详解
2021/03/01 Python
HTML5仿手机微信聊天界面
2016/03/18 HTML / CSS
Python面试题:Python里面如何生成随机数
2015/03/12 面试题
奥巴马演讲稿
2014/01/08 职场文书
网上书店创业计划书
2014/01/12 职场文书
总经理助理工作职责
2014/02/06 职场文书
优秀医生事迹材料
2014/02/12 职场文书
中级会计职业生涯规划书
2014/03/01 职场文书
电子商务助理求职自荐信
2014/04/10 职场文书
学校党的群众路线教育实践活动领导班子对照检查材料
2014/09/25 职场文书
运动会广播稿200米(5篇)
2014/10/15 职场文书
三好学生评语大全
2014/12/29 职场文书
元旦晚会主持词开场白
2015/05/28 职场文书
MySQL 亿级数据导入导出及迁移笔记
2021/06/18 MySQL
MySQL派生表联表查询实战过程
2022/03/20 MySQL
国产动画《万圣街》日语配音版制作决定!
2022/03/20 国漫