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
6c53737e
Commit
6c53737e
authored
Jun 15, 2022
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
111
parent
4b7cf449
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
44 deletions
+40
-44
Program.cs
EduSpider/Program.cs
+9
-12
ClassInAccountManager.cs
EduSpider/Spiders/ClassInRule/ClassInAccountManager.cs
+30
-32
ClassInFlow.cs
EduSpider/Spiders/ClassInRule/ClassInFlow.cs
+1
-0
No files found.
EduSpider/Program.cs
View file @
6c53737e
...
...
@@ -10,24 +10,21 @@ namespace EduSpider
{
static
void
Main
(
string
[]
args
)
{
var
stopTime
=
1000
*
60
*
30
;
var
stopTime
=
1000
*
60
*
2
;
//30分钟执行一次
while
(
true
)
{
//ClassIn数据
new
ClassInFlow
().
StartAsync
();
Thread
.
Sleep
(
stopTime
);
var
date
=
DateTime
.
Now
;
if
(
date
.
Minute
==
0
)
{
Console
.
WriteLine
(
string
.
Format
(
"{0} 执行方法."
,
date
.
ToString
(
"yyyy-MM-dd HH:mm"
)));
//ClassIn数据
new
ClassInFlow
().
StartAsync
();
Thread
.
Sleep
(
stopTime
);
}
}
//校管家数据
//SchoolTaskHelper.RunTask();
Console
.
ReadLine
();
Environment
.
Exit
(
0
);
//ServiceBase[] services = new ServiceBase[] { new MindService() };
//ServiceBase.Run(services);
}
}
}
\ No newline at end of file
EduSpider/Spiders/ClassInRule/ClassInAccountManager.cs
View file @
6c53737e
...
...
@@ -14,7 +14,7 @@ namespace TicketSpider.Spiders.ClassInRule
public
class
ClassInAccountManager
{
private
static
readonly
object
lockerSafe
=
new
();
private
static
readonly
object
lockerSafe
=
new
();
private
static
string
_loginCookies
=
""
;
//"locationArgumentLang=zh-CN; sensorsdata2015jssdkcross={\"distinct_id\":\"12780052\",\"first_id\":\"180e074a47f92f-06489d0bb8915b-6b3e555b-1327104-180e074a4805d2\",\"props\":{\"$latest_traffic_source_type\":\"直接流量\",\"$latest_search_keyword\":\"未取到值_直接打开\",\"$latest_referrer\":\"\"},\"$device_id\":\"180e074a47f92f-06489d0bb8915b-6b3e555b-1327104-180e074a4805d2\"}; _eeos_uid=12780052; _eeos_useraccount=18140082327; _eeos_userlogo=/upload/images/20200126/709df9532bee722f2268_70.jpg; _eeos_domain=.eeo.cn; _eeos_sid=12780052; _eeos_nsid=kspGu2gfMu+U2EFgLpSGyg==; __tk_id=5792ca4f7a6655c40c4431fbdb729da4; PHPSESSID=l5aanmebp5lvpcbg630ccfha37; _eeos_traffic=EqlIOFq4S2hz5FTTtHzNUViBYcWCixrJYMCF6Y5yJuD8eq8ZwPvVSHMvUkLFA5lzNoaTrDBpGhEY7ykZ9lwMAsNJoNiDt2xKQBr9csRmiBE=";
...
...
@@ -22,18 +22,23 @@ namespace TicketSpider.Spiders.ClassInRule
public
static
string
_userId
=
String
.
Empty
;
public
static
void
ClearCookie
()
{
_loginCookies
=
""
;
}
public
static
string
GetInstance
()
{
if
(
string
.
IsNullOrEmpty
(
_loginCookies
))
{
lock
(
lockerSafe
)
{
if
(
string
.
IsNullOrEmpty
(
_loginCookies
))
if
(
string
.
IsNullOrEmpty
(
_loginCookies
))
{
_loginCookies
=
string
.
Empty
;
var
cnt
=
0
;
while
(
cnt
<
4
)
while
(
cnt
<
4
)
{
cnt
++;
var
result
=
RunAsync
();
...
...
@@ -43,7 +48,7 @@ namespace TicketSpider.Spiders.ClassInRule
Task
.
Run
(()
=>
HeartLine
());
break
;
}
else
else
{
Console
.
WriteLine
(
"开始重新尝试登录"
);
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"GetInstance"
,
"开始重新尝试登录"
);
...
...
@@ -51,13 +56,11 @@ namespace TicketSpider.Spiders.ClassInRule
}
}
}
}
}
}
return
_loginCookies
;
}
public
static
bool
RunAsync
()
{
var
flag
=
false
;
...
...
@@ -76,15 +79,11 @@ namespace TicketSpider.Spiders.ClassInRule
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"RunAsync"
,
"开始登录"
);
try
{
driver
.
Navigate
().
GoToUrl
(
$"https://www.eeo.cn/cn/login"
);
driver
.
Manage
().
Timeouts
().
PageLoad
=
TimeSpan
.
FromSeconds
(
15
);
driver
.
Manage
().
Timeouts
().
PageLoad
=
TimeSpan
.
FromSeconds
(
15
);
inputEle
=
driver
.
FindElement
(
By
.
Name
(
"phoneNum"
));
pwdEle
=
driver
.
FindElement
(
By
.
Name
(
"loginPwd"
));
if
(
inputEle
!=
null
&&
pwdEle
!=
null
)
if
(
inputEle
!=
null
&&
pwdEle
!=
null
)
{
inputEle
.
SendKeys
(
"18140082327"
);
pwdEle
.
SendKeys
(
"ls123456"
);
...
...
@@ -116,7 +115,7 @@ namespace TicketSpider.Spiders.ClassInRule
{
silderBoxEle
=
driver
.
FindElement
(
By
.
Id
(
"reload"
));
}
catch
(
Exception
)
{
}
catch
(
Exception
)
{
}
if
(
silderBoxEle
!=
null
)
{
silderBoxEle
.
Click
();
...
...
@@ -141,7 +140,7 @@ namespace TicketSpider.Spiders.ClassInRule
break
;
}
}
else
else
{
Console
.
WriteLine
(
"未知异常,程序退出"
);
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"RunAsync"
,
$"未知异常,程序退出"
);
...
...
@@ -159,12 +158,11 @@ namespace TicketSpider.Spiders.ClassInRule
Console
.
WriteLine
(
"完成登录..."
);
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"RunAsync"
,
$"完成登录..."
);
return
flag
;
}
public
static
Task
BeginSliderLoginHandler
(
ref
IWebDriver
driver
)
{
//等待滑块加载
Thread
.
Sleep
(
5000
);
driver
.
SwitchTo
().
Frame
(
driver
.
FindElement
(
By
.
Id
(
"tcaptcha_iframe"
)));
...
...
@@ -182,9 +180,9 @@ namespace TicketSpider.Spiders.ClassInRule
var
fileBlockPath
=
$"
{
dirpath
}
\\
{
DateTime
.
Now
.
Ticks
+
1
}
.png"
;
bgPng
.
SaveAsFile
(
fileBgPath
,
ScreenshotImageFormat
.
Png
);
blockPng
.
SaveAsFile
(
fileBlockPath
,
ScreenshotImageFormat
.
Png
);
var
bgX
=
GetBoundary
(
fileBgPath
,
fileBlockPath
);
var
bgX
=
GetBoundary
(
fileBgPath
,
fileBlockPath
);
Console
.
WriteLine
(
$"读取背景缺口边界X坐标:
{
bgX
}
"
);
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"BeginSliderLoginHandler"
,
$"读取背景缺口边界X坐标:
{
bgX
}
"
);
...
...
@@ -210,19 +208,19 @@ namespace TicketSpider.Spiders.ClassInRule
action
.
Build
().
Perform
();
driver
.
SwitchTo
().
DefaultContent
();
}
File
.
Delete
(
fileBgPath
);
File
.
Delete
(
fileBlockPath
);
return
Task
.
CompletedTask
;
}
private
static
int
GetBoundary
(
string
bg
,
string
tp
)
{
var
bgImg
=
Cv2
.
ImRead
(
bg
);
var
tpImg
=
Cv2
.
ImRead
(
tp
);
{
var
bgImg
=
Cv2
.
ImRead
(
bg
);
var
tpImg
=
Cv2
.
ImRead
(
tp
);
var
bgEdge
=
new
Mat
();
Cv2
.
Canny
(
bgImg
,
bgEdge
,
100
,
200
);
...
...
@@ -236,16 +234,16 @@ namespace TicketSpider.Spiders.ClassInRule
Cv2
.
CvtColor
(
tpEdge
,
tpPic
,
ColorConversionCodes
.
GRAY2RGB
);
var
res
=
new
Mat
();
Cv2
.
MatchTemplate
(
bgPic
,
tpPic
,
res
,
TemplateMatchModes
.
CCoeffNormed
);
Cv2
.
MatchTemplate
(
bgPic
,
tpPic
,
res
,
TemplateMatchModes
.
CCoeffNormed
);
OpenCvSharp
.
Point
minLoc
=
new
OpenCvSharp
.
Point
(),
maxLoc
=
new
OpenCvSharp
.
Point
();
Cv2
.
MinMaxLoc
(
res
,
out
double
minVal
,
out
double
maxVal
,
out
minLoc
,
out
maxLoc
);
Cv2
.
MinMaxLoc
(
res
,
out
double
minVal
,
out
double
maxVal
,
out
minLoc
,
out
maxLoc
);
var
bt
=
new
OpenCvSharp
.
Point
(
maxLoc
.
X
+
tpPic
.
Width
,
maxLoc
.
Y
+
tpPic
.
Height
);
var
bt
=
new
OpenCvSharp
.
Point
(
maxLoc
.
X
+
tpPic
.
Width
,
maxLoc
.
Y
+
tpPic
.
Height
);
Cv2
.
Rectangle
(
bgImg
,
maxLoc
,
bt
,
Scalar
.
Red
,
2
);
var
dirpath
=
$"
{
Environment
.
CurrentDirectory
}
\\geetest"
;
Cv2
.
ImWrite
(
$"
{
dirpath
}
\\
{
DateTime
.
Now
.
Ticks
}
.png"
,
bgImg
);
Cv2
.
ImWrite
(
$"
{
dirpath
}
\\
{
DateTime
.
Now
.
Ticks
}
.png"
,
bgImg
);
return
maxLoc
.
X
-
20
;
return
maxLoc
.
X
-
20
;
}
private
static
void
HeartLine
()
...
...
@@ -268,7 +266,7 @@ namespace TicketSpider.Spiders.ClassInRule
}
public
static
void
StopHeartLine
()
{
{
_openHeartTimer
=
false
;
}
...
...
EduSpider/Spiders/ClassInRule/ClassInFlow.cs
View file @
6c53737e
...
...
@@ -16,6 +16,7 @@ namespace TicketSpider.Spiders.ClassInRule
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"StartAsync"
,
"开始模拟登录信息......."
);
string
loginCookies
;
//自定获取Cookie
ClassInAccountManager
.
ClearCookie
();
loginCookies
=
ClassInAccountManager
.
GetInstance
();
//loginCookies = "_eeos_uid=12780052; _eeos_useraccount=18140082327; _eeos_userlogo=%2Fupload%2Fimages%2F20200126%2F709df9532bee722f2268_70.jpg; _eeos_domain=.eeo.cn; _eeos_remember=1; _eeos_sid=12780052; _eeos_nsid=kspGu2gfMu%2BU2EFgLpSGyg%3D%3D; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2212780052%22%2C%22first_id%22%3A%22180f59907abbed-081e4952c5b26f-12333272-2073600-180f59907acbc8%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_referrer%22%3A%22%22%7D%2C%22%24device_id%22%3A%22180f59907abbed-081e4952c5b26f-12333272-2073600-180f59907acbc8%22%7D; _eeos_traffic=EqlIOFq4S2hz5FTTtHzNUViBYcWCixrJYMCF6Y5yJuD8eq8ZwPvVSHMvUkLFA5lzNoaTrDBpGhFOuRmo3R6CQ5GeSsJx1IEakyt2K%2B3ifco%3D; PHPSESSID=3etqs18ka2s425omq6uqsus8s2; __tk_id=7a20b97a04709afc3137ec211e756d5f";
...
...
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