豆瓣接口用例

Posted 藤上小冬瓜

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了豆瓣接口用例相关的知识,希望对你有一定的参考价值。

get 方法用例

url = "https://aip.douban.com/"#首页地址
url_path =url + "v2/book/search"#子页地址
data ={"q":"bb"}#需要传入的数据
re = requests.get(url = url_path,params = data)#获取地址,传入数据
json_1 =re.json()#转换json格式
asser_Equal(re.status_code,200,"接口请求失败")

post方法用例

url = "https://manage-eloan-test.xinzhentech.com/modules/ecust/ecustInfo/saveOrUpdate.htm"

datas = {"contacts":[{"contactuser":"深圳","contactphone":"13245937882"}]}

header = {Accept:text/javascript, text/html, application/xml, text/xml, */*,
     Accept-Encoding:gzip, deflate,
     Accept-Language:zh-CN,zh;q=0.8,
       Connection:keep-alive,
      Content-Length:203,
      Content-Type:application/x-www-form-urlencoded,
      Cookie:JSESSIONID=6C572BAB9C882B07B2A51B162668D403; username=system,
      Host:manage-eloan-test.xinzhentech.com,
      Origin:https://manage-eloan-test.xinzhentech.com,
      Referer:https://manage-eloan-test.xinzhentech.com/build/index.html;
jsessionid=D7EB59F8AFCEF0046BF6C6B962CEAD66
,         User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit/537.36
(KHTML,likeGecko) Chrome/49.0.2623.110 Safari/537.36
,      X-Requested-With:XMLHttpRequest, } ret = request.post(url,data = datas ,headers = header) r_dict = ret.json() assert_Equal(r_dict["msg"],"对比结果""自定义报错提示信息") assert_Equal(r_dict[code],200,"自定义报错信息")

 

以上是关于豆瓣接口用例的主要内容,如果未能解决你的问题,请参考以下文章

微信小程序豆瓣电影项目的改造过程经验分享

豆瓣图书接口API

从父片段到选项卡片段的接口侦听器不起作用

接口测试用例编写要点都有哪些?

微信小程序开发--豆瓣图书接口

Python Api接口自动化测试框架 代码写用例