本帖最后由 蜗牛杰 于 2023-10-28 11:32 编辑
北京继教国培教育研究院简介 北京继教国培教育研究院创办于2014年,主要致力于中国教育事业的发展与研究,围绕国家教育培训计划开展教育研究、教师培训、教研服务、教育咨询、论坛承办等服务,以开阔的视野,前瞻的思维,与国内多所知名师范院校建立战略合作关系,积极引进优质教育资源,汲取先进培训理念,建成研修融合,研训一体的线上与线下相结合的“多层次、多维度、全方位、立体式”网络研修平台。
目前有视频网课,但是无法用加速器,目前我研究了天津这边的学习方法,其他地区的不清楚,如有其他地区的请留意我会看
现在讲如何快速学习:
首先登陆网站首页,打开浏览器控制台F12,查看网络请求 查看getUser接口,拿到请求头数据 再看响应数据,拿到id import com.alibaba.fastjson2.JSONObject import kotlinx.coroutines.* import org.springframework.http.HttpHeaders import org.springframework.http.HttpMethod import org.springframework.http.RequestEntity import org.springframework.http.ResponseEntity import org.springframework.web.client.RestTemplate import java.net.URI
class ActivityData { var activityIds: List<LinkedHashMap<String, Any>>? = null var videoIds: List<Int>? = null var videoWatchTimes: List<Int>? = null }
fun main() { val activityData = ActivityData()
runBlocking { while (true) { // 如果数据为空,或者需要刷新,调用接口获取数据 if (activityData.activityIds == null || needRefreshData()) { activityData.activityIds = getActivityId() activityData.videoIds = getVideoId() activityData.videoWatchTimes = getVideoWatchTime() }
// 创建协程列表,用于存储所有请求的 Deferred 对象 val requests = mutableListOf<Deferred<Unit>>()
// 使用协程启动多个异步请求 activityData.activityIds?.forEachIndexed { index, activity -> val videoId = activityData.videoIds?.get(index) val videoWatchTime = activityData.videoWatchTimes?.get(index)
if (videoId != null && videoWatchTime != null) { val requestDeferred = async { sendPostRequest(activity["id"] as Int, videoId, videoWatchTime) } requests.add(requestDeferred) } }
// 等待所有请求完成 requests.awaitAll()
// 暂停10秒钟 delay(10000) } } }
fun needRefreshData(): Boolean { return false } suspend fun sendPostRequest(activityId: Int, videoId: Int, videoWatchTime: Int) { val url = "http://api.jijiaoguopei.com/api/spActivity/changeActivityStatusNew" val headers = HttpHeaders() // 设置请求头信息 headers.add("Accept", "application/json, text/plain, */*") headers.add("Accept-Encoding", "gzip, deflate") headers.add("Accept-Language", "zh-CN,zh;q=0.9") headers.add( "Authorization",“换成你的” ) headers.add("Content-Type", "application/json;charset=UTF-8") headers.add("Content-Length", "79") headers.add("Host", "api.jijiaoguopei.com") headers.add("Origin", "http://jijiaoguopei.com") headers.add("Proxy-Connection", "keep-alive") headers.add("Referer", "http://jijiaoguopei.com/") headers.add( "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" ) // 构建请求体 val requestBody = """ { "activityId": $activityId, "videoCompleteFlag": 0, "videoId": $videoId, "videoWatchTime": $videoWatchTime } """.trimIndent()
// 发送POST请求 val restTemplate = RestTemplate() val requestEntity: RequestEntity<String> = RequestEntity.post(URI.create(url)) .headers(headers) .body(requestBody)
val responseEntity: ResponseEntity<String> = withContext(Dispatchers.IO) { restTemplate.exchange(requestEntity, String::class.java) }
// 处理响应,你可以根据需要进行处理 println("Response: ${responseEntity.body}") }
fun sendGetRequest(): JSONObject? { val url = "http://api.jijiaoguopei.com/api/spActivity/getActivityByTeacherId?id=“你拿到的ID”&page=1&limit=30&specialTopicId=252&activityClassifyId=299&courseTypeId=&compulsoryFlag=1&code="
val requestEntity: RequestEntity<String> = requestEntity(url) val restTemplate = RestTemplate() val responseEntity: ResponseEntity<JSONObject> = restTemplate.exchange(requestEntity, JSONObject::class.java) return responseEntity.body }
private fun requestEntity(url: String): RequestEntity<String> { val headers = HttpHeaders() headers.add("Accept", "application/json, text/plain, */*") headers.add("Accept-Encoding", "gzip, deflate") headers.add("Accept-Language", "zh-CN,zh;q=0.9") headers.add( "Authorization", ) headers.add("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8") headers.add("Host", "api.jijiaoguopei.com") headers.add("Origin", "http://jijiaoguopei.com") headers.add("Proxy-Connection", "keep-alive") headers.add("Referer", "http://jijiaoguopei.com/") headers.add( "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" ) val requestEntity: RequestEntity<String> = RequestEntity( headers, HttpMethod.GET, URI.create(url) ) return requestEntity }
fun getVideoId(): ArrayList<Int> { val videoIds = ArrayList<Int>() getActivityId().forEach { it -> val activityId = it["id"] as Int val url = "http://api.jijiaoguopei.com/api/spActivity/getById?id=$activityId&teacherId=你拿到的ID" val requestEntity: RequestEntity<String> = requestEntity(url) val restTemplate = RestTemplate() val responseEntity: ResponseEntity<JSONObject> = restTemplate.exchange(requestEntity, JSONObject::class.java) val video = ((responseEntity.body?.get("data")) as LinkedHashMap<*, *>)["courseChapters"] as ArrayList<*>
if (video.size > 0) { video.forEach { it as LinkedHashMap<*, *> val videoId = it["video"] as ArrayList<LinkedHashMap<*, *>> videoId.forEach { ids -> val idd = ids["id"] as Int videoIds.add(idd) } } }
} return videoIds }
fun getVideoWatchTime(): ArrayList<Int> { val videoWatchTimes = ArrayList<Int>() getActivityId().forEach { val activityId = it["id"] as Int val url = "http://api.jijiaoguopei.com/api/spActivity/getTaskNode?teacherId=你的ID&activityId=$activityId" val requestEntity: RequestEntity<String> = requestEntity(url) val restTemplate = RestTemplate() val responseEntity: ResponseEntity<JSONObject> = restTemplate.exchange(requestEntity, JSONObject::class.java) val data = responseEntity.body?.get("data") as LinkedHashMap<*, *> val videoWatchTime = data["videoWatchTime"] as Int videoWatchTimes.add(videoWatchTime) } return videoWatchTimes }
private fun getActivityId(): List<LinkedHashMap<String, Any>> { val json = sendGetRequest() val data = json?.get("data") as LinkedHashMap<*, *> val list = data["activityInfo"] as ArrayList<LinkedHashMap<String, Any>> // 使用filter函数过滤列表 val filteredList = list.filter { // 获取LinkedHashMap中的allCompleteFlag字段,并检查其值是否为0 val allCompleteFlag = it["allCompleteFlag"] as? Int allCompleteFlag == 0 } return filteredList }
接下来在IDEA中运行kotlin代码,修改id为你拿到的ID,请求头换成你拿到的请求头
注:若转载请注明大神论坛来源(本贴地址)与作者信息。
|