代码拉取完成,页面将自动刷新
#!/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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。