requests.request(method,url,**kwargs)
result = requests.request(‘GET',data.get("url"),params=p)
result = requests.request(‘POST',data.get("url"),data=d)
method
GET, POST, PUT, DELETE, etc.
url
请求的地址
**kwargs
- params 参数,字典或字节组类型
- headers 请求头
- cookies 字典或cookieJar,需要在请求中发送的cookie
- files 字典类型,请求中需要传送的文件
- auth 元组,http身份验证信息
- data 字典或元组列表,post请求体
- json json格式的post请求体
requests.get(url,**kwargs)
requests.get(url,**kwargs)
requests.post(url,**kwargs)
requests.post(url,**kwargs)
result.code
result.content
Content of the response, in bytes.
result.text
Content of the response, in unicode.
result.cookies
A CookieJar of Cookies the server sent back.
result.headers
Case-insensitive Dictionary of Response Headers.
requests.session()
异常处理
requests.RequestException()
requests.ConnectionError()
requests.HTTPError()
requests.Timeout()
json.loads() 将json格式字符串数据转化成字典
json.dumps() 将python数据类型进行json格式编码—>字符串
网友评论