Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
EduSpider
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
viitto
EduSpider
Commits
03f477cd
Commit
03f477cd
authored
Jun 02, 2022
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
ab0fdeae
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
27 deletions
+31
-27
Program.cs
EduSpider/Program.cs
+6
-7
ClassInFlow.cs
EduSpider/Spiders/ClassInRule/ClassInFlow.cs
+4
-11
SchoolCourseManager.cs
EduSpider/Spiders/SchoolHouseKeeper/SchoolCourseManager.cs
+21
-9
No files found.
EduSpider/Program.cs
View file @
03f477cd
// 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
);
...
...
EduSpider/Spiders/ClassInRule/ClassInFlow.cs
View file @
03f477cd
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
;
...
...
EduSpider/Spiders/SchoolHouseKeeper/SchoolCourseManager.cs
View file @
03f477cd
...
...
@@ -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
)
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment