国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

使用Python實現下載網易云音樂的高清MV

2020-02-23 00:22:07
字體:
來源:轉載
供稿:網友

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)

以上就是本文分享的全部代碼了,希望大家能夠喜歡。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 玉门市| 东乡族自治县| 饶平县| 军事| 尚义县| 将乐县| 长葛市| 泗阳县| 眉山市| 密山市| 阜平县| 四平市| 公安县| 汨罗市| 彭阳县| 梁河县| 瓮安县| 泊头市| 南丰县| 临海市| 喀什市| 时尚| 象山县| 蒙山县| 明星| 阜宁县| 定结县| 蒙自县| 彩票| 大方县| 板桥市| 阿拉善右旗| 曲周县| 普陀区| 甘南县| 班玛县| 浦江县| 栖霞市| 衡阳县| 北海市| 闽清县|