当前位置:网站首页>Cloud function to achieve automatic website check-in configuration details [Web function/Nodejs/cookie]
Cloud function to achieve automatic website check-in configuration details [Web function/Nodejs/cookie]
2022-08-04 09:02:00 【Aspirant dishes pig】
文章目录
一.前言
现在大多数的网站都有每日签到功能,坚持签到会给相应的奖励,然而我们每天都签到是非常的不容易,难免会出现忘记签到的情况,所以云函数就产生了.
像现在大厂给个人用户提供的免费额度已经足够我们使用了.
我们以某网站为例,配置过程如下.
二.配置脚本过程
2.1获取某网站的cookie
我们需要先获取某网站的cookie,推荐使用谷歌游览器.我们打开该网站,保证现在处于登录状态.我们随机的发起一个请求,抓包如下:
我们抓到了现在的cookie先复制下来备用.
2.2获取uuid、aid和_signature
我们访问该网站的签到页面,筛选:check
查看详细,点击payload,显示uuid、aid和_signature,如下备用.
复制好上面的uuid、aid和_signature和cookie之后,下面就是我们的脚本函数.
2.3 脚本函数
我们写一个如下的脚本函数:
执行文件为app.js.
配置文件在config.js.
我们进入config.js,修改一下参数配置;
module.exports = {
cookie: '',
PUSH_PLUS_TOKEN: '',
aid: '',
uuid: '',
_signature: ''
}
2.4 注册plus
wx登录plus会获取到token,复制token.
这里的token对应着我们上文的的PUSH_PLUS_TOKEN.
2.5 配置config.js
如上,我们把上面步骤获取到的uuid、aid和_signature和cookie,放到config.js配置函数里.
如下:

三.部署脚本过程
创建云函数
版本选择:Nodejs12.16
选择事件函数
如下配置:
进入函数管理,部署事件函数:
配置触发器:每天早上9点自动签到.
点击测试,运行函数,检测部署是否有效.
测试截图:

测试成功,之后全自动的会每天9点准时签到领取奖励.nice
四,脚本代码分享
主要脚本代码,api已去掉.
const got = require('got')
const {
cookie, aid, uuid, _signature, PUSH_PLUS_TOKEN } = require('./config')
const BASEURL = 'https:XXXX'
const PUSH_URL = 'http:XXXXX' // 推送api
const URL = `${
BASEURL}?aid=${
aid}&uuid=${
uuid}&_signature=${
_signature}`
const DRAW_URL = `https:xxxxx`
const HEADERS = {
cookie,
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36 Edg/92.0.902.67'
}
// 签到
async function signIn () {
const res = await got.post(URL, {
hooks: {
beforeRequest: [
options => {
Object.assign(options.headers, HEADERS)
}
]
}
})
console.log(res.body)
draw()
if (!PUSH_PLUS_TOKEN) return
handlePush(res.body)
}
async function draw () {
const res = await got.post(DRAW_URL, {
hooks: {
beforeRequest: [
options => {
Object.assign(options.headers, HEADERS)
}
]
}
})
console.log(res.body)
}
// push
async function handlePush (desp) {
const body = {
token: `${
PUSH_PLUS_TOKEN}`,
title: `签到结果`,
content: `${
desp}`
};
const res = await got.post(PUSH_URL, {
json: body
})
console.log(res.body)
}
signIn()
边栏推荐
猜你喜欢

从底层看 Redis 的五种数据类型

2022年化工自动化控制仪表考试模拟100题及模拟考试

C Language Lectures from Scratch Part 6: Structure

Implementation of redis distributed lock

ShuffleNet v2网络结构复现(Pytorch版)

How many assertion methods are commonly used in JMeter?

注意力机制

TCP的四次挥手

VRRP + MSTP configuration, huawei eNSP experiment 】 【

【正点原子STM32连载】第一章 本书学习方法 摘自【正点原子】MiniPro STM32H750 开发指南_V1.1
随机推荐
sql在字段重复时 对某个字段根据最新时间取数
recursive thinking
从零开始的tensorflow小白使用指北
三层交换机/路由器OSPF配置详解【华为eNSP实验】
思想茶叶蛋 (Jul 31,2022)| 元宇宙(Metaverse)下了一枚什么样的蛋
发现WRH几个表被锁了,怎么办?
2022-08-02 Analyze RK817 output 32k clock PMIC_32KOUT_WIFI to WiFi module clock register devm_clk_hw_register
The difference between character stream and byte stream
Layer 3 Switch/Router OSPF Configuration Details [Huawei eNSP Experiment]
ISO14443A读卡流程(作为示例参考)
2022-08-02 分析RK817 输出32k clock PMIC_32KOUT_WIFI给WiFi模块 clock 注册devm_clk_hw_register
JMeter 常用的几种断言方法,你会几种呢?
[Cloud Residency Co-Creation] HCSD Celebrity Live Streaming – Employment Guide
微信消息从发送到接收,经历了什么?如何防止丢包
MATLAB/Simulink快捷键
C# DirectoryInfo类
一道[CSCCTF 2019 Qual]FlaskLight的详解再遇SSTI
【Attention】Dual Attention(DANet) & Fully Attention(FLA)
tcp连接的细节
四大网络攻击常见手段及防护