Python爬虫:requests模块的基本使用

学习目标:

  1. 了解 requests模块的介绍
  2. 掌握 requests的基本使用
  3. 掌握 response常见的属性
  4. 掌握 requests.text和content的区别
  5. 掌握 解决网页的解码问题
  6. 掌握 requests模块发送带headers的请求
  7. 掌握 requests模块发送带参数的get请求

1 为什么要重点学习requests模块,而不是urllib

  • requests的底层实现就是urllib
  • requests在python2 和python3中通用,方法完全一样
  • requests简单易用
  • Requests能够自动帮助我们解压(gzip压缩的等)响应内容

2 requests的作用

作用:发送网络请求,返回响应数据

补充:Python爬虫踩坑:UnicodeEncodeError: ‘gbk‘ codec can‘t encode character 全有效解的决方法

  • PyCharm设置
  • 我注意到,我已经用utf-8来解码了&#

你可能感兴趣的:(python,爬虫,开发语言)