Skip to content

Commit a9918a3

Browse files
author
tuntun
committed
Python3下载网易云音乐高清MV
1 parent 294debc commit a9918a3

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

‎yun.py‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#coding=utf-8
2+
import urllib.request
3+
import re
4+
import os
5+
import sys
6+
7+
def getHtml(url):
8+
page = urllib.request.urlopen(url)
9+
html = page.read()
10+
return html
11+
12+
13+
def getVideo(html):
14+
reg = r'hurl=(.+?\.jpg)'
15+
imgre = re.compile(reg)
16+
imglist = re.findall(imgre,html)
17+
return imglist
18+
19+
for num in range(28000,1000000):
20+
print (num)
21+
html = getHtml("http://music.163.com/mv?id=%s"%num)
22+
html = html.decode('utf-8')
23+
parsed = getVideo(html)
24+
print(parsed)
25+
if len(parsed)==0:
26+
continue
27+
vedioUrls = parsed[0].split("&")
28+
29+
artist = vedioUrls[4].split("=")[1].strip()
30+
song = vedioUrls[3].split("=")[1].strip()
31+
if len(vedioUrls[0])==0:
32+
continue
33+
filename = '%s/%s.mp4' %(artist,song)
34+
if "/" in song:
35+
continue
36+
37+
if os.path.exists(filename):
38+
print ('the MV file exists.%s'%num)
39+
else:
40+
print ('the MV is downloding.%s'%num)
41+
if os.path.exists(artist):
42+
print ("")
43+
else:
44+
os.makedirs(artist)
45+
urllib.request.urlretrieve(vedioUrls[0],filename)

0 commit comments

Comments
 (0)