一、前言
当然,有请求就有响应,浏览器在接收到服务端的响应数据后,经过处理将有用的信息展示到浏览器上。所以,接口自动化也需要对响应内容进行解析或提取有用的数据。
二、学习目标
1.响应报文的构成
2.响应数据有哪几种格式
三、知识点
1.【响应报文的构成】
2.【响应数据有哪几种格式】
与请求数据一样,响应头Content-Type中也规定了响应体的数据格式,requests模块对不同的响应数据的获取方式是不同的。
- json类型的响应数据
#这种格式的响应数据是{}形式的json类型
Content-Type: application/json; charset=utf-8
#响应体示例
{"Text":"Fiddler Jam - Your Secure, One-Pass Approach to Finding and Resolving Bugs","Tags":"Troubleshooting","Url":"https://www.telerik.com/blogs/fiddler-jam-your-secure-one-pass-approach-finding-resolving-bugs?utm_source=fiddlerapp&utm_medium=blog&utm_id=product"},{"Text":"What's the Best Way to Build Your Web Application? (Infographic)","Tags":"JS","Url":"https://www.telerik.com/blogs/best-way-to-build-web-app-infographic?utm_medium=product&utm_source=fiddlerapp&utm_campaign=kendo-ui-react-blog-dt-build-or-buy-infographic"},{"Text":"Exploring Fiddler Jam: Get Your Time Back by Solving Issues Faster","Tags":"How To","Url":"https://www.telerik.com/blogs/exploring-fiddler-jam-get-time-back-solving-issues-faster?utm_source=fiddlerapp&utm_medium=blog&utm_id=product"}
- xml类型的响应数据
#这种格式的响应数据是<a></a>形式的xml类型。XML 是一种标记语言,很类似 HTML
Content-Type: text/html; charset=UTF-8
#响应体示例
<note>
<to>George</to>
<from>John</from>
<heading>Reminder</heading>
<body>Don't forget the meeting!</body>
</note>
- Content-Type: image/jpeg
这种格式的响应数据类型是一些静态资源,什么是静态资源,如图片、音乐、视频等资源数据。
标签:HTTP,数据,utm,Content,响应,格式,Requests,Type From: https://www.cnblogs.com/ckxingchen/p/17057092.html