Commit 318738fb authored by 郝聪敏's avatar 郝聪敏

修改登录问题

parent 64e037b3
...@@ -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');
......
...@@ -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;
} }
......
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