资源简介
import requests
from lxml import etree
url = 'https://music.163.com/playlist?id=2409342460'
base_url = 'https://music.163.com/song/media/outer/url?id='
html_str = requests.get(url).text
dom = etree.HTML(html_str)
song_ids = dom.xpath('//a[contains(@href,"/song?")]/@href')
song_names = dom.xpath('//a[contains(@href,"/song?")]/text()')
for song_id,song_name in zip(song_ids,song_names):
count_id = song_id.strip('/song?id=')
if('$' in count_id) == False:
mp3_url = base_url count_id '.mp3'
print(mp3_url)
mp3 = requests.get(mp3_url).content
str = '%s.mp3'%song_name
print(str)
with open(str,'wb') as file:
file.write(mp3)
from lxml import etree
url = 'https://music.163.com/playlist?id=2409342460'
base_url = 'https://music.163.com/song/media/outer/url?id='
html_str = requests.get(url).text
dom = etree.HTML(html_str)
song_ids = dom.xpath('//a[contains(@href,"/song?")]/@href')
song_names = dom.xpath('//a[contains(@href,"/song?")]/text()')
for song_id,song_name in zip(song_ids,song_names):
count_id = song_id.strip('/song?id=')
if('$' in count_id) == False:
mp3_url = base_url count_id '.mp3'
print(mp3_url)
mp3 = requests.get(mp3_url).content
str = '%s.mp3'%song_name
print(str)
with open(str,'wb') as file:
file.write(mp3)
代码片段和文件信息
import requests
from lxml import etree
url = ‘https://music.163.com/playlist?id=2409342460‘
base_url = ‘https://music.163.com/song/media/outer/url?id=‘
html_str = requests.get(url).text
dom = etree.HTML(html_str)
song_ids = dom.xpath(‘//a[contains(@href“/song?“)]/@href‘)
song_names = dom.xpath(‘//a[contains(@href“/song?“)]/text()‘)
for song
- 上一篇:python数据结构
- 下一篇:打砖块
相关资源
- python与量化投资-从基础到实战 配套资
- python Tkinter
- 批量文件.py
- Python贪吃蛇源码+背景音乐+中文字体
- get-pip.py下载267386
- 蜻蜓fm文件名还原逆还原工具qtfmr2.e
- python机器学习-音乐分类器实现
- Python小说器
- python实现音乐播放器
- Python飞机大战完整素材包字体音乐图
- Python飞机大战 图片+音乐
- numpy-1.15.3-cp27-none-win_amd64.whl
- python音乐播放器
- 基于django的音乐网站 课程设计
- python音乐播放器动态显示歌词
- python算法图解. 真正完整版.pdf
- 《Python面向对象编程指南》 高清完整
- Python-导出qq音乐歌单的小工具导出格
- 爬取网易云音乐.py
- python3爬取网易云歌单
- 用Python网易云音乐
- python音乐源代码
- 网易云课堂:21天搞定Python分布式爬虫
- python获取酷狗音乐top500的地址 MP3格式
- 基于深度学习生成音乐(mid格式的音
- python自动抓取网页中的pdf文件
- python爬虫网站图片
- PCA故障诊断python实现
- 百度文库自动
- 解决pythonSSL问题,pip,easy_install无法
评论
共有 条评论