Commit af71237e by lei

1

parent f58a8c54
...@@ -204,7 +204,7 @@ class ToWork: ...@@ -204,7 +204,7 @@ class ToWork:
except Exception as e: except Exception as e:
logger.error(e) logger.error(e)
async def img_callback(self, task, href): async def img_callback(self, task, href, message=''):
# 先要上传图片 # 先要上传图片
# cur_href = await self.upload_img(task, href) # cur_href = await self.upload_img(task, href)
url = task['callback'] url = task['callback']
...@@ -215,6 +215,8 @@ class ToWork: ...@@ -215,6 +215,8 @@ class ToWork:
'task_id': task['task_id'], 'task_id': task['task_id'],
'prompt_id': task['prompt_id'], 'prompt_id': task['prompt_id'],
} }
if message:
params['message'] = message
res = req.post(url, data=params) res = req.post(url, data=params)
logger.info(res) logger.info(res)
except Exception as e: except Exception as e:
...@@ -243,11 +245,17 @@ class ToWork: ...@@ -243,11 +245,17 @@ class ToWork:
if text_el: if text_el:
title = await page.evaluate('(element) => element.textContent', text_el) title = await page.evaluate('(element) => element.textContent', text_el)
logger.info(title) logger.info(title)
if '%' not in title and '(Waiting to start)' not in title and '正在发送命令' not in title: # 判断失败
if 'Failed to process your command' in title:
logger.info('本次任务失败')
# 回调
await self.img_callback(task, '', title)
elif '%' not in title and '(Waiting to start)' not in title and '正在发送命令' not in title:
logger.info('任务完成') logger.info('任务完成')
# 最后一个链接 # 最后一个链接
'//*[@id="message-accessories-1095187577776124025"]/div[1]/div/div/div/div/div/a'
img_path = '//*[contains(@id, "message-accessories-")]/div[1]/div/div/div/div/div/a' img_path = '//*[contains(@id, "message-accessories-")]/div[1]/div/div/div/div/div/a'
img_el = await self.CheckElement(page, img_path, 20) img_el = await self.FindElement(page, img_path, 'last')
if img_el: if img_el:
href = await page.evaluate('img_el => img_el.href', img_el) href = await page.evaluate('img_el => img_el.href', img_el)
if href: if href:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment