Python抓取网易云付费音乐代码
时间: 2023-11-21 17:43:07 浏览: 191
Python版的网易云音乐API,基于django3.0搭建+源代码+文档说明
5星 · 资源好评率100%
抓取网易云付费音乐的Python代码示例如下:
```python
import requests
from bs4 import BeautifulSoup
url = 'http://music.163.com/#/artist/album?id=101988&limit=120&offset=0'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'}
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text, 'html.parser')
albums = soup.find_all('div', class_='u-cover u-cover-alb3')
for album in albums:
album_name = album.find('a', class_='tit s-fc0').get_text()
album_date = album.find('span', class_='s-fc3').get_text()
album_price = album.find('b', class_='st s-fc4').get_text()
print('专辑名称:', album_name)
print('发行日期:', album_date)
print('价格:', album_price)
print('------------------')
```
阅读全文