python接口自动化之get请求
接口自动化之get请求代码:
#coding:utf-8
import requests
#发送无参数的get请求
#发送get请求
response=requests.get('https://www.baidu.com/')
#打印响应内容
print(response.text)
#打印响应状态码
print(response.status_code)
#发送有参数的get请求
param={
'q':'che'}
header={
'User-Agent':'ua.chrome'}
response2=requests.get("https://www.douban.com/search",params=param,headers=header)
#打印响应信息
print(response2.text)
#打印状态码
print(response2.status_code)
接口自动化之get代码执行结果: