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 (opens new window)

本文链接:
版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC-ND 3.0 许可协议。可自由转载、引用,但需署名作者且注明文章出处。如转载至微信公众号,请在文末添加作者公众号二维码。

扫描下方二维码阅读当前文章

浏览器、微信扫码

评 论:

好文推荐
每天进步一点点~