mirror of
https://github.com/zhao-zg/jd-login.git
synced 2026-01-14 23:10:44 +08:00
Compare commits
3 Commits
cbb57ccfea
...
ee2c7f842e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee2c7f842e | ||
|
|
06f6a90ea1 | ||
|
|
d50a32cc3e |
26
login.py
26
login.py
@ -51,6 +51,13 @@ supported_colors = {
|
||||
"红色": ([0, 50, 50], [10, 255, 255]),
|
||||
}
|
||||
|
||||
|
||||
async def deleteSession(workList, uid):
|
||||
s = workList.get(uid, "")
|
||||
if s:
|
||||
await asyncio.sleep(15)
|
||||
del workList[uid]
|
||||
|
||||
async def loginPhone(chromium_path, workList, uid, headless):
|
||||
# 判断账号密码错误
|
||||
async def isWrongAccountOrPassword(page, verify=False):
|
||||
@ -205,9 +212,11 @@ async def loginPhone(chromium_path, workList, uid, headless):
|
||||
except Exception as e:
|
||||
logger.info("异常退出")
|
||||
logger.error(e)
|
||||
await browser.close()
|
||||
await deleteSession(workList, uid)
|
||||
workList[uid].status = "error"
|
||||
workList[uid].msg = "异常退出"
|
||||
break
|
||||
raise e
|
||||
|
||||
logger.info("任务完成退出")
|
||||
|
||||
@ -495,9 +504,11 @@ async def loginPassword(chromium_path, workList, uid, headless):
|
||||
content = await page.content()
|
||||
with open(f"error_{usernum}-html-{dateTime}.html", 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
await browser.close()
|
||||
await deleteSession(workList, uid)
|
||||
workList[uid].status = "error"
|
||||
workList[uid].msg = "异常退出"
|
||||
break
|
||||
raise e
|
||||
|
||||
logger.info("任务完成退出")
|
||||
logger.info("开始删除缓存文件......")
|
||||
@ -1200,5 +1211,16 @@ async def main(workList, uid, oocr, oocrDet):
|
||||
await asyncio.sleep(random.uniform(2, 4))
|
||||
logger.info(f"进行第{try_time}次重试")
|
||||
try_time += 1
|
||||
if os.path.exists("image.png"):
|
||||
os.remove("image.png")
|
||||
if os.path.exists("template.png"):
|
||||
os.remove("template.png")
|
||||
if os.path.exists("shape_image.png"):
|
||||
os.remove("shape_image.png")
|
||||
if os.path.exists("rgba_word_img.png"):
|
||||
os.remove("rgba_word_img.png")
|
||||
if os.path.exists("rgb_word_img.png"):
|
||||
os.remove("rgb_word_img.png")
|
||||
await deleteSession(workList, uid)
|
||||
logger.info("登录完成")
|
||||
await asyncio.sleep(10)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user