时间:2021-07-01 10:21:17 帮助过:75人阅读
#!/usr/bin/env python #-*- coding: utf-8 -*- import urllib import re baseurl = "http://music.baidu.com" url = "http://music.baidu.com/search/tag?key=经典流行" html = urllib.urlopen(url).read() uri = re.findall(r'/song/\d+', html, re.M) lst = [] for i in uri: link = baseurl+i+"/download" lst.insert(0, link) for k in lst: res = urllib.urlopen(k).read() down = re.search('http://[^ ]*xcode.[a-z0-9]*' , res, re.M).group() s1 = re.search('title=".*',res, re.M).group() s2 = re.search('>.*<.a', s1, re.M).group() s3 = s2[1:-3] urllib.urlretrieve(down, s3+".mp3")
希望本文所述对大家的Python程序设计有所帮助。