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
e540b712
Commit
e540b712
authored
May 24, 2022
by
罗超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
变更框架
parent
e729ebc3
Pipeline
#132
failed with stages
Changes
12
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
432 additions
and
409 deletions
+432
-409
.dtbcache.v2
.vs/TicketSpider/DesignTimeBuild/.dtbcache.v2
+0
-0
.suo
.vs/TicketSpider/v17/.suo
+0
-0
FlightFlow.cs
Data/FlightFlow.cs
+1
-0
Program.cs
Program.cs
+401
-390
CityService.cs
Spiders/CityService.cs
+1
-0
AccountManagerHelper.cs
Spiders/EasterLineRule/AccountManagerHelper.cs
+3
-0
PassengerHelper.cs
Spiders/EasterLineRule/PassengerHelper.cs
+1
-0
QueryFlightHelper.cs
Spiders/EasterLineRule/QueryFlightHelper.cs
+19
-17
TicketOrderHelper.cs
Spiders/EasterLineRule/TicketOrderHelper.cs
+2
-0
TicketSpider.csproj
TicketSpider.csproj
+2
-2
HttpClientHelper.cs
Uitls/HttpClientHelper.cs
+1
-0
TaskHelper.cs
Uitls/TaskHelper.cs
+1
-0
No files found.
.vs/TicketSpider/DesignTimeBuild/.dtbcache.v2
View file @
e540b712
No preview for this file type
.vs/TicketSpider/v17/.suo
View file @
e540b712
No preview for this file type
Data/FlightFlow.cs
View file @
e540b712
...
...
@@ -6,6 +6,7 @@ using System.Collections.Generic;
using
System.Collections.ObjectModel
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
TicketSpider.Model
;
using
TicketSpider.Spiders.EasterLineRule
;
...
...
Program.cs
View file @
e540b712
// See https://aka.ms/new-console-template for more information
using
Newtonsoft.Json
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
TicketSpider.Data
;
using
TicketSpider.Model
;
using
TicketSpider.Spiders
;
using
TicketSpider.Uitls
;
ThreadPool
.
SetMaxThreads
(
255
,
255
);
ThreadPool
.
SetMinThreads
(
255
,
255
);
#region 初始化城市信息
if
(!
CityService
.
Load
())
static
void
Main
(
string
[]
args
)
{
ThreadPool
.
SetMaxThreads
(
255
,
255
);
ThreadPool
.
SetMinThreads
(
255
,
255
);
#
region
初始化城市信息
if
(!
CityService
.
Load
())
{
Console
.
WriteLine
(
"初始化城市信息失败,检查相关文件"
);
return
;
}
#endregion
}
#
endregion
#region 航司选择
var
airLines
=
new
string
[]
{
"E"
,
"C"
};
while
(
true
)
{
#
region
航司选择
var
airLines
=
new
string
[]
{
"E"
,
"C"
};
while
(
true
)
{
Console
.
WriteLine
(
"请选择要执行的航司,E:东航;C:国航,多个航司使用英语逗号相隔(E,C)"
);
var
airlineStr
=
Console
.
ReadLine
();
if
(!
string
.
IsNullOrEmpty
(
airlineStr
))
...
...
@@ -34,16 +42,16 @@ while (true)
}
}
Console
.
WriteLine
(
"输入有误,重新输入"
);
}
#endregion
}
#
endregion
#region 命令模式
while
(
true
)
{
#
region
命令模式
while
(
true
)
{
Console
.
WriteLine
(
"请选择命令模式(1 步骤模式,2 命令行模式)"
);
var
modes
=
new
int
[]
{
1
,
2
};
var
modes
=
new
int
[]
{
1
,
2
};
var
mode
=
Console
.
ReadLine
();
if
(!
string
.
IsNullOrEmpty
(
mode
)&&
int
.
TryParse
(
mode
,
out
CmdHelper
.
CMD_MODEL
))
if
(!
string
.
IsNullOrEmpty
(
mode
)
&&
int
.
TryParse
(
mode
,
out
CmdHelper
.
CMD_MODEL
))
{
if
(
modes
.
Contains
(
CmdHelper
.
CMD_MODEL
))
{
...
...
@@ -51,12 +59,12 @@ while (true)
}
}
Console
.
WriteLine
(
"输入有误,重新输入"
);
}
#endregion
}
#
endregion
#region 步骤命令模式
if
(
CmdHelper
.
CMD_MODEL
==
1
)
{
#
region
步骤命令模式
if
(
CmdHelper
.
CMD_MODEL
==
1
)
{
#
region
输入航段
while
(
true
)
{
...
...
@@ -100,7 +108,7 @@ if (CmdHelper.CMD_MODEL == 1)
if
(
DateTime
.
TryParse
(
dates
[
0
],
out
dtNow
)
&&
DateTime
.
TryParse
(
dates
[
1
],
out
dtNow
))
{
model
.
DepartDate
=
dateStr
.
Replace
(
"-"
,
"~"
);
model
.
DepartDate
=
dateStr
.
Replace
(
"-"
,
"~"
);
model
.
DepartDateMode
=
2
;
break
;
}
...
...
@@ -121,13 +129,13 @@ if (CmdHelper.CMD_MODEL == 1)
Console
.
WriteLine
(
$"请输入航段
{
CmdHelper
.
FLIGHTS
.
Count
()
+
1
}
需要指定的航班(如:3U8633, 没有直接回车)"
);
model
.
AirlineCode
=
Console
.
ReadLine
()
??
string
.
Empty
;
Console
.
WriteLine
(
$"请输入航段
{
CmdHelper
.
FLIGHTS
.
Count
()
+
1
}
需要指定的仓位代码,多个使用英文逗号相隔(如:\"Y\" \"C,Y\", 没有直接回车)"
);
model
.
SeatCode
=
Console
.
ReadLine
()
??
string
.
Empty
;
model
.
SeatCode
=
Console
.
ReadLine
()
??
string
.
Empty
;
CmdHelper
.
FLIGHTS
.
Add
(
model
);
var
isContinu
=
false
;
while
(
true
)
{
Console
.
WriteLine
(
$"航段
{
CmdHelper
.
FLIGHTS
.
Count
()}
添加成功,是否继续添加航段? (Y:继续添加/n:不添加)"
);
var
continu
=
Console
.
ReadLine
()
??
string
.
Empty
;
var
continu
=
Console
.
ReadLine
()
??
string
.
Empty
;
if
(
continu
==
"Y"
||
continu
==
"n"
)
{
isContinu
=
continu
==
"Y"
;
...
...
@@ -147,7 +155,7 @@ if (CmdHelper.CMD_MODEL == 1)
while
(
true
)
{
Console
.
WriteLine
(
$"请输入乘客
{
CmdHelper
.
PASSENGETS
.
Count
+
1
}
的英文姓名(LIU/DONG)"
);
var
name
=
Console
.
ReadLine
()
??
string
.
Empty
;
var
name
=
Console
.
ReadLine
()
??
string
.
Empty
;
if
(
name
.
Split
(
"/"
).
Length
==
2
)
{
model
.
paxNameFirst
=
name
.
Split
(
"/"
)[
0
];
...
...
@@ -171,8 +179,8 @@ if (CmdHelper.CMD_MODEL == 1)
{
Console
.
WriteLine
(
$"请输入乘客
{
CmdHelper
.
PASSENGETS
.
Count
+
1
}
生日 (2022/01/01)"
);
var
name
=
Console
.
ReadLine
()
??
string
.
Empty
;
var
dtnow
=
DateTime
.
Now
;
if
(
DateTime
.
TryParse
(
name
,
out
dtnow
))
var
dtnow
=
DateTime
.
Now
;
if
(
DateTime
.
TryParse
(
name
,
out
dtnow
))
{
model
.
birthday
=
name
;
break
;
...
...
@@ -183,7 +191,7 @@ if (CmdHelper.CMD_MODEL == 1)
{
Console
.
WriteLine
(
$"请输入乘客
{
CmdHelper
.
PASSENGETS
.
Count
+
1
}
联系电话 (13080808080)"
);
var
name
=
Console
.
ReadLine
()
??
string
.
Empty
;
if
(
name
.
Length
==
11
)
if
(
name
.
Length
==
11
)
{
model
.
mobile
=
name
;
break
;
...
...
@@ -194,8 +202,8 @@ if (CmdHelper.CMD_MODEL == 1)
{
Console
.
WriteLine
(
$"请输入乘客
{
CmdHelper
.
PASSENGETS
.
Count
+
1
}
护照号和护照有效期 (EH36523023 2029/08/18)"
);
var
name
=
(
Console
.
ReadLine
()
??
string
.
Empty
).
Split
(
" "
);
var
dtNow
=
DateTime
.
Now
;
if
(
name
.
Length
==
2
&&
name
[
0
].
Length
>
6
&&
DateTime
.
TryParse
(
name
[
1
],
out
dtNow
))
var
dtNow
=
DateTime
.
Now
;
if
(
name
.
Length
==
2
&&
name
[
0
].
Length
>
6
&&
DateTime
.
TryParse
(
name
[
1
],
out
dtNow
))
{
model
.
favorPaxIdDtoList
=
new
List
<
FavorPaxIdDtoList
>()
{
new
FavorPaxIdDtoList
()
...
...
@@ -226,12 +234,12 @@ if (CmdHelper.CMD_MODEL == 1)
if
(!
isContinu
)
break
;
}
#
endregion
}
#endregion
}
#
endregion
#region 命令行模式
if
(
CmdHelper
.
CMD_MODEL
==
2
)
{
#
region
命令行模式
if
(
CmdHelper
.
CMD_MODEL
==
2
)
{
while
(
true
)
{
Console
.
WriteLine
(
"请输入命令行,如果需要帮助请输入“H”"
);
...
...
@@ -362,7 +370,7 @@ if (CmdHelper.CMD_MODEL == 2)
foreach
(
var
flight
in
flights
)
{
var
flightInfo
=
flight
.
Split
(
" "
);
if
(
flightInfo
.
Length
==
4
&&
flightInfo
[
0
].
Split
(
"/"
).
Length
==
2
)
if
(
flightInfo
.
Length
==
4
&&
flightInfo
[
0
].
Split
(
"/"
).
Length
==
2
)
{
//验证时间
var
dtNow
=
DateTime
.
Now
;
...
...
@@ -426,8 +434,8 @@ if (CmdHelper.CMD_MODEL == 2)
paxName
=
""
,
paxNameFirst
=
pList
[
0
].
Split
(
"/"
)[
0
],
paxNameLast
=
pList
[
0
].
Split
(
"/"
)[
1
],
gender
=
pList
[
1
]==
"男"
?
"M"
:
"F"
,
birthday
=
pList
[
2
].
Replace
(
"/"
,
""
),
gender
=
pList
[
1
]
==
"男"
?
"M"
:
"F"
,
birthday
=
pList
[
2
].
Replace
(
"/"
,
""
),
nationality
=
"CN"
,
telephoneCode
=
"86"
,
mobile
=
pList
[
3
],
...
...
@@ -458,14 +466,16 @@ if (CmdHelper.CMD_MODEL == 2)
{
var
flightAllName
=
string
.
Empty
;
var
passNames
=
string
.
Empty
;
flightList
.
ForEach
(
x
=>
{
if
(
flightList
.
IndexOf
(
x
)
!=
flightList
.
Count
-
1
||
flightList
.
IndexOf
(
x
)==
0
)
flightAllName
+=
"/"
+
x
.
DepartCity
;
flightList
.
ForEach
(
x
=>
{
if
(
flightList
.
IndexOf
(
x
)
!=
flightList
.
Count
-
1
||
flightList
.
IndexOf
(
x
)
==
0
)
flightAllName
+=
"/"
+
x
.
DepartCity
;
if
(
flightList
.
IndexOf
(
x
)
==
flightList
.
Count
-
1
)
flightAllName
+=
"/"
+
x
.
ArriveCity
;
});
passengerList
.
ForEach
(
x
=>
{
passengerList
.
ForEach
(
x
=>
{
passNames
+=
"/"
+
x
.
paxNameFirst
+
x
.
paxNameLast
;
});
Console
.
WriteLine
(
$"刷票需求识别成功,本次行程为:
{
flightAllName
.
Remove
(
0
,
1
)}
{
flightList
.
Count
}
段航程,本次乘客为:
{
passNames
.
Remove
(
0
,
1
)}
{
passengerList
.
Count
}
位乘客"
);
Console
.
WriteLine
(
$"刷票需求识别成功,本次行程为:
{
flightAllName
.
Remove
(
0
,
1
)}
{
flightList
.
Count
}
段航程,本次乘客为:
{
passNames
.
Remove
(
0
,
1
)}
{
passengerList
.
Count
}
位乘客"
);
CmdHelper
.
FLIGHTS
=
flightList
;
CmdHelper
.
PASSENGETS
=
passengerList
;
break
;
...
...
@@ -476,33 +486,34 @@ if (CmdHelper.CMD_MODEL == 2)
}
Console
.
WriteLine
(
""
);
}
}
#endregion
}
#
endregion
#region 初始化机场信息
#
region
初始化机场信息
CmdHelper
.
FLIGHTS
.
ForEach
(
x
=>
{
CmdHelper
.
FLIGHTS
.
ForEach
(
x
=>
{
var
cityDept
=
CityService
.
GetCityHandler
(
x
.
DepartCity
);
var
cityArr
=
CityService
.
GetCityHandler
(
x
.
ArriveCity
);
x
.
depCityCode
=
cityDept
.
cityCode
;
x
.
depCode
=
cityDept
.
value
;
x
.
arrCityCode
=
cityArr
.
cityCode
;
x
.
arrCode
=
cityArr
.
value
;
});
});
#endregion
#
endregion
//Task.Run(() => new FlightFlow().StartAsync());
if
(
CmdHelper
.
AIRLINE
.
Contains
(
"E"
))
{
//Task.Run(() => new FlightFlow().StartAsync());
if
(
CmdHelper
.
AIRLINE
.
Contains
(
"E"
))
{
Task
.
Factory
.
StartNew
(()
=>
new
FlightFlow
().
StartAsync
(),
TaskHelper
.
cancelTokenSource
.
Token
);
}
if
(
CmdHelper
.
AIRLINE
.
Contains
(
"C"
))
{
}
if
(
CmdHelper
.
AIRLINE
.
Contains
(
"C"
))
{
Console
.
WriteLine
(
"暂不支持国航机票嗅探"
);
}
}
Console
.
ReadLine
();
Console
.
ReadLine
();
Environment
.
Exit
(
0
);
\ No newline at end of file
Environment
.
Exit
(
0
);
}
\ No newline at end of file
Spiders/CityService.cs
View file @
e540b712
...
...
@@ -2,6 +2,7 @@
using
Newtonsoft.Json.Linq
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
...
...
Spiders/EasterLineRule/AccountManagerHelper.cs
View file @
e540b712
...
...
@@ -8,9 +8,12 @@ using System.Collections.Generic;
using
System.Collections.ObjectModel
;
using
System.Drawing
;
using
System.Drawing.Imaging
;
using
System.IO
;
using
System.Linq
;
using
System.Net
;
using
System.Net.Http
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
TicketSpider.Spiders.EasterLineRule
...
...
Spiders/EasterLineRule/PassengerHelper.cs
View file @
e540b712
...
...
@@ -4,6 +4,7 @@ using System;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Net
;
using
System.Net.Http
;
using
System.Text
;
using
System.Threading.Tasks
;
using
TicketSpider.Model
;
...
...
Spiders/EasterLineRule/QueryFlightHelper.cs
View file @
e540b712
...
...
@@ -4,8 +4,10 @@ using System;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Net
;
using
System.Net.Http
;
using
System.Net.Http.Headers
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
TicketSpider.Data
;
using
TicketSpider.Uitls
;
...
...
@@ -73,23 +75,23 @@ namespace TicketSpider.Spiders.EasterLineRule
{
Console
.
WriteLine
(
"未找到机票"
);
var
newCookies
=
result
.
cookies
.
Split
(
';'
,
StringSplitOptions
.
RemoveEmptyEntries
);
if
(
newCookies
.
Any
())
{
var
uri
=
new
Uri
(
"https://www.ceair.com"
);
foreach
(
var
cookie
in
newCookies
)
{
var
haveCookies
=
cookieContainer
.
GetAllCookies
().
Where
(
x
=>
x
.
Name
==
cookie
.
Split
(
"="
)[
0
]);
if
(
haveCookies
.
Any
())
{
haveCookies
.
First
().
Value
=
cookie
.
Split
(
"="
)[
1
];
}
else
{
cookieContainer
.
SetCookies
(
uri
,
cookie
);
}
}
}
//
var newCookies = result.cookies.Split(';',StringSplitOptions.RemoveEmptyEntries);
//
if (newCookies.Any())
//
{
//
var uri = new Uri("https://www.ceair.com");
//
foreach (var cookie in newCookies)
//
{
//
var haveCookies = cookieContainer.GetAllCookies().Where(x => x.Name == cookie.Split("=")[0]);
//
if (haveCookies.Any())
//
{
//
haveCookies.First().Value = cookie.Split("=")[1];
//
}
//
else
//
{
//
cookieContainer.SetCookies(uri, cookie);
//
}
//
}
//
}
//TODO 切换代理
}
...
...
Spiders/EasterLineRule/TicketOrderHelper.cs
View file @
e540b712
...
...
@@ -4,7 +4,9 @@ using System;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Net
;
using
System.Net.Http
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
TicketSpider.Model
;
...
...
TicketSpider.csproj
View file @
e540b712
...
...
@@ -2,8 +2,8 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net
6
.0</TargetFramework>
<ImplicitUsings>
en
able</ImplicitUsings>
<TargetFramework>net
5
.0</TargetFramework>
<ImplicitUsings>
dis
able</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
...
...
Uitls/HttpClientHelper.cs
View file @
e540b712
...
...
@@ -2,6 +2,7 @@
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Net
;
using
System.Net.Http
;
using
System.Text
;
using
System.Threading.Tasks
;
...
...
Uitls/TaskHelper.cs
View file @
e540b712
...
...
@@ -2,6 +2,7 @@
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
TicketSpider.Uitls
...
...
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