Python download NetEase cloud music HD MV, not from the home page to parse, direct loop ....
downpage1.py
The code is as follows:
#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)
The above is the entire code to share this article, I hope you can enjoy.