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
94d5dbd2
Commit
94d5dbd2
authored
Sep 21, 2022
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
47041ac9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
599 additions
and
522 deletions
+599
-522
ClassInFlow.cs
EduSpider/Spiders/ClassInRule/ClassInFlow.cs
+0
-2
CourseManager.cs
EduSpider/Spiders/ClassInRule/CourseManager.cs
+229
-189
HomeWorkManager.cs
EduSpider/Spiders/ClassInRule/HomeWorkManager.cs
+126
-106
QuestionManager.cs
EduSpider/Spiders/ClassInRule/QuestionManager.cs
+152
-131
StudentManager.cs
EduSpider/Spiders/ClassInRule/StudentManager.cs
+64
-59
TeacherManager.cs
EduSpider/Spiders/ClassInRule/TeacherManager.cs
+28
-22
ICookiesManager.cs
EduSpider/Spiders/ICookiesManager.cs
+0
-13
No files found.
EduSpider/Spiders/ClassInRule/ClassInFlow.cs
View file @
94d5dbd2
using
EduSpider.Spiders.ClassInRule
;
using
EduSpider.Spiders.ClassInRule
;
using
EduSpider.Utility.Plugin
;
using
EduSpider.Utility.Plugin
;
using
System
;
using
System.Threading
;
namespace
TicketSpider.Spiders.ClassInRule
namespace
TicketSpider.Spiders.ClassInRule
{
{
...
...
EduSpider/Spiders/ClassInRule/CourseManager.cs
View file @
94d5dbd2
This diff is collapsed.
Click to expand it.
EduSpider/Spiders/ClassInRule/HomeWorkManager.cs
View file @
94d5dbd2
This diff is collapsed.
Click to expand it.
EduSpider/Spiders/ClassInRule/QuestionManager.cs
View file @
94d5dbd2
This diff is collapsed.
Click to expand it.
EduSpider/Spiders/ClassInRule/StudentManager.cs
View file @
94d5dbd2
...
@@ -18,10 +18,14 @@ namespace EduSpider.Spiders.ClassInRule
...
@@ -18,10 +18,14 @@ namespace EduSpider.Spiders.ClassInRule
private
static
readonly
IStudentRepository
courseRepository
=
new
StudentRepository
();
private
static
readonly
IStudentRepository
courseRepository
=
new
StudentRepository
();
/// <summary>
/// 获取学生数据
/// </summary>
/// <param name="cookie"></param>
public
static
async
void
RunAsync
(
string
cookie
)
public
static
async
void
RunAsync
(
string
cookie
)
{
{
var
request
=
Utility
.
HttpHelper
.
GenerateHttp
(
cookie
);
var
request
=
Utility
.
HttpHelper
.
GenerateHttp
(
cookie
);
int
pageIndex
=
1
,
pageCount
=
1
,
pageSize
=
500
;
int
pageIndex
=
1
,
pageCount
=
1
,
pageSize
=
500
;
#
region
获取最大学生
ID
#
region
获取最大学生
ID
//更新账户
//更新账户
...
@@ -31,78 +35,81 @@ namespace EduSpider.Spiders.ClassInRule
...
@@ -31,78 +35,81 @@ namespace EduSpider.Spiders.ClassInRule
List
<
rb_account_hk
>
accountList
=
new
();
List
<
rb_account_hk
>
accountList
=
new
();
#
endregion
#
endregion
while
(
pageIndex
<=
pageCount
)
while
(
pageIndex
<=
pageCount
)
{
{
InfoHelper
.
WriteLine
(
$"正在查询第
{
pageIndex
}
-
{
pageSize
}
页学员信息"
);
InfoHelper
.
WriteLine
(
$"正在查询第
{
pageIndex
}
-
{
pageSize
}
页学员信息"
);
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"RunAsync"
,
$"正在查询第
{
pageIndex
}
-
{
pageSize
}
页学员信息"
);
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"RunAsync"
,
$"正在查询第
{
pageIndex
}
-
{
pageSize
}
页学员信息"
);
var
paramStr
=
$"page=
{
pageIndex
}
&perpage=
{
pageSize
}
&isdel=0"
;
var
paramStr
=
$"page=
{
pageIndex
}
&perpage=
{
pageSize
}
&isdel=0"
;
var
content
=
new
StringContent
(
paramStr
,
System
.
Text
.
Encoding
.
UTF8
,
"application/x-www-form-urlencoded"
);
var
content
=
new
StringContent
(
paramStr
,
System
.
Text
.
Encoding
.
UTF8
,
"application/x-www-form-urlencoded"
);
var
response
=
await
request
.
PostAsync
(
"https://console.eeo.cn/saasajax/student.ajax.php?action=getSchoolStudentListByPage"
,
content
);
try
var
resultStr
=
response
.
Content
.
ReadAsStringAsync
().
Result
??
string
.
Empty
;
var
result
=
resultStr
.
TryToJObject
();
if
(
result
.
flag
)
{
{
var
data
=
(
result
.
val
.
ContainsKey
(
"data"
)
?
result
.
val
[
"data"
]
:
new
JObject
())
as
JObject
;
var
response
=
await
request
.
PostAsync
(
"https://console.eeo.cn/saasajax/student.ajax.php?action=getSchoolStudentListByPage"
,
content
);
if
(
data
.
ContainsKey
(
"totalStudentNum"
))
{
var
resultStr
=
response
.
Content
.
ReadAsStringAsync
().
Result
??
string
.
Empty
;
var
result
=
resultStr
.
TryToJObject
();
#
region
更新
PageCount
if
(
result
.
flag
)
{
if
(
pageIndex
==
1
)
var
data
=
(
result
.
val
.
ContainsKey
(
"data"
)
?
result
.
val
[
"data"
]
:
new
JObject
())
as
JObject
;
if
(
data
.
ContainsKey
(
"totalStudentNum"
))
{
{
pageCount
=
(
int
)
Math
.
Ceiling
(
data
.
GetDecimal
(
"totalStudentNum"
)
/
pageSize
);
#
region
更新
PageCount
}
if
(
pageIndex
==
1
)
#
endregion
#
region
组装实体
var
stus
=
new
List
<
rb_student_hk
>();
var
stuArray
=
(
data
[
"studentList"
]
as
JArray
);
foreach
(
JObject
x
in
stuArray
)
{
stus
.
Add
(
new
rb_student_hk
()
{
{
AddTime
=
ConvertHelper
.
UnixToDateTime
(
x
.
GetString
(
"addTime"
)),
pageCount
=
(
int
)
Math
.
Ceiling
(
data
.
GetDecimal
(
"totalStudentNum"
)
/
pageSize
);
StudentAccount
=
x
.
GetString
(
"studentAccount"
),
}
Isdel
=
x
.
GetInt
(
"isdel"
,
0
),
#
endregion
IsGroup
=
x
.
GetInt
(
"isGroup"
,
0
),
StudId
=
x
.
GetInt
(
"studId"
,
0
),
Progress
=
x
.
GetString
(
"progress"
),
PublicResourceStatus
=
x
.
GetInt
(
"publicResourceStatus"
,
0
),
ServeState
=
x
.
GetInt
(
"serveState"
,
0
),
StudentName
=
x
.
GetString
(
"studentName"
),
StudentUid
=
x
.
GetInt
(
"studentUid"
,
0
),
Stuno
=
x
.
GetString
(
"stuno"
),
});
}
courseRepository
.
BatchSetStudent
(
stus
);
InfoHelper
.
WriteLine
(
$"已导入第
{
pageIndex
}
-
{
pageSize
}
页学员信息"
);
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"RunAsync"
,
$"已导入第
{
pageIndex
}
-
{
pageSize
}
页学员信息"
);
#
endregion
#
region
写入账号
#
region
组装实体
if
(
stus
.
Any
(
x
=>
x
.
StudId
>
MaxStuId
))
{
var
stus
=
new
List
<
rb_student_hk
>();
foreach
(
var
item
in
stus
.
Where
(
x
=>
x
.
StudId
>
MaxStuId
))
var
stuArray
=
(
data
[
"studentList"
]
as
JArray
);
foreach
(
JObject
x
in
stuArray
)
{
{
accountList
.
Add
(
new
rb_accou
nt_hk
()
stus
.
Add
(
new
rb_stude
nt_hk
()
{
{
UniqueId
=
0
,
AddTime
=
ConvertHelper
.
UnixToDateTime
(
x
.
GetString
(
"addTime"
)),
Id
=
item
.
StudId
,
StudentAccount
=
x
.
GetString
(
"studentAccount"
),
Account
=
item
.
StudentAccount
,
Isdel
=
x
.
GetInt
(
"isdel"
,
0
),
AccountId
=
item
.
StudentUid
,
IsGroup
=
x
.
GetInt
(
"isGroup"
,
0
),
AccountType
=
Utility
.
Enum
.
AccountTypeEnum
.
Student
,
StudId
=
x
.
GetInt
(
"studId"
,
0
),
OpenId
=
""
,
Progress
=
x
.
GetString
(
"progress"
),
Password
=
DESHepler
.
Encrypt
(
item
.
StudentAccount
[^
6.
.]),
PublicResourceStatus
=
x
.
GetInt
(
"publicResourceStatus"
,
0
),
Status
=
0
,
ServeState
=
x
.
GetInt
(
"serveState"
,
0
),
UnionId
=
""
StudentName
=
x
.
GetString
(
"studentName"
),
StudentUid
=
x
.
GetInt
(
"studentUid"
,
0
),
Stuno
=
x
.
GetString
(
"stuno"
),
});
});
}
}
courseRepository
.
BatchSetStudent
(
stus
);
InfoHelper
.
WriteLine
(
$"已导入第
{
pageIndex
}
-
{
pageSize
}
页学员信息"
);
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"RunAsync"
,
$"已导入第
{
pageIndex
}
-
{
pageSize
}
页学员信息"
);
#
endregion
#
region
写入账号
if
(
stus
.
Any
(
x
=>
x
.
StudId
>
MaxStuId
))
{
foreach
(
var
item
in
stus
.
Where
(
x
=>
x
.
StudId
>
MaxStuId
))
{
accountList
.
Add
(
new
rb_account_hk
()
{
UniqueId
=
0
,
Id
=
item
.
StudId
,
Account
=
item
.
StudentAccount
,
AccountId
=
item
.
StudentUid
,
AccountType
=
Utility
.
Enum
.
AccountTypeEnum
.
Student
,
OpenId
=
""
,
Password
=
DESHepler
.
Encrypt
(
item
.
StudentAccount
[^
6.
.]),
Status
=
0
,
UnionId
=
""
});
}
}
#
endregion
}
}
#
endregion
}
}
}
}
catch
(
Exception
ex
)
{
VTX
.
FW
.
Helper
.
LogHelper
.
WriteError
(
"StudentManager_RunAsync"
,
ex
:
ex
);
}
pageIndex
++;
pageIndex
++;
}
}
...
@@ -115,8 +122,6 @@ namespace EduSpider.Spiders.ClassInRule
...
@@ -115,8 +122,6 @@ namespace EduSpider.Spiders.ClassInRule
InfoHelper
.
WriteLine
(
"学员同步完成"
);
InfoHelper
.
WriteLine
(
"学员同步完成"
);
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"RunAsync"
,
$"学员同步完成"
);
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"RunAsync"
,
$"学员同步完成"
);
}
}
}
}
}
}
EduSpider/Spiders/ClassInRule/TeacherManager.cs
View file @
94d5dbd2
...
@@ -29,39 +29,45 @@ namespace EduSpider.Spiders.ClassInRule
...
@@ -29,39 +29,45 @@ namespace EduSpider.Spiders.ClassInRule
{
{
string
paramStr
=
string
.
Format
(
"page={0}&perpage={1}"
,
pageIndex
,
perpage
);
string
paramStr
=
string
.
Format
(
"page={0}&perpage={1}"
,
pageIndex
,
perpage
);
var
content
=
new
StringContent
(
paramStr
,
System
.
Text
.
Encoding
.
UTF8
,
"application/x-www-form-urlencoded"
);
var
content
=
new
StringContent
(
paramStr
,
System
.
Text
.
Encoding
.
UTF8
,
"application/x-www-form-urlencoded"
);
var
response
=
await
request
.
PostAsync
(
"https://console.eeo.cn/saasajax/teacher.ajax.php?action=getSchoolTeacherFullList"
,
content
);
try
var
result
=
response
.
Content
.
ReadAsStringAsync
().
Result
;
if
(!
string
.
IsNullOrWhiteSpace
(
result
))
{
{
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"RunTeacher"
,
$"result:
{
result
}
"
);
var
response
=
await
request
.
PostAsync
(
"https://console.eeo.cn/saasajax/teacher.ajax.php?action=getSchoolTeacherFullList"
,
content
);
JObject
rootObj
=
JObject
.
Parse
(
result
)
;
var
result
=
response
.
Content
.
ReadAsStringAsync
().
Result
;
if
(!
string
.
IsNullOrWhiteSpace
(
r
ootObj
.
GetString
(
"data"
)
))
if
(!
string
.
IsNullOrWhiteSpace
(
r
esult
))
{
{
JObject
dataObj
=
JObject
.
Parse
(
rootObj
.
GetString
(
"data"
));
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"RunTeacher"
,
$"result:
{
result
}
"
);
var
totalNum
=
dataObj
.
GetInt
(
"totalNum"
);
JObject
rootObj
=
JObject
.
Parse
(
result
);
string
rlist
=
dataObj
.
GetString
(
"list"
);
if
(!
string
.
IsNullOrWhiteSpace
(
rootObj
.
GetString
(
"data"
)))
if
(
pageIndex
==
1
)
{
{
if
(
totalNum
>
perpage
)
JObject
dataObj
=
JObject
.
Parse
(
rootObj
.
GetString
(
"data"
));
var
totalNum
=
dataObj
.
GetInt
(
"totalNum"
);
string
rlist
=
dataObj
.
GetString
(
"list"
);
if
(
pageIndex
==
1
)
{
{
if
(
totalNum
%
perpage
==
0
)
if
(
totalNum
>
perpage
)
{
{
pageCount
=
totalNum
/
perpage
;
if
(
totalNum
%
perpage
==
0
)
}
{
else
pageCount
=
totalNum
/
perpage
;
{
}
pageCount
=
(
totalNum
/
perpage
)
+
1
;
else
{
pageCount
=
(
totalNum
/
perpage
)
+
1
;
}
}
}
}
}
list
.
AddRange
(
ParseJson
(
rlist
));
}
}
}
list
.
AddRange
(
ParseJson
(
rlist
));
else
{
Console
.
WriteLine
(
"result"
,
result
);
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"RunTeacher"
,
$"result:
{
result
}
"
);
}
}
}
}
else
catch
(
Exception
ex
)
{
{
Console
.
WriteLine
(
"result"
,
result
);
VTX
.
FW
.
Helper
.
LogHelper
.
WriteError
(
"RunTeacher"
,
ex
:
ex
);
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"RunTeacher"
,
$"result:
{
result
}
"
);
}
}
if
(
pageIndex
==
pageCount
)
if
(
pageIndex
==
pageCount
)
{
{
...
...
EduSpider/Spiders/ICookiesManager.cs
deleted
100644 → 0
View file @
47041ac9
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
TicketSpider.Spiders
{
public
interface
ICookiesManager
{
}
}
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