当前位置: 首页> 技术文章> Python 接口自动化之requests库

Python 接口自动化之requests库

Python 接口自动化之requests库

一. 了解http协议

1.定义: TheHypertext Transfer Protocol (HTTP) is an application protocol (应用层)for distributed(分布式), collaborative(协作式), and hypermedia information systems(超文本信息系统). HTTP is the foundation of data communication for theWorld Wide Web.(HTTP是互联网的基石)

2. 自定义图形表示http协议

Client端是发送请求的,Server端是处理和响应请求的
3. Http协议的三次握手

4. 常用的http请求方法

运行urlib做一个简单的接口案例

二、urllib和requests小程序(请求百度网页)

python自带的urllib包:

import urllib.request
#请求百度网页
re= urllib.request.urlopen(‘http://www.baidu.com’,data=None,timeout=10)
print(re.info())

运用Request包

import requests
#请求百度网页
response =requests.get(‘https://www.baidu.com’,data=None, timeout=10)
print(response.headers)






上一篇: 为什么要对软件进行测试?

下一篇: 软件测试之手工测试人员如何转测试开发?

QQ技术交流群

多测师官方学习交流
556733550

加入群聊