-
响应基本API
查看全部 -
Hyper Text Transfer Protocol(简称HTTP)超文本传输协议
查看全部 -
Session:
- 服务器端存储
Cookie:
- 客户端存储
cookies=dict(c=requests.get(url).cookies['cookiename'])
requests.get(url,cookies=cookies)
查看全部 -
proxy
response = requests.get(url, proxies=proxies)
查看全部 -
- Base Auth
Basic: base64.b64decode('xxxxxxxxx')
- OAuth
headers={'Authorization': 'token xxxxxxxxxxxxxxxx'}
from requests.auth import AuthBase
class GithubAuth(AuthBase):
def __init__(self. token):
self.token = token
def __call__(self,r):
r.headers['Authorization'] = ''.join(['token',self.token])
return r
查看全部 -
def m_hook_fun()
response.headers['Content-Type']
def main()
requests.get(url,hooks=dict(response=m_hook_fun))
查看全部 -
response = requests.get(url, headers=headers, stream=True)
#with closing(requests.get(Jurl,xxx)as response:
with open( 'xxx.jpg', 'wb') as fd:
for chunk in response.iter_content(123):
fd.write(chunk)
查看全部 -
from requests import Request,Session
查看全部 -
response.raise_for_status()
查看全部 -
带参数的请求
- URL Parameters: URL参数
request.get(url,params={'key':'value'})
- 表单参数
Content-Type: application/x-www-form-urlencoded
request.post(url,data={'key':'value'})
- Json参数提交
Content-Type:application/json
requests.post(url,json={'key':'value'})
查看全部 -
GET
POST
PUT
PATCH
DELETE
HEAD
OPTIONS
查看全部 -
gunicorn httpbin
gunicorn httpbin:app
查看全部 -
windows10安装gunicorn,httpbin。
启动 gunicorn httpbin:app
报错:ModuleNotFoundError: No module named 'pwd'
原因: gunicorn不支持Windows系统。
查看全部 -
requests下载图片
查看全部 -
response content text json 字符串,unicode,json查看全部
举报