async def input_verify_code(self, frame, fromStore, type): logger.info("需要要手机验证码") ms = MySql(db_setting=TEST_SERVER_DB_TEST) ms.delete(t='phone_verify', c={'fromStore': fromStore}) ms.insert(t="phone_verify", d={"fromStore": fromStore}) mail(fromStore + "手机验证码", fromStore + "登陆需要手机验证码", MAIL_RECEIVERS) verify_code = "0" while 1: if type == 0: await frame.click(PHONE_GET_CODE[0]) else: await frame.click(PHONE_GET_CODE[1]) for i in range(120): await asyncio.sleep(5) verify_code = ms.get_one(t='phone_verify', cn=['verify_code'], c={"fromStore": fromStore}) if verify_code != "0": ms.delete(t='phone_verify', c={'fromStore': fromStore}) del ms break if verify_code != "0": break await asyncio.sleep(10) if type == 0: await frame.type(PHONE_CHECK_INPUT[0], verify_code, {'delay': self.input_time_random() - 50}) await frame.click(PHONE_SUBMIT_BTN[0]) else: await frame.type(PHONE_CHECK_INPUT[1], verify_code, {'delay': self.input_time_random() - 50}) await frame.click(PHONE_SUBMIT_BTN[1])
async def parse_order_detail_item(continue_code, i, main_orders, sub_orders, tb_order_item, ms): for j in range(len(sub_orders)): tb_order_detail_item = TBOrderDetailItem() tb_order_detail_item.orderNo = main_orders[i]["id"] tb_order_detail_item.itemNo = j try: tb_order_detail_item.goodsCode = sub_orders[j]['itemInfo'][ 'extra'][0]['value'] except KeyError: tb_order_detail_item.goodsCode = 'error' tb_order_detail_item.tbName = format_tb_name( sub_orders[j]['itemInfo']['title']) tb_order_detail_item.unitPrice = sub_orders[j]['priceInfo'][ 'realTotal'] tb_order_detail_item.sellNum = sub_orders[j]['quantity'] tb_order_detail_item.orderStatus = tb_order_item.orderStatus tb_order_detail_item.url = "https:" + sub_orders[j]['itemInfo'][ 'itemUrl'] try: attribute_list = sub_orders[j]['itemInfo']['skuText'] except KeyError: pass else: tb_order_detail_item.goodsAttribute = format_attribute( attribute_list) try: operations = sub_orders[j]['operations'] except KeyError: pass else: for x in range(len(operations)): t = operations[x]['style'] if t in ['t12', 't16'] and operations[x]['text'] != "退运保险": tb_order_detail_item.refundStatus = operations[x][ 'text'] tb_order_detail_item.isRefund = "1" elif t == 't0' and operations[x]['text'] == '已取消': continue_code = 1 delete_item = { 'orderNo': tb_order_detail_item.orderNo, 'itemNo': tb_order_detail_item.itemNo, 'goodsCode': tb_order_detail_item.goodsCode } ms = MySql() is_exist = ms.get(t="tb_order_detail_spider", l=1, c=delete_item) if is_exist: ms.delete(t="tb_order_detail_spider", c=delete_item) sql = "UPDATE tb_order_detail_spider SET itemNo=itemNo-1 " \ "WHERE orderNo='{}' " \ "AND itemNo>'{}'".format(tb_order_detail_item.orderNo, tb_order_detail_item.itemNo) ms.update(sql=sql) pass if continue_code: continue tb_order_detail_item.save(ms)