今日校园提交签到和查寝-Java实现

2020年10月29日,今日校园闲得蛋疼,改了接口,文章中部分接口失效,最新接口点击下面源码链接,获取

之前未开学之前,是信息表采集,开学之后,改成了循环签到和查寝,那就想着再写个脚本

站在巨人的肩膀上,所以该代码全部开源,我也借鉴的大佬的东西,放在第三节致谢。有问题可以在下面进行留言讨论!

博客地址

一、自动每日签到

源码

1.1 思路

  1. 抓包(抓包的流程,可以参照我之前的文章
  2. 每日接口获取最新表单
  3. 通过上步的id获取详细表单
  4. 通过上步获取该表单的选项id

如果整体的思路看不明白,可以参照下面的详细步骤

1.1 获取最新表单

接口

/wec-counselor-sign-apps/stu/sign/getStuSignInfosInOneDay

参数

{}

返回值

{
	"code": "0",
	"message": "SUCCESS",
	"datas": {
		"dayInMonth": "2020-09-10",
		"codeRcvdTasks": [],
		"signedTasks": [],
		"unSignedTasks": [{
			"stuSignWid": "746210",
			"signInstanceWid": "4146", //需要
			"signWid": "514213", //需要
			"signRate": "1",
			"taskType": "4",
			"taskName": "一日三签(早签到)",
			"senderUserName": "牛逼学院(牛逼老师)",
			"signStatus": "2",
			"isMalposition": null,
			"isLeave": "0",
			"leavePcUrl": null,
			"leaveMobileUrl": null,
			"currentTime": "2020-09-10 08:15",
			"singleTaskBeginTime": null,
			"singleTaskEndTime": null,
			"rateSignDate": "2020-09-10 (周四)",
			"rateTaskBeginTime": "05:00",
			"rateTaskEndTime": "09:59"
		}, {
			"stuSignWid": "759720",
			"signInstanceWid": "4199",
			"signWid": "514234",
			"signRate": "1",
			"taskType": "4",
			"taskName": "一日三签(午签到)",
			"senderUserName": "牛逼学院(牛逼老师)",
			"signStatus": "2",
			"isMalposition": null,
			"isLeave": "0",
			"leavePcUrl": null,
			"leaveMobileUrl": null,
			"currentTime": "2020-09-10 08:15",
			"singleTaskBeginTime": null,
			"singleTaskEndTime": null,
			"rateSignDate": "2020-09-10 (周四)",
			"rateTaskBeginTime": "10:00",
			"rateTaskEndTime": "15:59"
		}, {
			"stuSignWid": "778325",
			"signInstanceWid": "4266",
			"signWid": "535128",
			"signRate": "1",
			"taskType": "4",
			"taskName": "一日三签(晚签到)",
			"senderUserName": "牛逼学院(牛逼老师)",
			"signStatus": "2",
			"isMalposition": null,
			"isLeave": "0",
			"leavePcUrl": null,
			"leaveMobileUrl": null,
			"currentTime": "2020-09-10 08:15",
			"singleTaskBeginTime": null,
			"singleTaskEndTime": null,
			"rateSignDate": "2020-09-10 (周四)",
			"rateTaskBeginTime": "16:00",
			"rateTaskEndTime": "22:00"
		}],
		"leaveTasks": []
	}
}

其中我们需要获取signWid514213和signInstanceWid4146

1.2 获取详细信息

接口

/wec-counselor-sign-apps/stu/sign/detailSignInstance

参数

{
  "signWid" : 514213,
  "signInstanceWid" : 4146
}

返回值

{
  "message" : "SUCCESS",
  "datas" : {
    "latitude" : "",
    "singleTaskEndTime" : null,
    "catQrUrl" : "https:\/\/cat.cpdaily.com\/erweima",
    "singleTaskBeginTime" : null,
    "signInstanceWid" : "4146",
    "signPhotoUrl" : null,
    "signTime" : null,
    "senderUserName" : "牛逼学院(牛逼老师)",
    "qrCodeRcvdUsers" : [
      {
        "targetWid" : "91457111",
        "targetType" : "4",
        "targetName" : "牛逼老师\/19070302",
        "targetGrade" : "-1",
        "targetDegree" : "-1",
        "targetUserType" : "-1"
      }
    ],
    "isNeedExtra" : 1,
    "signCondition" : 0,
    "currentTime" : "2020-09-10 09:33:08",
    "taskDesc" : "https:\/\/wecres.cpdaily.com\/counselor\/1018615876819107\/content\/54e503639d0244049c3b85baabe509fc.html",
    "signType" : null,
    "changeActorName" : "牛逼老师",
    "isMalposition" : 0,
    "longitude" : "",
    "signedStuInfo" : {
      "cls" : "20200521",
      "major" : "改变世界专业-牛逼",
      "dept" : "牛逼学院",
      "sex" : "男",
      "mobile" : null,
      "nation" : "-",
      "userWid" : "1017790009",
      "userId" : "20200521",
      "userName" : "雷军",
      "malposition" : null,
      "extraFieldItemVos" : [
        {
          "fieldIndex" : 0,
          "extraDesc" : "",
          "extraFieldItemWid" : "",
          "extraTitle" : "体温",
          "extraFieldItem" : null,
          "isExtraFieldOtherItem" : "0",
          "isAbnormal" : "0"
        },
        {
          "fieldIndex" : 0,
          "extraDesc" : "",
          "extraFieldItemWid" : "",
          "extraTitle" : "身体是否异常",
          "extraFieldItem" : null,
          "isExtraFieldOtherItem" : "0",
          "isAbnormal" : "0"
        }
      ],
      "schoolStatus" : null,
      "stuDormitoryVo" : {
        "sex" : "",
        "area" : "",
        "building" : "",
        "unit" : "",
        "room" : ""
      },
      "grade" : "2019级"
    },
    "extraFieldItemVos" : [

    ],
    "changeTime" : null,
    "taskType" : "4",
    "photograph" : [

    ],
    "signRate" : "1",
    "isPhoto" : 0,
    "signAddress" : null,
    "rateTaskEndTime" : "09:59",
    "taskName" : "一日三签(早签到)",
    "leaveAppUrl" : "\/wec-counselor-leave-apps\/leave\/home\/index.html",
    "isAllowUpdate" : false,
    "signMode" : 0,
    "rateTaskBeginTime" : "05:00",
    "signStatus" : "2",
    "signPlaceSelected" : [
      {
        "address" : "只有野鸡学校才用这个流氓app(北界王西区)",
        "radius" : 520,
        "longitude" : "125.398185",
        "placeWid" : null,
        "creatorUserWid" : null,
        "creatorName" : null,
        "wid" : null,
        "latitude" : "44.001709",
        "currentStatus" : null,
        "isShare" : null,
        "creatorUserId" : null
      },
      {
        "address" : "只有野鸡学校才用这个流氓app(北界王东区)",
        "radius" : 500,
        "longitude" : "125.40993457956229",
        "placeWid" : null,
        "creatorUserWid" : null,
        "creatorName" : null,
        "wid" : null,
        "latitude" : "44.00262969203334",
        "currentStatus" : null,
        "isShare" : null,
        "creatorUserId" : null
      },
      {
        "address" : "只有野鸡学校才用这个流氓app(南界王校区)",
        "radius" : 400,
        "longitude" : "125.296568",
        "placeWid" : null,
        "creatorUserWid" : null,
        "creatorName" : null,
        "wid" : null,
        "latitude" : "43.859918",
        "currentStatus" : null,
        "isShare" : null,
        "creatorUserId" : null
      }
    ],
    "rateSignDate" : "2020-09-10 (周四)",
    "extraField" : [
      {
        "hasOtherItems" : 0,
        "title" : "体温",
        "extraFieldItems" : [
          {
            "isSelected" : null,
            "value" : null,
            "content" : "37.3度以下",
            "isOtherItems" : 0,
            "wid" : 499882,//获取
            "isAbnormal" : false
          },
          {
            "isSelected" : null,
            "value" : null,
            "content" : "37.3度及以上",
            "isOtherItems" : 0,
            "wid" : 499883,
            "isAbnormal" : true
          }
        ],
        "description" : "",
        "wid" : 211814
      },
      {
        "hasOtherItems" : 1,
        "title" : "身体是否异常",
        "extraFieldItems" : [
          {
            "isSelected" : null,
            "value" : null,
            "content" : "健康",
            "isOtherItems" : 0,
            "wid" : 499884,//获取
            "isAbnormal" : false
          },
          {
            "isSelected" : null,
            "value" : null,
            "content" : "感冒",
            "isOtherItems" : 0,
            "wid" : 499885,
            "isAbnormal" : false
          },
          {
            "isSelected" : null,
            "value" : null,
            "content" : "发烧",
            "isOtherItems" : 0,
            "wid" : 499886,
            "isAbnormal" : false
          },
          {
            "isSelected" : null,
            "value" : null,
            "content" : "咳嗽",
            "isOtherItems" : 0,
            "wid" : 499887,
            "isAbnormal" : false
          },
          {
            "isSelected" : null,
            "value" : null,
            "content" : "其它",
            "isOtherItems" : 1,
            "wid" : 499888,
            "isAbnormal" : false
          }
        ],
        "description" : "",
        "wid" : 211815
      }
    ],
    "downloadUrl" : "https:\/\/img.cpdaily.com\/ldy\/index.html"
  },
  "code" : "0"
}

获取我需要的两个参数,体温选项499882和身体是否异常选项499884

1.3 模拟提交

最后通过上面步骤获取到的4146,499882,499884以及自定义的地址,进行签到

接口

/wec-counselor-sign-apps/stu/sign/submitSign

参数

{
	"abnormalReason": "",
	"position": "你的地址",
	"longitude": 你的经度,
	"isNeedExtra": 1,
	"latitude": 你的纬度,
	"isMalposition": 0,
	"extraFieldItems": [{
			"extraFieldItemWid": 499882,
			"extraFieldItemValue": "37.3度以下"
		},
		{
			"extraFieldItemWid": 499884,
			"extraFieldItemValue": "健康"
		}
	],
	"signInstanceWid": "4146",
	"signPhotoUrl": ""
}

返回值

{
  "message" : "SUCCESS",
  "datas" : {
    "signedStuInfo" : null,
    "signInstanceWid" : "4146"
  },
  "code" : "0"
}

1.4 运行结果

二、自动每日查寝

源码

2.1 思路

  1. 抓包(抓包的流程,可以参照我之前的文章
  2. 每日接口获取最新表单
  3. 通过上步的id获取详细表单
  4. 通过上步获取该表单的选项id

2.2 接口

获取最新查寝

/wec-counselor-attendance-apps/student/attendance/getStuAttendacesInOneDay

获取详细查寝

/wec-counselor-attendance-apps/student/attendance/detailSignInstance

提交查寝

/wec-counselor-attendance-apps/student/attendance/submitSign

2.3 随机图片

今日校园的图片,是存储到了阿里云。当然,你也可以尝试用代码实现自动往阿里云提交,但是我还是觉得太麻烦,就放弃了。

提交查寝时的参数

{
	"signInstanceWid": "null",
	"longitude": "null",
	"latitude": "null",
	"isMalposition": "null",
	"abnormalReason": "null",
	"signPhotoUrl": "null", //这个地方的图片链接,其实也可以放你自己服务器的图片链接,然后随机即可。
	"position": "null",
	"qrUuid": "null"
}

三、获取今日校园阿里云oss账号

3.1 前言

10月22日,学校换了新的签到,要拍照。

在提交今日校园照片的时候,无意间抓包到一系列数据,然后,看了阿里云oss的文档之后,顿时明白了许多。

终于知道为啥好多人挤破头颅都要去阿里了。

阿里,就是牛逼,就连上传的所有可能用到的比较人性化的功能(比方说上传进度条功能),都给整完了。

就连我这种菜鸡,都能拿来就可以用。

我曾经听过某大佬说,真正的开发者,写的代码,不仅条理清楚,还通俗易懂。这用来形容阿里再合适不过了。

这是不是就是真正的宗师境界呢?

原谅我太过激动,这也更让我坚定了,要努力学习,进大厂的愿望

3.2 正题

今日校园获取阿里云OSS的接口

/wec-counselor-sign-apps/stu/sign/getStsAccess

请求头中携带自己的cookie

获取如下信息,然后用id、secret、token,再结合阿里开源

{
  "code": "0",
  "datas": {
    "accessKeyId": "STS.NV47ZBrGJfjlsj97t7VKWepMJvc",
    "accessKeySecret": "6ZdSLF6T3JPCbQgqd3mTcqzbEh987829gksCaFxsdxdYK",
    "securityToken": "CAIShAN1q6Ft5B2yfSjIr5WBfOD2n5hrgfufR235nFYeW+pcoo/dgTz228gnsibhnhsPw1m2xT6/cTlr0qEsIVGxybMpcutsoGqFP5JtKZ4pQdXmbqNdv3d1KIAjvXgeUFCoeQFaEME5XAQlTAkTAJK9KYERypQ12iN7CQlJdjda55dwKkbD1AdtU0Qwx5s501OGf2P/SgOQKI523LFxhQpxZbg2Fy4rjdusqH8UjygVn31uIyrYb8KYTGCs53J8VbUsyp5OVsarGjoClL8Epj/qBskIlZ/SvGptiHH2RJ5xKPP4iz9cZ0fit4fbQdEaxJp+Tn774a3NbejIPq0R1AEPhIWiDEPuCazdDDBfmiO6ReF9PyMG+f1cuUZNun8VFmQwpCbV4aJYp+dSMuUUJ9E2GCEML9pgCWODXEYrOezaQ73aByy1jV5teQLzCNOe7Ejn5HasRtNx1wbUFKhjGwI7V1eghNYk5hAK2OUYJwYRZRpKXlpwTOUTd6yXVarykzhQceaE91GoABUp6SSSSKU/bJ1rJtD536UCvZcYvsdl9eaDRwkSdFJhLlmd/jC6wpk1NUdqkDbRCs87xwfPZrdfL6AJXRxN0bXIR79q4M9s7tlqes+5iCDaXwsk5/MhIRE+asN6AM9YzOjlu2uftrxyvUsVqMbkBz8QCF+KrdLnSzvTQr1K+LdJQ\u003d",
    "expiration": "2020-10-22T14:53:12Z",
    "endPoint": "oss-cn-hangzhou.aliyuncs.com",
    "bucket": "wecloud-res",
    "fileName": "counselor/101820526o268269/content/2085lksj2jgwjoihggsljh.png"
  },
  "message": "SUCCESS"
}

此处我也遇到了很多问题,比方说有token经常报错不对,那就继续抓包,在上传照片的请求体重,会获得x-oss-security-token

再将token换成x-oss-security-token即可登录今日校园oss,当然,这并不是永久有效的,但是依然有最高权限,比方说删除之类~

注意:

不要乱删除内容哦~

附张成功登录oss之后的图

四、致谢

  1. ZimoLoveShuang
posted @ 2020-09-10 16:58  言成言成啊  阅读(3546)  评论(1编辑  收藏  举报