Project code stamp here to use the problem, welcome to leave a message
Project purpose
Recently, due to insufficient work, I only turn on the machine on weekdays (I don’t turn on the machine at weekends), which leads to frequent missed signings. Just before, I used the automatic script deployed by Tencent Cloud, so I tried the automatic sign-in of tunneling gold, and pushed it through wechat with pushPlus, and found it feasible, so I shared it.
What do you need
Github and NodeJS are standard.
- Tencent cloud account, used to publish scripts
- Pushplus accounts, used to receive check-in results, need to use wechat public account to activate messages
Using the step
-
Global global offset (GLOBAL offset) interface request (global offset) interface request (global offset)
-
Open the project, install the dependencies, and configure the contents of config.js.
module.exports = { cookie: ' '.aid: ' '.uuid: ' '._signature: ' '.PUSH_PLUS_TOKEN: ' ' } Copy the code
The title cookie Open the console to find any Juejin Request and find the cookie in the Request Header aid, uuid, _signature For these three requests, you can manually click the check-in button after the browser is offline to see the request PUSH_PLUS_TOKEN Pushplus Specifies the token used by pushPlus. The following describes how to obtain the token -
Wechat search pushPlus and activate the message after following it.
-
Open the pushplus official website on the bottom menu bar of the official account. After entering the official website, the upper right menu displays a one-to-one push, and you can check the push token of PushPlus
-
Open [Tencent Cloud function](function service – Serverless – Console (tencent.com)) to log in
-
To create a cloud function, select
Custom creation
, select the operating environmentNodejs 12.16
Select the local upload folder and upload the project code in its entiretyThe node_modules folder is also uploaded
-
After creating the trigger, configure the project trigger, using the custom trigger cycle
How expression
.How expression
Usage :(Cloud function timing trigger Description – Trigger – Documentation Center – Tencent Cloud (Tencent.com))0, 30, 9 * * * * means that the code is executed once a day at 09:30
Local debugging
Open the project and execute Node app.js
Cloud function debugging
After the cloud function is created, click the function code under function management, and the execution mode does not need to be modified by default. Click Deploy first and then test. At this time, wechat of mobile phone will receive a wechat message.
Project directory structure description
App.js: the main code of the project config.js: some configuration information of the project index.js: the entry of the cloud function, if called locally, do not need to care about this file
Project code
app.js
const got = require('got')
const { cookie, aid, uuid, _signature, PUSH_PLUS_TOKEN } = require('./config')
const BASEURL = 'https://api.juejin.cn/growth_api/v1/check_in' // Nuggets check-in API
const PUSH_URL = 'http://www.pushplus.plus/send' // pushplus push API
const URL = `${BASEURL}? aid=${aid}&uuid=${uuid}&_signature=${_signature}`
const HEADERS = {
cookie,
'user-agent': 'the Mozilla / 5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/ 537.36EDG /92.0.902.67'
}
/ / sign in
async function signIn () {
const res = await got.post(URL, {
hooks: {
beforeRequest: [
options= > {
Object.assign(options.headers, HEADERS)
}
]
}
})
console.log(res.body)
handlePush(res.body)
}
// push
async function handlePush (desp) {
const body = {
token: `${PUSH_PLUS_TOKEN}`.title: 'Check-in result'.content: `${desp}`
};
const res = await got.post(PUSH_URL, {
json: body
})
console.log(res.body)
}
signIn()
Copy the code
config.js
module.exports = {
cookie: ' '.PUSH_PLUS_TOKEN: ' '.aid: ' '.uuid: ' '._signature: ' '
}
Copy the code
index.js
'use strict';
exports.main_handler = async (event, context, callback) => {
require('./app.js')}Copy the code