分类:
文本类型数据:txt、csv、execl、数据库
多媒体类型:图片、音乐、视频
"""
y音频存储
"""
import requests
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
}
url = "https://sf-sycdn.kuwo.cn/f9b2e272af8bc91a6a815b70d9decaf1/65997b0c/resource/n2/42/67/550491908.mp3"
response = requests.get(url,headers=headers)
#使用content来存储音频
content = response.content
#保存音频
with open("music.mp3","wb") as file:
file.write(content)
csv格式存储
"""
csv 格式
"""
import csv
data = [[1,2,3],[2,3,4],[3,4,5]]
with open("data.csv", "w", encoding="utf-8") as file:
#构建csv对象
csv_writer = csv.writer(file)
#将data数据每一行写入csv文本里
csv_writer.writerows(data)
#输出
1,2,3
2,3,4
3,4,5
标签:存储,data,writer,爬虫,content,file,csv,数据 From: https://www.cnblogs.com/littlecc/p/17949991