使用Python實(shí)現(xiàn)下載網(wǎng)易云音樂的高清MV
更新時間:2015年03月16日 15:45:22 投稿:hebedich
本文給大家分享的是一則使用Python實(shí)現(xiàn)下載網(wǎng)易云音樂中高清MV的代碼,本人新手,沒有做特別的功能,僅僅是直接循環(huán)了MV的id,小伙伴們可以自己擴(kuò)展下。
Python下載網(wǎng)易云音樂的高清MV,沒有從首頁進(jìn)去解析,直接循環(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)文章
torchxrayvision包安裝過程(附pytorch1.6cpu版安裝)
這篇文章主要介紹了torchxrayvision包安裝過程(附pytorch1.6cpu版安裝),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08
python遍歷目錄下所有文件的五種實(shí)現(xiàn)方法
本文主要介紹了python遍歷目錄下所有文件的五種實(shí)現(xiàn)方法,包含os.walk(),os.scandir(),os.listdir(),glob模塊和osqp模塊這幾種方法,具有一定的參考價值,感興趣的可以了解一下2024-07-07
python定時任務(wù) sched模塊用法實(shí)例
這篇文章主要介紹了python定時任務(wù) sched模塊用法實(shí)例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2019-11-11

