青年大学习自动完成

前言

​ 发送get请求,实现完成青年大学习(后台记录学习记录)

步骤

  • 创建一个Github Action,将代码复制到工作流
  • Get clone 本地,修改信息后pull到仓库
  • 代码中的信息,手机本地抓包青年大学习即可

命令

var url="http://dxx.****.com/v1/user/commit";/打卡请求所对应url
var stage_id="22";//打卡期数
var org=[*,2***,2***,2**2];//所对应的组织
var last_org=2**2;//对应的组织的最后一项
var org_name="****团支部";//团支部名称

let msg
const checkpass = async request => {
  
  const { name,number } = await request.json()
  console.log(name,number)
  const headers = { 'Content-Type': 'application/json' }
  const { number } = await request.json()
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({"stage_id":stage_id,"name":name,"tel":number,"org":org,"last_org":last_org,"org_name":org_name});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

const result = await fetch(url, requestOptions)
  .then(function(response) {
    console.log(response)
    console.log("ok")
    return response.json();
  })
  .then(function(myJson) {
    msg = myJson;
    
  })
  .catch(error => console.log('error', error));
console.log(msg)
  return new Response(JSON.stringify(msg), { headers })
}
async function handleRequest(request) {
  let response
  if (request.method === 'POST') {
    response = await checkpass(request)
  } else {
    response = new Response(“Error,Github@iflynews”, { headers: { 'Content-Type': 'text/html' } })
  }
  return response
}

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

定时任务

添加 schedule 语句可以实现每周自动执行命令

on:
  schedule:
    # * is a special character in YAML so you have to quote this string
    - cron:  '30 12 * * MON'
    # 每周一 12:30执行

cron examples

posted @   LiamYe  阅读(480)  评论(1编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示