From 09adc57c949cfd9cd3840326d294e27983bd3a74 Mon Sep 17 00:00:00 2001 From: axetroy Date: Sun, 1 Oct 2017 12:20:33 +0800 Subject: [PATCH] update --- app/providers/aliyun.js | 2 ++ app/providers/juhe.js | 4 ++- app/providers/qq.js | 3 ++ app/providers/taobao.js | 2 ++ app/providers/xiangrikui.js | 7 ----- app/providers/youku.js | 62 +++++++++++++++++++++++++++++++++++++ index.js | 2 ++ 7 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 app/providers/youku.js diff --git a/app/providers/aliyun.js b/app/providers/aliyun.js index 2fd5c8c..c48dffc 100644 --- a/app/providers/aliyun.js +++ b/app/providers/aliyun.js @@ -61,6 +61,8 @@ class AliYunProvider extends Provider { await page.mouse.click(438, 433); + await utils.sleep(2000); + await browser.close(); } } diff --git a/app/providers/juhe.js b/app/providers/juhe.js index 840971d..f3c9e9a 100644 --- a/app/providers/juhe.js +++ b/app/providers/juhe.js @@ -44,7 +44,9 @@ class JuheProvider extends Provider { await $sendBtn.click({ button: 'left' }); - // await browser.close(); + await utils.sleep(2000); + + await browser.close(); } } diff --git a/app/providers/qq.js b/app/providers/qq.js index 83acb83..b083f0a 100644 --- a/app/providers/qq.js +++ b/app/providers/qq.js @@ -2,6 +2,7 @@ const puppeteer = require('puppeteer'); const Provider = require('../provider'); const config = require('../config'); +const utils = require('../utils'); class QQProvider extends Provider { constructor() { @@ -39,6 +40,8 @@ class QQProvider extends Provider { await page.type(phone + '', { delay: 100 }); await $send.click({ button: 'left' }); + await utils.sleep(2000); + await browser.close(); } } diff --git a/app/providers/taobao.js b/app/providers/taobao.js index a2c78d9..b2c2637 100644 --- a/app/providers/taobao.js +++ b/app/providers/taobao.js @@ -57,6 +57,8 @@ class TaobaoProvider extends Provider { await page.mouse.click(500, 380); + await utils.sleep(2000); + await browser.close(); } } diff --git a/app/providers/xiangrikui.js b/app/providers/xiangrikui.js index 107f8c3..f7059dd 100644 --- a/app/providers/xiangrikui.js +++ b/app/providers/xiangrikui.js @@ -38,13 +38,6 @@ class XiangRiKuiProvider extends Provider { await $mobile.click(); await page.type(phone + '', { delay: 100 }); - // 按下鼠标,拖动滚动条 - await page.mouse.move(415, 325, { step: 10 }); - await $slide.click(415, 325); - await page.mouse.down({ - button: 'left' - }); - await $submit.click({ button: 'left' }); await utils.sleep(2000); diff --git a/app/providers/youku.js b/app/providers/youku.js new file mode 100644 index 0000000..65eb87b --- /dev/null +++ b/app/providers/youku.js @@ -0,0 +1,62 @@ +const puppeteer = require('puppeteer'); +const Provider = require('../provider'); + +const config = require('../config'); +const utils = require('../utils'); + +class QQProvider extends Provider { + constructor() { + super(); + } + async resolve(phone) { + const URL = `http://www.youku.com/`; + const browser = await puppeteer.launch({ + headless: config.isProduction + }); + + const page = await browser.newPage(); + await page.goto(URL, { + networkIdleTimeout: 5000, + waitUntil: 'networkidle', + timeout: 3000000 + }); + + await page.deleteCookie(); + + const $user = await page.$('#qheader_login'); // 点击登陆 + + await $user.click({ button: 'left' }); + + await utils.sleep(2000); + + const $go2register = await page.$('#YT-registeBtn'); // phone + + await $go2register.click({ button: 'left' }); + + await utils.sleep(2000); + + const [$phone, $password, $repassword, $send] = await Promise.all([ + page.$('#YT-mPassport'), // phone + page.$('#YT-mRegPassword'), // password + page.$('#YT-mRepeatPwd'), // 确认密码 + page.$('#YT-mGetMobileCode') // 发送验证码 + ]); + + await $phone.click({ button: 'left' }); + await page.type(phone + '', { delay: 100 }); + + await $password.click({ button: 'left' }); + await page.type(`abc123abc123`, { delay: 100 }); + + await $repassword.click({ button: 'left' }); + await page.type(`abc123abc123`, { delay: 100 }); + + await $send.click({ button: 'left' }); + + await utils.sleep(2000); + + await browser.close(); + } +} + +module.exports = QQProvider; diff --git a/index.js b/index.js index 37acc7f..cc0adf5 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,7 @@ const AliyunProvider = require('./app/providers/aliyun'); const TaobaoProvider = require('./app/providers/taobao'); const JuheProvider = require('./app/providers/juhe'); const XiangRiKuiProvider = require('./app/providers/xiangrikui'); +const YoukuProvider = require('./app/providers/youku'); new App(13377175342) .provider(QQProvider) @@ -11,4 +12,5 @@ new App(13377175342) .provider(TaobaoProvider) .provider(JuheProvider) .provider(XiangRiKuiProvider) + .provider(YoukuProvider) .bootstrap();