zoukankan      html  css  js  c++  java
  • 使用python的 Requests模块实现简单的接口自动化

    1.安装Requests;

       pip  install requests

    2.在HTTP的请求中,最常使用的分别有GET,POST,通过request库也是可以实现,下面用post方法做接口测试

    #!/usr/bin/env python
    #coding:utf-8
    
    import requests
    #传入参数
    url = 'http://ip.taobao.com/service/getIpInfo.php'
    param = [{"ip": "117.89.35.58"}, {"ip": "117.79.35.58"}, {"ip": "117.69.35.58"}]
    def ta_bao(url,param):
        result=requests.post(url,param)#调用requests的post方法
        print (result.json())#打印返回结果
    for item in param:#通过for循环插入参数
     ta_bao(url,item)

     执行以下就会打印出接口返回结果

  • 相关阅读:
    Flesch Reading Ease (poj 3371)
    保留道路
    列车调度
    三角形
    高精度加法
    AC自动机(1)
    线段树
    并查集(3)
    并查集(2)
    并查集
  • 原文地址:https://www.cnblogs.com/cc233/p/10956232.html
Copyright © 2011-2022 走看看