Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
egg-puppeteer
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ui
egg-puppeteer
Commits
318738fb
Commit
318738fb
authored
Jun 03, 2020
by
郝聪敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改登录问题
parent
64e037b3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
helper.js
app/extend/helper.js
+4
-0
home.js
app/service/home.js
+5
-2
No files found.
app/extend/helper.js
View file @
318738fb
...
@@ -34,6 +34,10 @@ module.exports = {
...
@@ -34,6 +34,10 @@ module.exports = {
return
this
.
writeTecentLoginCode
(
page
);
return
this
.
writeTecentLoginCode
(
page
);
}
}
this
.
ctx
.
logger
.
info
(
`tecent mail: 获取到的验证码是
${
code
}
`
);
this
.
ctx
.
logger
.
info
(
`tecent mail: 获取到的验证码是
${
code
}
`
);
await
page
.
$eval
(
'
#inputuin
'
,
input
=>
{
input
.
value
=
''
;
});
await
page
.
$eval
(
'
#pp
'
,
input
=>
{
input
.
value
=
''
;
});
await
page
.
type
(
'
#inputuin
'
,
this
.
ctx
.
app
.
config
.
tecent
.
account
);
await
page
.
type
(
'
#pp
'
,
this
.
ctx
.
app
.
config
.
tecent
.
password
);
await
page
.
type
(
'
#vc
'
,
code
);
await
page
.
type
(
'
#vc
'
,
code
);
await
page
.
click
(
'
#auto_login_in_five_days_pwd
'
);
await
page
.
click
(
'
#auto_login_in_five_days_pwd
'
);
await
page
.
click
(
'
#btlogin
'
);
await
page
.
click
(
'
#btlogin
'
);
...
...
app/service/home.js
View file @
318738fb
...
@@ -472,6 +472,7 @@ class HomeService extends Service {
...
@@ -472,6 +472,7 @@ class HomeService extends Service {
async
sendMail
(
mails
=
[])
{
async
sendMail
(
mails
=
[])
{
const
{
ctx
,
service
}
=
this
;
const
{
ctx
,
service
}
=
this
;
const
result
=
[];
const
result
=
[];
let
browser
=
null
;
const
browserConfig
=
{
const
browserConfig
=
{
args
:
[
'
--no-sandbox
'
,
'
--disable-setuid-sandbox
'
],
args
:
[
'
--no-sandbox
'
,
'
--disable-setuid-sandbox
'
],
headless
:
true
,
headless
:
true
,
...
@@ -483,7 +484,7 @@ class HomeService extends Service {
...
@@ -483,7 +484,7 @@ class HomeService extends Service {
if
(
!
mails
.
length
)
return
result
;
if
(
!
mails
.
length
)
return
result
;
let
cookie
=
fs
.
readFileSync
(
path
.
join
(
__dirname
,
cookiePath
)).
toString
();
let
cookie
=
fs
.
readFileSync
(
path
.
join
(
__dirname
,
cookiePath
)).
toString
();
try
{
try
{
const
browser
=
await
puppeteer
.
launch
(
browserConfig
);
browser
=
await
puppeteer
.
launch
(
browserConfig
);
const
page
=
await
browser
.
newPage
();
const
page
=
await
browser
.
newPage
();
if
(
cookie
)
await
ctx
.
helper
.
addCookies
(
JSON
.
parse
(
cookie
),
page
);
if
(
cookie
)
await
ctx
.
helper
.
addCookies
(
JSON
.
parse
(
cookie
),
page
);
await
page
.
goto
(
'
https://exmail.qq.com
'
);
await
page
.
goto
(
'
https://exmail.qq.com
'
);
...
@@ -579,11 +580,13 @@ class HomeService extends Service {
...
@@ -579,11 +580,13 @@ class HomeService extends Service {
result
.
push
({
id
:
mails
[
i
].
id
,
url
:
imagePath
});
result
.
push
({
id
:
mails
[
i
].
id
,
url
:
imagePath
});
await
mainFrame
.
waitFor
(
parseInt
((
Math
.
random
()
*
3
+
1
)
*
1000
,
10
));
await
mainFrame
.
waitFor
(
parseInt
((
Math
.
random
()
*
3
+
1
)
*
1000
,
10
));
}
}
await
browser
.
close
();
}
catch
(
e
)
{
}
catch
(
e
)
{
await
service
.
dingTalk
.
push
(
e
&&
e
.
message
);
await
service
.
dingTalk
.
push
(
e
&&
e
.
message
);
ctx
.
logger
.
error
(
e
);
ctx
.
logger
.
error
(
e
);
}
}
if
(
browser
)
await
browser
.
close
();
return
result
;
return
result
;
}
}
...
...
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