import requests
import re
from multiprocessing import Pool
import urllib
headers = {
'Referer': 'https://music.163.com/',
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.89 "
"Safari/537.36"
}
def get_page(url):
res = requests.get(url, headers=headers)
data = re.findall('<a title="(.*?)" href="/playlist\?id=(\d+)" class="msk"></a>', res.text)
print(data)
pool = Pool(processes=4)
pool.map(get_songs, data[:len(data) - 1])
print("下载完毕!")
def get_songs(data):
print(data[1])
playlist_url = "https://music.163.com/playlist?id=%s" % data[1]
res = requests.get(playlist_url, headers=headers)
for i in re.findall(r'<a href="/song\?id=(\d
用Python3爬取网易云音乐并且下载至本地
最新推荐文章于 2024-06-24 16:59:14 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)