目录
2.requests.request(method,url,**kwargs)
一、requests库
最好用的网页爬虫库之一,重点是requests.get()和requests.head()
使用pip install requests 在cmd中安装requests库
1.读取网页 requests.get()
import requests
r = requests.get("http://www.baidu.com")
r.status_code
# 传回200为一切正常
r.encoding = 'utf-8'
r.text
用type(r)来读取,r是一个Response类 <class 'requests.models.Response'>
2.requests.head() 获得页面的头部信息
3.其他方法,了解即可
http协议对资源的操作同上
patch可以改变一组或几组字段,put必须将所有字段一起提交,未提交会被删除
post一个字典:存储到表单的字段下