楔子
现在, 要测试这些接口:
""" 用例集 case_set.py pip install requests """ import requests def v2ex_info(): """ 获取v2ex的网站信息 https://www.v2ex.com/api/site/info.json """ response = requests.get(url='https://www.v2ex.com/api/site/info.json') return response.json().get('title') # V2EX def v2ex_stats(): """ 获取v2ex的网站信息 https://www.v2ex.com/api/site/stats.json """ response = requests.get(url='https://www.v2ex.com/api/site/stats.json') return response.json().get('member_max') # int类型 def cnodejs(): """ 获取 cnodejs,推荐博客总数 """ response = requests.get('https://cnodejs.org/api/v1/topics') return response.json().get('success') # True if __name__ == '__main__': print(v2ex_info() == 'V2EX') print(type(v2ex_stats()) is int) print(cnodejs() is True)