Skip to content

Commit

Permalink
feat: 增加快乐购provider
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Nov 26, 2017
1 parent 0cd1bac commit 25e97bc
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions app/providers/快乐购.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const Provider = require('../provider');
const utils = require('../utils');

module.exports = class extends Provider {
constructor() {
super();
this.url = `http://www.happigo.com/register/`;
}
async resolve(ctx) {
const options = ctx.options;
const page = ctx.page;

await page.type('#mobile', options.phone, { delay: 100 });

await page.click('#send_auth_code');

await utils.sleep(500);

// 检验是否发送成功
const isSuccess = await page.evaluate(() => {
const span = document.querySelectorAll('#show_times');
return /\d+/.test(span.innerText);
});

if (isSuccess === false) {
throw null;
}
}
};

0 comments on commit 25e97bc

Please sign in to comment.