使用Python實現(xiàn)下載網(wǎng)易云音樂的高清MV
更新時間:2015年03月16日 15:45:22 投稿:hebedich
本文給大家分享的是一則使用Python實現(xiàn)下載網(wǎng)易云音樂中高清MV的代碼,本人新手,沒有做特別的功能,僅僅是直接循環(huán)了MV的id,小伙伴們可以自己擴展下。
Python下載網(wǎng)易云音樂的高清MV,沒有從首頁進去解析,直接循環(huán)了....
downPage1.py
復(fù)制代碼 代碼如下:
#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(")
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)
以上就是本文分享的全部代碼了,希望大家能夠喜歡。
相關(guān)文章
如何將python中的List轉(zhuǎn)化成dictionary
這篇文章主要介紹在python中如何將list轉(zhuǎn)化成dictionary,通過提出兩個問題來告訴大家如何解決,有需要的可以參考借鑒。2016-08-08Python使用selenium + headless chrome獲取網(wǎng)頁內(nèi)容的方法示例
這篇文章主要介紹了Python使用selenium + headless chrome獲取網(wǎng)頁內(nèi)容的方法示例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2019-10-10