使用Python实现下载网易云音乐的高清MV,python高清
使用Python实现下载网易云音乐的高清MV,python高清
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)
以上就是本文分享的全部代码了,希望大家能够喜欢。
相关内容
- Python实现windows下模拟按键和鼠标点击的方法,python鼠标
- Python实现遍历windows所有窗口并输出窗口标题的方法,
- python实现根据窗口标题调用窗口的方法,python窗口标题
- python根据时间生成mongodb的ObjectId的方法,mongodbobjectid
- python使用chardet判断字符串编码的方法,pythonchardet
- python通过正则查找微博@(at)用户的方法,pythonat
- python将MongoDB里的ObjectId转换为时间戳的方法,mongodbob
- python通过urllib2获取带有中文参数url内容的方法,
- Python比较两个图片相似度的方法,
- python实现简单socket程序在两台电脑之间传输消息的方法
评论关闭