10 Star 38 Fork 18

Men/CoOper

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
testAPI.py 1.18 KB
一键复制 编辑 原始数据 按行查看 历史
mxx1219 提交于 2020-10-12 18:30 +08:00 . first commit
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2017-06-03 15:27:24
# @Author : luckcul (tyfdream@gmail.com)
# @Version : 2.7.12
import sys
import requests
import time
def check(baseUrl, api, detail):
'''
check function
'''
url = baseUrl + api + '&token=cooper'
print url
t1 = time.time()
try:
r = requests.get(url)
print r.status_code,
if detail:
print r.content
except requests.exceptions.ConnectionError as identifier:
print 'connection failed!'
t2 = time.time()
print '%.4f'%(t2-t1)
print '-------------------------------------------------'
return False if r.status_code != 200 else True
if __name__ == '__main__':
print sys.argv
baseUrl = 'http://192.168.' + sys.argv[1]
filename = sys.argv[2] + '.txt'
f = file(filename, 'r')
apis = [line.strip('\n') for line in f.readlines() if line.strip() != '']
# print apis
not200 = []
for api in apis:
if api[0] == '-':
continue
time.sleep(0.1)
flag = check(baseUrl, api, True if len(sys.argv) >= 4 else False)
if not flag : not200.append(api)
print 'not200: ', not200
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/lewismen/CoOper.git
git@gitee.com:lewismen/CoOper.git
lewismen
CoOper
CoOper
master

搜索帮助