def handle(self, *args, **options): print "__token" print datetime.now() current_token = dbutils.get_token_code() if current_token: print "has a token!" else: times = 0 token = get_token_good() while token is None: token = get_token_good() times += 1 time.sleep(5) if times >= 15: break if token: dbutils.add_token(token) else: print "token is None" print "ok"
HEADERS = { "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "Accept-Encoding": "gzip, deflate, sdch, br", "Accept-Language": "zh-CN,zh;q=0.8,en;q=0.6,zh-TW;q=0.4", "Cache-Control": "no-cache", "Connection": "keep-alive", "Pragma": "no-cache", 'Content-type': 'application/x-www-form-urlencoded', 'Host': 'shandianbao.chinapnr.com', 'Origin': 'https://shandianbao.chinapnr.com', 'Referer': 'https://shandianbao.chinapnr.com/supm/main/index', 'X-Requested-With': 'XMLHttpRequest', "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) C,hrome/43.0.2357.124 Safari/537.36", } DAYS = 1 token = get_token_code() class Command(BaseCommand): """ 数据来源https://shandianbao.chinapnr.com/supm/TRD101/index 交易管理---交易明细管理 POST https://shandianbao.chinapnr.com/supm/TRD101/controlagent agentLevel=&merId=&agentId=&mobileId=&ordId=&payCardId=&transType=&transStat=&devsId=&dcType=&startDate=2018-08-30&endDate=2018-08-30&vipGate= """ def add_arguments(self, parser): parser.add_argument( '--start', action='store', dest='start', help=''