Requests库
Requests库中,encoding属性代表了从服务器返回HTTP协议头所推荐的编码方式,apparent_encoding属性代表了从服务器返回HTTP协议内容部分猜测的编码方式
在Requests库的get()方法中,能够定制向服务器提交HTTP请求头的参数是headers
Response类的.content属性用于获取网络上某个URL对应的图片或视频等二进制资源
raise_for_status()
Requests库的异常
Requests库的主要方法
BeautifulSoup库
BeautifulSoup类的基本元素:
Tag、Name、Attribute、NavigableString、Comment
标签树下行遍历属性:
.contents //Beautiful Soup库在进行标签树下行遍历时,以列表形式返回儿子节点
.children
.descendants
标签树上行遍历属性:
.parent
.parents
标签树平行遍历属性:
.next_sibling
.previous_sibling
.next_sibling
.previous_siblings
Scrapy
Scrapy结构:
Scrapy常用命令:
request和Scrapy比较:
Request:
Response: