def serverlist(): if not session: return redirect('/login/') idcs = getlist('newidc',idc_field)['msg'] idcs = dict((idc['id'],idc['name_cn']) for idc in idcs) print "idcs-------idcs" print idcs servers = getlist('server',server_field)['msg'] print "servers ---list--------------" print servers for i in servers: if i['idc_id'] in idcs: i['idc_id'] = idcs[i['idc_id']] print "newnew-----newservers" print servers return render_template("server_list.html",result=servers,info=session)
def idclist(): if not session: return redirect('/login/') result = getlist('newidc',idc_field) print result result = result['msg'] return render_template("idc_list.html",result=result,info = session)
def userlist(): if not session or session['role'] != 0: return redirect("/login/") result = getlist('taokey',field) if result['code'] == 0: result = result['msg'] return render_template("userlist.html",result=result)
def userlist(): if session: result = getlist('taokey', field) print result return render_template('userlist.html', result=result) else: return redirect('/')
def userlist(): if not session: return redirect("/login") result = getlist('user', field) if result['code'] == 0: result = result['msg'] return render_template("userlist.html", result=result, info=session)
def cabinetlist(): if not session: return redirect('/login/') idcs = getlist('newidc',idc_field)['msg'] # idcs = {idc['id']:idc['name'] for idc in idcs} idcs = dict((idc['id'],idc['name_cn']) for idc in idcs) print "idcs-------idcs" print idcs cabinets = getlist('cabinet',cabinet_field)['msg'] print "cabinets ---list--------------" print cabinets for i in cabinets: if int(i['idc_id']) in idcs: i['idc_id'] = idcs[int(i['idc_id'])] print "newnew-----newcabinets" print cabinets return render_template("cabinet_list.html",result=cabinets)
def userlist(): if not session: return redirect("/login") result = getlist('user', field) util.WriteLog('[redirect /userlist/]').info('getlist--%s' % result) print "userlist-getlist" print result print '\n' print result['msg'] if result['code'] == 0: result = result['msg'] return render_template("userlist.html", result=result, info=session)
def order_list(): if request.method == 'GET': result = getlist('work_order', order_field) if result['code'] == 0: result = result['msg'] print "\n" print result for i in result: print i if int(i['status']) == 0: print i['status'] i['status'] = "doing" else: i['status'] = "done" return render_template('order_list.html', result=result, info=session)
# API getone_url = (f"{config['api_url']}&action=getone&" f"user_token={config['user_token']}") getcomment_url = (f"{config['api_url']}&action=getcomment" f"&user_token={config['user_token']}") getlist_url = (f"{config['api_url']}&action=getlist" f"&user_token={config['user_token']}") store_path = args.store_path sleep_factor = args.sleep_factor if not os.path.exists(store_path): os.makedirs(store_path) # 获取最新帖子pid max_pid = 0 page = getlist(1, getlist_url) page = json.loads(page, encoding='utf-8') print(page) max_pid = max(map(lambda x: int(x['pid']), page['data'])) start_pid = max_pid if args.start is None else args.start end_pid = args.end if args.end is not None else 1 n = args.n assert n > 0, "n 应为正整数" # 根据start end 爬取页面 print(f"spider pid range: {start_pid, end_pid}") s = end_pid print(s) with tqdm(total=start_pid - end_pid + 1) as pbar: while True: spider_comments(range(s, s + n), getcomment_url, store_path)
import json from utils import getlist with open('config.json', 'r') as f: config = json.load(f) getlist_url = (f"{config['api_url']}&action=getlist" f"&user_token={config['user_token']}") a = getlist(1500, getlist_url) print(a)
def userlist(): if not session or session["role"] == 1: return redirect("/login/") result = utils.getlist('user', field) return render_template("userlist.html", result=result)