码迷,mamicode.com
首页 > 其他好文 > 详细

豆瓣接口用例

时间:2018-02-27 14:58:04      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:headers   UI   phone   x64   upd   com   dex   .com   update   

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,"自定义报错信息")

 

豆瓣接口用例

标签:headers   UI   phone   x64   upd   com   dex   .com   update   

原文地址:https://www.cnblogs.com/guog1/p/8478540.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!