The technology stack we use here is Node.js. Less than 50 lines of code, paste the code first.
const Koa = require('koa');
const schedule = require('node-schedule');
const _request = require('request');
const app = new Koa();
/ / custom
const sessionid = ' '; // SessionID
const url = ' '; // Url
const options = {
url: url,
method:'post'.headers: {
'cookie': 'sessionid='+ sessionid,
},
}
/ / Koa
function request(url, options) {
return new Promise(function (resolve, reject) {
_request(url, options, function (error, response, body) { error && reject(error); resolve(response, body); })})}// Output information
async function start (ctx, next) {
const res = await request(options);
console.log(res.body)
}
const rule = '30 10 0 * * *'; // Trigger every day at 10:30am '
// Scheduled task
const scheduleCronstyle = () = >{
schedule.scheduleJob(rule,() = >{
start();
});
}
app.listen(3000.() = >{
console.log('Service started successfully! ');
scheduleCronstyle(); // Timed start
// start(); // Start immediately
})
Copy the code
This code can achieve a gold mining automatic check-in function, no longer need to manually click to check in!
The custom
Now, I teach you how to operate, first look at the source code in this code.
/ / custom
const sessionid = ' '; // SessionID
const url = ' '; // Url
Copy the code
You need to change these two lines of code, technically, you only need to change one line. Why is that? Listen to me.
First, let’s look at where we get the URL variable from.
- Log in to your gold digger account on the web;
- Open the check-in page (if not, click to sign in);
- Open the console and switch tonetworkTAB, find
/check_in_rules
This interface then puts the following string (toaid=
Start) Copy and save. - And then concatenate the string you just saved to
https://api.juejin.cn/growth_api/v1/check_in?
behind
Example: https://api.juejin.cn/growth_api/v1/check_in?aid=?&uuid=?&_signature=?
In the future, you don’t have to do this all the time, just once.
And then, let’s take a look at where the sessionID variable comes from.
- Again, we open the console;
- Switch to theapplicationUnder the TAB, findCookieOptions, click
https://juejin.cn
; - find
sessionid
Name, copy the corresponding value.
Because cookies have a time limit, but usually a few months or so, that’s enough. It’s expired, just replace it.
conclusion
If you have a cloud server, you can use PM2 to run Persistent Node applications.