00 练习文章图片音频下载

本文详细介绍了HTTP状态响应码的含义与分类,通过Python的requests库演示了如何从互联网上获取文章、图片和音频文件的具体过程。实践案例丰富,适合初学者快速掌握网络爬虫的基本技能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

# Author:Nimo_Ding

'''
练习要求:
获取文章《HTTP状态响应码》全部内容,并且打印出全文内容。
'''
import requests
res=requests.get('https://localprod.pandateacher.com/python-manuscript/crawler-html/exercise/HTTP%E5%93%8D%E5%BA%94%E7%8A%B6%E6%80%81%E7%A0%81.md')
print(res.text)
code=open('00HTTP状态响应码','a+')
code.write(res.text)
code.close()


'''
练习获取网上的图片文件。
'''
import requests
res=requests.get('https://res.pandateacher.com/2019-01-12-15-29-33.png')
spider_photo=open('00spider.jpg','wb')
spider_photo.write(res.content)
spider_photo.close()


'''
练习获取网上的音频文件。
https://static.pandateacher.com/Over%20The%20Rainbow.mp3
'''
import requests
res=requests.get('https://static.pandateacher.com/Over%20The%20Rainbow.mp3')
music=open('00music.mp3','wb')
music.write(res.content)
music.close()

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值