🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] ### 接口文档 #### 参数说明 | 参数名 | 是否必须 | 描述 | | --- | --- | --- | | ip | 是 | ip地址 | | sign | 是| 请求签名,签名方式:md5(key+ip),key由服务端指定,向将key与ip字符串拼接起来,然后对字符串进行md5加密。| API地址:http://ptqa.com/location 请求方法:POST #### 响应格式范例 ```python {"code": 1, "msg": "success", "data": {"country": "Thailand", "countryCode": "TH", "city": "Bankok", "ipaddress": "171.96.0.127"}} ``` ### python 测试用例示例 ```python import hashlib import requests import pytest def get_sign(ip): key = "Milton_PTQA" m = hashlib.md5(str(key + ip).encode()) sign = m.hexdigest() return sign def post_request(url, params): params["sign"] = get_sign(params["ip"]) resp = requests.post(url, data=params) print(resp.json()) return resp.json() class TestLocation(): def test_location_1(self): """ 用例一""" params = { "ip": "171.96.0.127" } resp = post_request("http://ptqa.com/location", params) assert resp['code'] == 1 def test_location_2(self): """ 用例二""" params = { "ip": "171.96.0.128" } resp = post_request("http://ptqa.com/location", params) assert resp['code'] == 1 if __name__ == '__main__': args = ['-s', '-q'] pytest.main(args) ``` <hr style="margin-top:100px"> :-: ![](https://box.kancloud.cn/2ff0bc02ec938fef8b6dd7b7f16ee11d_258x258.jpg) ***微信扫一扫,关注“python测试开发圈”,了解更多测试教程!***