python如何使用requests检查请求

518次阅读
没有评论

python如何使用requests检查请求

python requests模块说明

当发出请求时,requests 库会在将请求实际发送到目标服务器之前准备该请求。 请求准备包括像验证头信息和序列化JSON内容等。

python requests模块检查请求实例

可以通过访问 .request 来查看 PreparedRequest:

>>> response = requests.post('https://httpbin.org/post', json={'key':'value'})
>>> response.request.headers['Content-Type']
'application/json'
>>> response.request.url
'https://httpbin.org/post'
>>> response.request.body
b'{"key": "value"}'

通过检查 PreparedRequest,可以访问有关正在进行的请求的各种信息,例如有效负载,URL,头信息,身份验证等。

神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试
1

相关文章:

版权声明:wuyou2021-04-30发表,共计430字。
新手QQ群:570568346,欢迎进群讨论 Python51学习