网易云音乐排行榜
# coding: utf-8import requests
import csv
import re
with open("网易云音乐排行榜.csv",mode="w",encoding="utf-8") as f:
csv_writer = csv.writer(f)
csv_writer.writerow(['音乐名','网址'])
# 注意headers里面的大小写
headers = {'referer': 'https://music.163.com/',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36'
}
url = 'https://music.163.com/discover/toplist'
response = requests.get(url=url, headers=headers)
print(response.text)
title_herf = re.findall('<li><a href="/(.*?)">(.*?)</a></li>', response.text)
for i in title_herf:
title = i
herf ="https://music.163.com/#/"+ i
print(title, herf)
with open("网易云音乐排行榜.csv", mode="a", encoding="utf-8") as f:
csv_writer = csv.writer(f)
csv_writer.writerow()
'''
https://music.163.com/#/song?id=1981889746
'''
学习了,感谢楼主 学习了,感谢分享 学习了 感谢 好棒,随时知道流行趋势 感谢楼主 不错,思路可以借鉴 哪有时间看啊。 感谢楼主 感谢楼主
页:
[1]
2