使用Python实现下载网易云音乐的高清MV
Python下载网易云音乐的高清MV,没有从首页进去解析,直接循环了....
downPage1.py
#coding=utf-8
importurllib
importre
importos
defgetHtml(url):
page=urllib.urlopen(url)
html=page.read()
returnhtml
defgetVideo(html):
reg=r'hurl=(.+?\.jpg)'
imgre=re.compile(reg)
imglist=re.findall(imgre,html)
returnimglist
fornuminrange(28000,1000000):
printnum
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"/"insong:
continue
ifos.path.exists(filename):
print'theMVfileexists.%s'%num
else:
print'theMVisdownloding.%s'%num
if os.path.exists(artist):
print""
else:
os.makedirs(artist)
urllib.urlretrieve(vedioUrls[0],filename)
以上就是本文分享的全部代码了,希望大家能够喜欢。
热门推荐
3 祝福语简短的微信
10 幼儿祝福语大全简短贺卡
11 感谢教官文案祝福语简短
12 鼠年同事祝福语简短创意
13 元旦祝福语 简短独特群发
14 妈咪跟我生日祝福语简短
15 给儿子新婚祝福语简短
16 伴娘祝福语长文案简短
17 恭喜高考完祝福语简短
18 生日祝福语送老公简短