Commit 03f477cd authored by 黄奎's avatar 黄奎

页面修改

parent ab0fdeae
// See https://aka.ms/new-console-template for more information
using System;
using System.Threading;
using System;
using TicketSpider.Spiders.ClassInRule;
namespace EduSpider
......@@ -10,11 +8,12 @@ namespace EduSpider
static void Main(string[] args)
{
//ThreadPool.SetMaxThreads(255, 255);
//ThreadPool.SetMinThreads(255, 255);
new ClassInFlow().StartAsync();
//ClassIn数据
// ClassInFlow.StartAsync();
//校管家数据
// SchoolTaskHelper.RunTask();
Console.ReadLine();
Environment.Exit(0);
......
using EduSpider.Spiders.ClassInRule;
using Newtonsoft.Json.Linq;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace TicketSpider.Spiders.ClassInRule
{
public class ClassInFlow
{
public void StartAsync()
/// <summary>
/// 导入ClassIn数据
/// </summary>
public static void StartAsync()
{
Console.WriteLine("开始模拟登录信息.......");
string loginCookies;
......
......@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using VTX.FW.Helper;
......@@ -14,43 +15,54 @@ namespace EduSpider.Spiders.SchoolHouseKeeper
/// </summary>
public class SchoolCourseManager
{
/// <summary>
/// 分页数据
/// </summary>
public class PageModel
{
public int PageIndex { get; set; }
public int PageSize { get; set; }
}
/// <summary>
/// 获取课程列表
/// </summary>
public static async void RunCourse(string cookie)
public static void RunCourse(string cookie)
{
var pageModel = new PageModel
{
PageIndex = 1,
PageSize = 10
};
int totalCount = 0, pageCount = 0;
int pageCount;
string url = "https://tms11.xiaogj.com/api/Shift/Query";
string result = Utility.SchoolHttpHelper.HttpPost(url, VTX.FW.Helper.JsonHelper.Serialize(pageModel), "application/json", cookie);
List<SchoolCourseItem> list = new List<SchoolCourseItem>();
if (!string.IsNullOrEmpty(result))
{
JObject jobj = JObject.Parse(result);
totalCount = jobj.GetInt("TotalCount");
pageCount = jobj.GetInt("PageCount");
list = ParseJson(jobj.GetString("Data"));
list.AddRange(ParseJson(jobj.GetString("Data")));
Console.WriteLine(string.Format("已完成 页{0}/{1},数据 {2}/{3}", pageModel.PageIndex, pageCount, pageModel.PageSize * pageModel.PageIndex, list.Count));
if (pageCount > pageModel.PageIndex)
{
Random random = new Random();
for (var i = 2; i <= pageCount; i++)
{
{
var num = random.Next(1, 10);
Thread.Sleep(1000 * num);
pageModel.PageIndex = i;
string subResult = Utility.SchoolHttpHelper.HttpPost(url, VTX.FW.Helper.JsonHelper.Serialize(pageModel), "application/json", cookie);
if (!string.IsNullOrEmpty(subResult))
{
JObject subObj = JObject.Parse(subResult);
list.AddRange(ParseJson(subObj.GetString("Data")));
}
Console.WriteLine(string.Format("已完成 页{0}/{1},数据 {2}/{3}", pageModel.PageIndex, pageCount, pageModel.PageSize * pageModel.PageIndex, list.Count));
}
}
}
Console.WriteLine("result:" + result);
Console.WriteLine("result:" + VTX.FW.Helper.JsonHelper.Serialize(list));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment