python接口自动化之get请求

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代码执行结果:

执行结果1
结果2

猜你喜欢

转载自blog.csdn.net/qq_38484679/article/details/113570917