使用Python实现下载网易云音乐的高清MV
2015-03-16 15:45
1006 查看
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使用网易云音乐 api下载mv
- Python使用urllib2模块实现断点续传下载的方法
- Python使用urllib2模块实现断点续传下载的方法
- Python使用wget实现下载网络文件功能示例
- 使用Python下载歌词并嵌入歌曲文件中的实现代码
- 【webserver】使用python实现webserver,支持上传下载文件
- 和我一起使用Python的bottle来实现文件的上传和下载(使用post方法)
- Python 使用urllib2模块实现断点续传下载
- Python 网易云音乐 MV 下载
- 使用Python实现无交互sftp上传、下载
- 使用python进行爬虫下载网易云音乐
- Python使用sftp实现上传和下载功能(实例代码)
- Python使用sftp实现上传和下载功能
- 使用Python下载歌词并嵌入歌曲文件中的实现代码
- python使用ftplib模块实现ftp目录嵌套下载
- 在python中可以使用urllib方便的实现图片和flash下载
- python使用paramiko模块实现ssh远程命令执行,与sftp文件下载功能
- 使用Shell脚本实现ftp的自动上传下载
- 使用VS2005的 ClickOnce 技术实现按需下载组件
- 使用Java程序来实现HTTP文件的队列下载