手机
当前位置:查字典教程网 >脚本专栏 >python >使用Python实现下载网易云音乐的高清MV
使用Python实现下载网易云音乐的高清MV
摘要:Python下载网易云音乐的高清MV,没有从首页进去解析,直接循环了....downPage1.py复制代码代码如下:#coding=utf...

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"%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实现下载网易云音乐的高清MV】相关文章:

用Python编程实现语音控制电脑

使用python实现扫描端口示例

Python实现多线程下载文件的代码实例

用Python的urllib库提交WEB表单

python实现定制交互式命令行的方法

python中使用pyhook实现键盘监控的例子

使用Python下载Bing图片(代码)

使用setup.py安装python包和卸载python包的方法

python使用PyFetion来发送短信的例子

用python实现的去除win下文本文件头部BOM的代码

精品推荐
分类导航