Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python_open_ai
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haojie
python_open_ai
Commits
af71237e
Commit
af71237e
authored
Apr 11, 2023
by
lei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
f58a8c54
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
ai_pyppeteer.py
+11
-3
No files found.
ai_pyppeteer.py
View file @
af71237e
...
@@ -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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment