您好,欢迎访问一九零五行业门户网

使用Python实现下载网易云音乐的高清MV

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)
以上就是本文分享的全部代码了,希望大家能够喜欢。
其它类似信息

推荐信息