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
86ae5043
Commit
86ae5043
authored
Jun 09, 2022
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
7f2d5f87
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
355 additions
and
19 deletions
+355
-19
AccountHelper.cs
EduSpider/Spiders/SchoolHouseKeeper/AccountHelper.cs
+19
-7
HouseKeeperModel.cs
EduSpider/Spiders/SchoolHouseKeeper/HouseKeeperModel.cs
+25
-0
SchoolCourseManager.cs
EduSpider/Spiders/SchoolHouseKeeper/SchoolCourseManager.cs
+1
-9
SchoolManager.cs
EduSpider/Spiders/SchoolHouseKeeper/SchoolManager.cs
+295
-0
SchoolTaskHelper.cs
EduSpider/Spiders/SchoolHouseKeeper/SchoolTaskHelper.cs
+15
-3
No files found.
EduSpider/Spiders/SchoolHouseKeeper/AccountHelper.cs
View file @
86ae5043
...
@@ -63,7 +63,7 @@ namespace EduSpider.Spiders.SchoolHouseKeeper
...
@@ -63,7 +63,7 @@ namespace EduSpider.Spiders.SchoolHouseKeeper
option
.
AddArgument
(
"headless"
);
option
.
AddArgument
(
"headless"
);
option
.
AddArgument
(
"disable-infobars"
);
option
.
AddArgument
(
"disable-infobars"
);
option
.
AddArgument
(
"window-size=1920,1080"
);
option
.
AddArgument
(
"window-size=1920,1080"
);
option
.
AddArgument
(
"user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/
95.0.4638.69
Safari/537.36"
);
option
.
AddArgument
(
"user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/
101.0.4951.41
Safari/537.36"
);
ChromeDriverService
service
=
ChromeDriverService
.
CreateDefaultService
(
Environment
.
CurrentDirectory
);
ChromeDriverService
service
=
ChromeDriverService
.
CreateDefaultService
(
Environment
.
CurrentDirectory
);
service
.
HideCommandPromptWindow
=
true
;
service
.
HideCommandPromptWindow
=
true
;
option
.
PageLoadStrategy
=
PageLoadStrategy
.
Eager
;
option
.
PageLoadStrategy
=
PageLoadStrategy
.
Eager
;
...
@@ -76,20 +76,31 @@ namespace EduSpider.Spiders.SchoolHouseKeeper
...
@@ -76,20 +76,31 @@ namespace EduSpider.Spiders.SchoolHouseKeeper
pwdEle
=
driver
.
FindElement
(
By
.
Id
(
"pwd"
));
pwdEle
=
driver
.
FindElement
(
By
.
Id
(
"pwd"
));
if
(
inputEle
!=
null
&&
pwdEle
!=
null
)
if
(
inputEle
!=
null
&&
pwdEle
!=
null
)
{
{
inputEle
.
SendKeys
(
"康磊@jjsw"
);
inputEle
.
SendKeys
(
"刘帅@jjsw"
);
pwdEle
.
SendKeys
(
"jjswchemkl2020"
);
pwdEle
.
SendKeys
(
"ls123456"
);
var
buttonEle
=
driver
.
FindElement
(
By
.
Id
(
"loginBtn"
));
var
buttonEle
=
driver
.
FindElement
(
By
.
Id
(
"loginBtn"
));
Thread
.
Sleep
(
1000
);
Thread
.
Sleep
(
1000
);
//开始登录
//开始登录
buttonEle
.
Click
();
buttonEle
.
Click
();
//处理
Thread
.
Sleep
(
1000
);
foreach
(
var
item
in
driver
.
Manage
().
Cookies
.
AllCookies
)
var
cookies
=
driver
.
Manage
().
Cookies
.
AllCookies
;
//处理Cookie
foreach
(
var
item
in
cookies
)
{
{
_loginCookies
+=
item
.
Name
+
"="
+
item
.
Value
+
";"
;
_loginCookies
+=
item
.
Name
+
"="
+
item
.
Value
+
";"
;
}
}
_loginCookies
=
_loginCookies
.
Substring
(
0
,
_loginCookies
.
Length
-
1
);
_loginCookies
=
_loginCookies
.
Substring
(
0
,
_loginCookies
.
Length
-
1
);
flag
=
true
;
if
(!
string
.
IsNullOrEmpty
(
_loginCookies
)
&&
_loginCookies
.
Contains
(
"ASP.NET_SessionId"
)
&&
_loginCookies
.
Contains
(
".ASPXAUTH"
)
)
{
flag
=
true
;
}
else
{
_loginCookies
=
""
;
flag
=
false
;
}
}
}
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
...
@@ -136,5 +147,6 @@ namespace EduSpider.Spiders.SchoolHouseKeeper
...
@@ -136,5 +147,6 @@ namespace EduSpider.Spiders.SchoolHouseKeeper
}
}
return
cc
;
return
cc
;
}
}
}
}
}
}
EduSpider/Spiders/SchoolHouseKeeper/HouseKeeperModel.cs
0 → 100644
View file @
86ae5043
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
EduSpider.Spiders.SchoolHouseKeeper
{
/// <summary>
/// 分页数据
/// </summary>
public
class
PageModel
{
public
int
PageIndex
{
get
;
set
;
}
public
int
PageSize
{
get
;
set
;
}
}
/// <summary>
/// 公用实体类
/// </summary>
public
class
HouseKeeperModel
{
}
}
EduSpider/Spiders/SchoolHouseKeeper/SchoolCourseManager.cs
View file @
86ae5043
...
@@ -15,19 +15,11 @@ namespace EduSpider.Spiders.SchoolHouseKeeper
...
@@ -15,19 +15,11 @@ namespace EduSpider.Spiders.SchoolHouseKeeper
/// </summary>
/// </summary>
public
class
SchoolCourseManager
public
class
SchoolCourseManager
{
{
/// <summary>
/// 分页数据
/// </summary>
public
class
PageModel
{
public
int
PageIndex
{
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
{
{
...
...
EduSpider/Spiders/SchoolHouseKeeper/SchoolManager.cs
0 → 100644
View file @
86ae5043
using
Newtonsoft.Json.Linq
;
using
System
;
using
System.Collections.Generic
;
using
System.Net.Http
;
using
System.Text
;
using
VTX.FW.Helper
;
namespace
EduSpider.Spiders.SchoolHouseKeeper
{
/// <summary>
/// 校区管理
/// </summary>
public
class
SchoolManager
{
/// <summary>
/// 获取课程列表
/// </summary>
public
static
void
RunSchool
(
string
cookie
)
{
var
pageModel
=
new
{
PageSize
=
999
};
int
pageCount
,
totalCount
;
string
url
=
"https://tms11.xiaogj.com/api/Area/ReportAreaList"
;
string
result
;
result
=
Utility
.
SchoolHttpHelper
.
HttpPost
(
url
,
VTX
.
FW
.
Helper
.
JsonHelper
.
Serialize
(
pageModel
),
"application/json"
,
cookie
);
List
<
SchoolItem
>
list
=
new
();
if
(!
string
.
IsNullOrEmpty
(
result
))
{
JObject
jobj
=
JObject
.
Parse
(
result
);
pageCount
=
jobj
.
GetInt
(
"PageCount"
);
totalCount
=
jobj
.
GetInt
(
"TotalCount"
);
list
.
AddRange
(
ParseJson
(
jobj
.
GetString
(
"Data"
)));
Console
.
WriteLine
(
string
.
Format
(
"已完成 总共 {0} 条"
,
totalCount
));
}
Console
.
WriteLine
(
"result:"
+
VTX
.
FW
.
Helper
.
JsonHelper
.
Serialize
(
list
));
}
/// <summary>
/// 解析JSON
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public
static
List
<
SchoolItem
>
ParseJson
(
string
data
)
{
List
<
SchoolItem
>
list
=
new
();
if
(!
string
.
IsNullOrEmpty
(
data
))
{
JArray
courseArray
=
JArray
.
Parse
(
data
);
if
(
courseArray
!=
null
&&
courseArray
.
Count
>
0
)
{
foreach
(
var
item
in
courseArray
)
{
JObject
cObj
=
JObject
.
Parse
(
item
.
ToString
());
var
model
=
new
SchoolItem
()
{
ID
=
cObj
.
GetString
(
"ID"
),
Name
=
cObj
.
GetString
(
"Name"
),
Describe
=
cObj
.
GetString
(
"Describe"
),
CreateTime
=
cObj
.
GetDateTime
(
"CreateTime"
),
ParentId
=
cObj
.
GetString
(
"ParentId"
),
};
list
.
Add
(
model
);
}
}
}
return
list
;
}
/// <summary>
/// 获取部门列表
/// </summary>
/// <param name="cookie"></param>
public
static
void
RunDepartment
(
string
cookie
)
{
var
pageModel
=
new
{
// PageSize = 999
};
int
pageCount
,
totalCount
;
string
url
=
"https://tms11.xiaogj.com/api/depart/query"
;
string
result
;
result
=
Utility
.
SchoolHttpHelper
.
HttpPost
(
url
,
VTX
.
FW
.
Helper
.
JsonHelper
.
Serialize
(
pageModel
),
"application/json"
,
cookie
);
;
List
<
DepartmentItem
>
list
=
new
();
if
(!
string
.
IsNullOrEmpty
(
result
))
{
JObject
jobj
=
JObject
.
Parse
(
result
);
pageCount
=
jobj
.
GetInt
(
"PageCount"
);
totalCount
=
jobj
.
GetInt
(
"TotalCount"
);
list
.
AddRange
(
ParseDepartJson
(
jobj
.
GetString
(
"Data"
)));
Console
.
WriteLine
(
string
.
Format
(
"已完成 总共 {0} 条"
,
totalCount
));
}
Console
.
WriteLine
(
"result:"
+
VTX
.
FW
.
Helper
.
JsonHelper
.
Serialize
(
list
));
}
/// <summary>
/// 解析JSON
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public
static
List
<
DepartmentItem
>
ParseDepartJson
(
string
data
)
{
List
<
DepartmentItem
>
list
=
new
();
if
(!
string
.
IsNullOrEmpty
(
data
))
{
JArray
courseArray
=
JArray
.
Parse
(
data
);
if
(
courseArray
!=
null
&&
courseArray
.
Count
>
0
)
{
foreach
(
var
item
in
courseArray
)
{
JObject
cObj
=
JObject
.
Parse
(
item
.
ToString
());
var
model
=
new
DepartmentItem
()
{
ID
=
cObj
.
GetString
(
"ID"
),
Address
=
cObj
.
GetString
(
"ID"
),
AreaId
=
cObj
.
GetString
(
"AreaId"
),
AreaName
=
cObj
.
GetString
(
"AreaName"
),
CategoryName
=
cObj
.
GetString
(
"CategoryName"
),
Leader
=
cObj
.
GetString
(
"Leader"
),
parentId
=
cObj
.
GetString
(
"parentId"
),
Name
=
cObj
.
GetString
(
"Name"
),
};
list
.
Add
(
model
);
}
}
}
return
list
;
}
/// <summary>
/// 获取员工列表
/// </summary>
/// <param name="cookie"></param>
public
static
void
RunEmployee
(
string
cookie
)
{
var
pageModel
=
new
PageModel
{
PageIndex
=
1
,
PageSize
=
20
};
int
pageCount
,
totalCount
;
string
url
=
"https://tms11.xiaogj.com/api/employee/Query"
;
string
result
;
result
=
Utility
.
SchoolHttpHelper
.
HttpPost
(
url
,
VTX
.
FW
.
Helper
.
JsonHelper
.
Serialize
(
pageModel
),
"application/json"
,
cookie
);
;
List
<
EmployeeItem
>
list
=
new
();
if
(!
string
.
IsNullOrEmpty
(
result
))
{
JObject
jobj
=
JObject
.
Parse
(
result
);
pageCount
=
jobj
.
GetInt
(
"PageCount"
);
totalCount
=
jobj
.
GetInt
(
"TotalCount"
);
list
.
AddRange
(
ParseEmployeeJson
(
jobj
.
GetString
(
"Data"
)));
Console
.
WriteLine
(
string
.
Format
(
"已完成 总共 {0} 条"
,
totalCount
));
}
Console
.
WriteLine
(
"result:"
+
VTX
.
FW
.
Helper
.
JsonHelper
.
Serialize
(
list
));
}
/// <summary>
/// 解析JSON
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public
static
List
<
EmployeeItem
>
ParseEmployeeJson
(
string
data
)
{
List
<
EmployeeItem
>
list
=
new
();
if
(!
string
.
IsNullOrEmpty
(
data
))
{
JArray
courseArray
=
JArray
.
Parse
(
data
);
if
(
courseArray
!=
null
&&
courseArray
.
Count
>
0
)
{
foreach
(
var
item
in
courseArray
)
{
JObject
cObj
=
JObject
.
Parse
(
item
.
ToString
());
var
model
=
new
EmployeeItem
()
{
ID
=
cObj
.
GetString
(
"ID"
),
Name
=
cObj
.
GetString
(
"Name"
),
SMSTel
=
cObj
.
GetString
(
"SMSTel"
),
Serial
=
cObj
.
GetString
(
"Serial"
),
};
list
.
Add
(
model
);
}
}
}
return
list
;
}
}
/// <summary>
/// 校区信息
/// </summary>
public
class
SchoolItem
{
/// <summary>
/// 校区编号
/// </summary>
public
string
ID
{
get
;
set
;
}
/// <summary>
/// 校区名称
/// </summary>
public
string
Name
{
get
;
set
;
}
/// <summary>
/// 描述
/// </summary>
public
string
Describe
{
get
;
set
;
}
/// <summary>
/// 创建时间
/// </summary>
public
DateTime
CreateTime
{
get
;
set
;
}
/// <summary>
/// 父节点GUID
/// </summary>
public
string
ParentId
{
get
;
set
;
}
}
/// <summary>
/// 部门信息
/// </summary>
public
class
DepartmentItem
{
public
string
Address
{
get
;
set
;
}
/// <summary>
/// 校区Id
/// </summary>
public
string
AreaId
{
get
;
set
;
}
/// <summary>
/// 校区名称
/// </summary>
public
string
AreaName
{
get
;
set
;
}
/// <summary>
/// 分类名称
/// </summary>
public
string
CategoryName
{
get
;
set
;
}
/// <summary>
/// 部门编号
/// </summary>
public
string
ID
{
get
;
set
;
}
/// <summary>
/// 负责人
/// </summary>
public
string
Leader
{
get
;
set
;
}
/// <summary>
/// 父级部门编号
/// </summary>
public
string
parentId
{
get
;
set
;
}
/// <summary>
/// 部门名称
/// </summary>
public
string
Name
{
get
;
set
;
}
}
/// <summary>
/// 员工信息
/// </summary>
public
class
EmployeeItem
{
/// <summary>
/// 员工编号
/// </summary>
public
string
ID
{
get
;
set
;
}
/// <summary>
/// 员工姓名
/// </summary>
public
string
Name
{
get
;
set
;
}
/// <summary>
/// 电话
/// </summary>
public
string
SMSTel
{
get
;
set
;
}
/// <summary>
/// 工号
/// </summary>
public
string
Serial
{
get
;
set
;
}
}
}
EduSpider/Spiders/SchoolHouseKeeper/SchoolTaskHelper.cs
View file @
86ae5043
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
namespace
EduSpider.Spiders.SchoolHouseKeeper
namespace
EduSpider.Spiders.SchoolHouseKeeper
...
@@ -18,10 +19,21 @@ namespace EduSpider.Spiders.SchoolHouseKeeper
...
@@ -18,10 +19,21 @@ namespace EduSpider.Spiders.SchoolHouseKeeper
{
{
Console
.
WriteLine
(
"开始校管家任务"
);
Console
.
WriteLine
(
"开始校管家任务"
);
string
cookies
=
""
;
string
cookies
=
""
;
//cookies = AccountHelper.GetInstance();
cookies
=
AccountHelper
.
GetInstance
();
cookies
=
"_gat_gtag_UA_167872829_1=1;_ga=GA1.2.1031016650.1654154573;_gid=GA1.2.876560535.1654154573;.ASPXAUTH=056D300F98E85276C3ED92CF49A02A66944CE75D5F4EE765A81B0F96357EFB5CF2E42BFB639F4F22A5CA94B2CC2723996E8FAD31912D2F7FDFE8819F53E8CE9806444EA3D590C276C6990E79FDD778A8D6300E7B80858646F82D930DF1BA7A6E936ED82C13B77EE0462949883B03C894359F685FEF44A6390DD0945BD1DDCC715B93E256711F67AF113149AAA6042266;ASP.NET_SessionId=ips0xoryxjnueqxbebttinpt"
;
while
(
string
.
IsNullOrEmpty
(
cookies
))
SchoolCourseManager
.
RunCourse
(
cookies
);
{
cookies
=
AccountHelper
.
GetInstance
();
Thread
.
Sleep
(
1000
*
2
);
}
Console
.
WriteLine
(
"cookies:"
+
cookies
);
//cookies = "_ga=GA1.2.1298484415.1654154393; %E5%BA%B7%E7%A3%8A%40jjswGetNewChargeGuide=true; chargeVersion=2; ASP.NET_SessionId=4rjp3ycjhy0faqti3w5mrssb; _gid=GA1.2.738826376.1654680792; autologin=null; loginname=null; loginpwd=null; .ASPXAUTH=B7153A073900F0DDA6155395E8C26A49E2256938BEE1987E6B1B26BE03DFE475EE924CFB2D783CCA46525F1EE2F57442DA29A35087C061B925A96FC4CEDCF850D0CBE9B07A02D7C2F44EE5EB6FA243D1D92B325A5E2EE8D8272514E861A50AAE903C5D777C623EFE3CA6BE7E4CDD78287233F02CBE8B413AACE0963FD4BE6639F9AC6804300F1AA1FFCF44EF7D389041; lastloginname=%E5%88%98%E5%B8%85%40jjsw; _gat_gtag_UA_167872829_1=1";
if
(!
string
.
IsNullOrEmpty
(
cookies
))
{
SchoolManager
.
RunSchool
(
cookies
);
//SchoolManager.RunDepartment(cookies);
//SchoolCourseManager.RunCourse(cookies);
}
Console
.
WriteLine
(
"结束校管家任务"
);
Console
.
WriteLine
(
"结束校管家任务"
);
}
}
}
}
...
...
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