Commit c7b520f9 by 马玮

Update .gitignore

parent a9233a5a
!/tmp/workflow
/tmp/captcha/* /tmp/captcha/*
/tmp/workflow/* /tmp/workflow/*
/logs/dealer/* /logs/dealer/*
\ No newline at end of file
...@@ -48,44 +48,48 @@ class Autohome extends Base { ...@@ -48,44 +48,48 @@ class Autohome extends Base {
async tryLogin() { async tryLogin() {
// 随机返回登录状态 // 随机返回登录状态
// return [new errors.TryLoginError('登录失效'), randomInt(0, 1)]; // return [new errors.TryLoginError('登录失效'), randomInt(0, 1)];
let newCookies;
let oldCookies;
let loginStatus = false;
try { try {
oldCookies = await DealerHelper.getCookies(this.params); let newCookies;
} catch (e) { let oldCookies;
logger.debug(`accountID: ${this.params.accountID}, 没有cookies: ${e}`); let loginStatus = false;
}
if (oldCookies) { try {
const horseman = new Horseman({ oldCookies = await DealerHelper.getCookies(this.params);
ignoreSSLErrors: true } catch (e) {
}); logger.debug(`accountID: ${this.params.accountID}, 没有cookies: ${e}`);
}
loginStatus =
await
horseman
.userAgent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0')
.viewport(1920, 1080)
.cookies(oldCookies)
.open('http://ics.Autohome.com.cn/passport/Home/Index')
.screenshot('tmp/workflow/autohome/tryLogin.png')
.exists('#loginout');
newCookies = await horseman.cookies();
await horseman.close();
}
if (loginStatus) { if (oldCookies) {
const params = this.params; const horseman = new Horseman({
params.cookies = newCookies; ignoreSSLErrors: true
});
logger.debug(`accountID: ${this.params.accountID}, cookies: ${JSON.stringify(newCookies)}`); loginStatus =
await
horseman
.userAgent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0')
.viewport(1920, 1080)
.cookies(oldCookies)
.open('http://ics.Autohome.com.cn/passport/Home/Index')
.screenshot('tmp/workflow/autohome/tryLogin.png')
.exists('#loginout');
newCookies = await horseman.cookies();
await horseman.close();
}
if (loginStatus) {
const params = this.params;
params.cookies = newCookies;
logger.debug(`accountID: ${this.params.accountID}, cookies: ${JSON.stringify(newCookies)}`);
await DealerHelper.saveCookies(params);
return 1;
} else {
throw new errors.TryLoginError('登录失效');
}
} catch (e) {
await DealerHelper.saveCookies(params);
return 1;
} else {
throw new errors.TryLoginError('登录失效');
} }
} }
......
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 sign in to comment