Exemplo n.º 1
0
        // 取课程表
        // time: 四位数年份 + 01上学期/02下学期
        // eg: 2017学年下学期 201702
        public async Task <JWList> GetTimeTableAsync(string time)
        {
            var weekOneMonday = await GetWeekOneMondayAsync(time);

            var    webRequest = GetWebRequest($"{JWURL}/xsgrkbcx!xsAllKbList.action?xnxqdm={time}", "GET");
            string html;

            using (var response = await webRequest.GetResponseAsync())
            {
                var reader = new StreamReader(response.GetResponseStream());
                html = await reader.ReadToEndAsync();
            }

            var regex = new Regex(@"var kbxx = (\[.*?\]);");

            if (!regex.IsMatch(html))
            {
                return(null);
            }

            var json     = regex.Match(html).Groups[1].Value;
            var lectures = JWJsonParser.FromLectureJson(json, weekOneMonday);

            return(lectures);
        }
Exemplo n.º 2
0
        public async Task <JWList> GetExamTimeTableAsync(string time)
        {
            var    webRequest = GetWebRequest($"{JWURL}/xsksap!getDataList.action", "POST");
            string json;

            using (var requestStream = await webRequest.GetRequestStreamAsync())
            {
                var writer = new StreamWriter(requestStream);
                await writer.WriteAsync($"xnxqdm={time}");

                writer.Close();
            }

            using (var response = await webRequest.GetResponseAsync())
            {
                var reader = new StreamReader(response.GetResponseStream());
                json = await reader.ReadToEndAsync();
            }

            var exams = JWJsonParser.FromExamJson(json);

            return(exams);
        }