美文网首页
用python实现简单的接口测试

用python实现简单的接口测试

作者: R夢夢夢冉 | 来源:发表于2017-01-04 16:49 被阅读0次

import requests    #导入requests库

url="https://api.douban.com/v2/book/:id/annotations"    #接口地址请求的URL

#提交到接口中的数据

data={

"content":u"哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈诶",

"page":2,

"chapter":3,

"privacy":1

}

#请求头

header={

"Content-type":"application/json"}

a=requests.post(url=url,data=data,headers=header) #赋值给a,发送post请求

print a.json() #输出a

相关文章

网友评论

      本文标题:用python实现简单的接口测试

      本文链接:https://www.haomeiwen.com/subject/awbkpttx.html