小程序校园服务是腾讯、支付宝举办小程序大赛重要话题,主要凸显校园生态重要性、同时向学生输送群体推广技术应用。很多同学想做课表查询、成绩查询、校园实名认证,但又拿不到学校官方授权,只能想办法使用模拟登录方式引导用户教务系统认证,然后缓存认证信息,夜间对学校教务系统很多波携带认证信息拿到想要的数据。我将介绍两种正常的教务系统模拟登录获取信息的案例。我以还没有人研究过的乘方科技教务系统为例,其他类似
你可能感兴趣的
1.爬取学校官网信息公告并存入数据库
注:http://xxxxxx.edu.cn/new/login ,xxxxxx代表您的学校对应的域名信息
方式一:使用前端方式对教务系统模拟登录
弊端:有些学校教务系统没有使用https协议,导致上线后无法直接使用js来模拟登录,如果使用了恭喜你能用前端解决的最好不要用后端。
// pages/mine/auth/auth.js
const app = getApp()
const apiUrl = require('../../../config.js').apiUrl
Page({
/**
* 页面的初始数据
*/
data: {
header: {
},
stuInfo:''
},
// 用户协议
goto() {
wx.navigateTo({
url: './agreement/agreement',
})
},
//再次登录
again(){
this.onLoad();
this.setData({
modalName: null
})
},
formSubmit: function(e) {
var info = e.detail.value
console.log('value', e.detail.value);
if (info.account.length == 0 || info.pwd.length == 0 || info.verify.length == 0) {
wx.showToast({
title: '信息输入不完整!',
icon: 'loading',
mask: true,
duration: 1000
})
} else {
var _this = this;
wx.request({
url: 'http://xxxxxx.edu.cn/new/login',
method: 'post',
header: this.data.header,
data: {
account: info.account,
pwd: info.pwd,
verifycode: info.verify,
},
success: function (e) {
console.log(e)
if (e.data.message == "登录成功" || e.data.code == 0) {
wx.request({
url: 'http://xxxxxx.edu.cn//login!welcome.action',
header: _this.data.header,
success: function (e) {
// replaceAll("\\D+", "");
var stu_name = e.data.replace(/<[^>]&