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

页面修改

parent ab0fdeae
// See https://aka.ms/new-console-template for more information using System;
using System;
using System.Threading;
using TicketSpider.Spiders.ClassInRule; using TicketSpider.Spiders.ClassInRule;
namespace EduSpider namespace EduSpider
...@@ -10,11 +8,12 @@ namespace EduSpider ...@@ -10,11 +8,12 @@ namespace EduSpider
static void Main(string[] args) static void Main(string[] args)
{ {
//ThreadPool.SetMaxThreads(255, 255); //ClassIn数据
//ThreadPool.SetMinThreads(255, 255); // ClassInFlow.StartAsync();
new ClassInFlow().StartAsync();
//校管家数据
// SchoolTaskHelper.RunTask();
Console.ReadLine(); Console.ReadLine();
Environment.Exit(0); Environment.Exit(0);
......
using EduSpider.Spiders.ClassInRule; using EduSpider.Spiders.ClassInRule;
using Newtonsoft.Json.Linq;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System; 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 namespace TicketSpider.Spiders.ClassInRule
{ {
public class ClassInFlow public class ClassInFlow
{ {
/// <summary>
public void StartAsync() /// 导入ClassIn数据
/// </summary>
public static void StartAsync()
{ {
Console.WriteLine("开始模拟登录信息......."); Console.WriteLine("开始模拟登录信息.......");
string loginCookies; string loginCookies;
......
...@@ -4,6 +4,7 @@ using System.Collections.Generic; ...@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using VTX.FW.Helper; using VTX.FW.Helper;
...@@ -14,43 +15,54 @@ namespace EduSpider.Spiders.SchoolHouseKeeper ...@@ -14,43 +15,54 @@ namespace EduSpider.Spiders.SchoolHouseKeeper
/// </summary> /// </summary>
public class SchoolCourseManager public class SchoolCourseManager
{ {
/// <summary>
/// 分页数据
/// </summary>
public class PageModel public class PageModel
{ {
public int PageIndex { get; set; } public int PageIndex { get; set; }
public int PageSize { get; set; } public int PageSize { get; set; }
} }
/// <summary> /// <summary>
/// 获取课程列表 /// 获取课程列表
/// </summary> /// </summary>
public static async void RunCourse(string cookie) public static void RunCourse(string cookie)
{ {
var pageModel = new PageModel var pageModel = new PageModel
{ {
PageIndex = 1, PageIndex = 1,
PageSize = 10 PageSize = 10
}; };
int totalCount = 0, pageCount = 0; int pageCount;
string url = "https://tms11.xiaogj.com/api/Shift/Query"; string url = "https://tms11.xiaogj.com/api/Shift/Query";
string result = Utility.SchoolHttpHelper.HttpPost(url, VTX.FW.Helper.JsonHelper.Serialize(pageModel), "application/json", cookie); string result = Utility.SchoolHttpHelper.HttpPost(url, VTX.FW.Helper.JsonHelper.Serialize(pageModel), "application/json", cookie);
List<SchoolCourseItem> list = new List<SchoolCourseItem>(); List<SchoolCourseItem> list = new List<SchoolCourseItem>();
if (!string.IsNullOrEmpty(result)) if (!string.IsNullOrEmpty(result))
{ {
JObject jobj = JObject.Parse(result); JObject jobj = JObject.Parse(result);
totalCount = jobj.GetInt("TotalCount");
pageCount = jobj.GetInt("PageCount"); 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) if (pageCount > pageModel.PageIndex)
{ {
Random random = new Random();
for (var i = 2; i <= pageCount; i++) 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