puppeteer实现产品经理咖啡自动签到

2020-07-01 08:57:26

puppeteer自动签到脚本,可用于pmcaff.com的自动签到

代码实现

代码采用nodejs实现
sign.js


const puppeteer = require('puppeteer')
let account = ''
let password = ''
;(async () => {
  const browser = await puppeteer.launch({
    headless: false,
    args: ['--no-sandbox', '--disable-setuid-sandbox'],
    dumpio: false,
  })
  const page = await browser.newPage()
  page.setUserAgent(
    'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1'
  )
  await page.setViewport({
    width: 375,
    height: 667,
    isMobile: true,
  })
  await page.goto('https://www.pmcaff.com/user/login?from=topbar', {
    waitUntil: 'networkidle2',
  })
  await page.type('input[name="phone"]', account)
  await page.type('input[name="password"]', password)
  console.log('登录...')
  await page.click('.pmcaff-account .btn-green')
  await page.waitForNavigation({
    waitUntil: 'networkidle0',
  })
  console.log('跳转签到页')
  await page.goto('https://www.pmcaff.com/user/sign?from=app', {
    waitUntil: 'networkidle2',
  })
  let btn = await page.$('.sign-btn')
  if (btn) {
    await page.click('.sign-btn')
  }
  await browser.close()
  console.log('签到结束')
})()

执行脚本:node sign.js

视频演示

仓库地址

github地址
https://github.com/xuedingmiaojun/pmcaffsign.git

本文链接:
版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC-ND 3.0 许可协议。转载请注明出处!

评 论:

本站博客小程序
好文推荐
微信扫码关注
领取学习礼包
技术交流群
每天进步一点点~