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.

  1. Log in to your gold digger account on the web;
  2. Open the check-in page (if not, click to sign in);
  3. Open the console and switch tonetworkTAB, find/check_in_rulesThis interface then puts the following string (toaid=Start) Copy and save.
  4. And then concatenate the string you just saved tohttps://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.

  1. Again, we open the console;
  2. Switch to theapplicationUnder the TAB, findCookieOptions, clickhttps://juejin.cn;
  3. findsessionidName, 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.