Commit 9787170f by 马玮

add random wait

parent 9fc79f6f
...@@ -2,20 +2,20 @@ Installation ...@@ -2,20 +2,20 @@ Installation
------ ------
1.Install nvm 1.Install nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
2.Install node-v8.2.1-linux-x64.tar.xz by nvm 2.Install node-v8.2.1-linux-x64.tar.xz by nvm
nvm install v8.2.1 nvm install v8.2.1
3.Set environment 3.Set environment
sudo vi /etc/profile sudo vi /etc/profile
Add "export NODE_ENV=production" to bottom Add "export NODE_ENV=production" to bottom
source /etc/profile source /etc/profile
4.Install redis 4.Install redis
sudo yum install redis sudo yum install redis
To do list: To do list:
------ ------
1.Add random delay when access a page 1.Add random delay when access a page
2.Add error stack 2.Add error stack
\ No newline at end of file \ No newline at end of file

4.93 KB | W: | H:

4.93 KB | W: | H:

captcha1.png
captcha1.png
captcha1.png
captcha1.png
  • 2-up
  • Swipe
  • Onion skin

4.93 KB | W: | H:

4.93 KB | W: | H:

captcha2.png
captcha2.png
captcha2.png
captcha2.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -73,6 +73,15 @@ class AutoHome { ...@@ -73,6 +73,15 @@ class AutoHome {
.screenshot('try.png') .screenshot('try.png')
.exists('#loginout'); .exists('#loginout');
if (loginoutBtnExists) {
this.login.status = 'success';
this.login.message =
} else {
this.login.status = 'error';
}
this.login.message = loginoutBtnExists ? '登录成功' : '尝试登录失败';
await horseman.close(); await horseman.close();
return loginoutBtnExists; return loginoutBtnExists;
// await horseman // await horseman
...@@ -86,12 +95,7 @@ class AutoHome { ...@@ -86,12 +95,7 @@ class AutoHome {
async login() { async login() {
try { try {
let loginMsg; await this.tryLogin();
let loginStatus = await this.login();
if (loginStatus == 'success') {
console.log('在login肚子里tryLogin');
return loginStatus;
}
const username = this.params.username; const username = this.params.username;
const password = this.params.password; const password = this.params.password;
...@@ -248,11 +252,14 @@ class AutoHome { ...@@ -248,11 +252,14 @@ class AutoHome {
console.log('上牌地区:', clue.LicenseCityStr); console.log('上牌地区:', clue.LicenseCityStr);
console.log('线索意向车型:', clue.SpecNameStr); console.log('线索意向车型:', clue.SpecNameStr);
console.log('==========================================================================='); console.log('===========================================================================');
// await Promise.delay(5000);
} }
if (customerIndex < rowcount) { if (customerIndex < rowcount) {
params.pageIndex++; let randomSecs = randomInt(1, 8);
await fetchByPage(); console.log(`随机等待${randomSecs}秒`);
await Promise.delay(randomSecs*1000).then(async function() {
params.pageIndex++;
await fetchByPage();
});
} }
}); });
} }
......

269 KB | W: | H:

269 KB | W: | H:

try.png
try.png
try.png
try.png
  • 2-up
  • Swipe
  • Onion skin
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