Python爬取照片

实例:爬取内蒙古科技大学校徽

打开网站

 

 

 

 

 

 

1.引入requests模块

 

 

 2.输入要请求的网站url

 

 

 网址获取

 3.发送请求头

 

 user-agent的获取

 

 user-agent的作用是伪装成浏览器,发送请求

4.使用get请求得到返回值赋值给response常量,输出response文本形式

 

 5.with open 方式保存获取的文件

 

 6.最终爬取结果

 

posted @ 2022-10-28 01:06  iqqq  阅读(59)  评论(0编辑  收藏  举报