Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
spider
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
spider
Commits
04ca02ca
Commit
04ca02ca
authored
Jul 28, 2020
by
罗超
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://gitlab.oytour.com/viitto/spider
parents
3c35c5d4
1204b667
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
411 additions
and
30 deletions
+411
-30
RB_Travel_Config.cs
src/DotnetSpider.Spiders/Model/RB_Travel_Config.cs
+5
-0
Program.cs
src/DotnetSpider.Spiders/Program.cs
+5
-1
LionListSpider.cs
src/DotnetSpider.Spiders/Rules/LionRule/LionListSpider.cs
+1
-1
LionService.cs
src/DotnetSpider.Spiders/Rules/LionRule/LionService.cs
+0
-2
SouthEastDetailsSpider.cs
...der.Spiders/Rules/SouthSastRule/SouthEastDetailsSpider.cs
+252
-8
SouthEastListSpider.cs
...Spider.Spiders/Rules/SouthSastRule/SouthEastListSpider.cs
+9
-4
SouthEastPageSpider.cs
...Spider.Spiders/Rules/SouthSastRule/SouthEastPageSpider.cs
+1
-1
SouthEastProdHtmlDetailsSpider.cs
...ers/Rules/SouthSastRule/SouthEastProdHtmlDetailsSpider.cs
+3
-3
SouthEastServicer.cs
...etSpider.Spiders/Rules/SouthSastRule/SouthEastServicer.cs
+5
-10
SouthEastStorageSpider.cs
...der.Spiders/Rules/SouthSastRule/SouthEastStorageSpider.cs
+130
-0
No files found.
src/DotnetSpider.Spiders/Model/RB_Travel_Config.cs
View file @
04ca02ca
...
...
@@ -363,6 +363,11 @@ namespace DotnetSpider.Spiders.Model
/// </summary>
public
string
KeyInfo
{
get
;
set
;
}
/// <summary>
/// 直客价
/// </summary>
public
decimal
B2CPrice
{
get
;
set
;
}
/// <summary>
/// 行程特色
/// </summary>
...
...
src/DotnetSpider.Spiders/Program.cs
View file @
04ca02ca
...
...
@@ -3,6 +3,7 @@ using System.Threading.Tasks;
using
DotnetSpider.Spiders.Rules.BestRule
;
using
DotnetSpider.Spiders.Rules.BwtRule
;
using
DotnetSpider.Spiders.Rules.LionRule
;
using
DotnetSpider.Spiders.Rules.SouthSastRule
;
using
Serilog
;
using
Serilog.Events
;
...
...
@@ -51,7 +52,10 @@ namespace DotnetSpider.Spiders
//await new BestService().RunAsync();
//
await
new
BwtService
().
RunAsync
();
//await new BwtService().RunAsync();
//
await
new
SouthEastServicer
().
RunAsync
();
Console
.
WriteLine
(
"End..."
);
Environment
.
Exit
(
0
);
...
...
src/DotnetSpider.Spiders/Rules/LionRule/LionListSpider.cs
View file @
04ca02ca
...
...
@@ -46,7 +46,7 @@ namespace DotnetSpider.Spiders.Rules.LionRule
{
AddDataFlow
(
new
PageParser
());
AddDataFlow
(
new
ListTravelParser
());
var
request
=
new
Request
(
"https://travel.liontravel.com/search/grouplist?DepartureID=&ArriveID=--9%2C&GoDateStart=2020-07-
16
&GoDateEnd=2020-12-31&GroupID=&Keywords=&IsEnsureGroup=false&IsSold=true&ThemeID=&GoStartDays=0&TravelType=1&ScriptTime=&QueryStr=&ArriveText=&TourArea=0&Page=1&SortType=3"
);
var
request
=
new
Request
(
"https://travel.liontravel.com/search/grouplist?DepartureID=&ArriveID=--9%2C&GoDateStart=2020-07-
30
&GoDateEnd=2020-12-31&GroupID=&Keywords=&IsEnsureGroup=false&IsSold=true&ThemeID=&GoStartDays=0&TravelType=1&ScriptTime=&QueryStr=&ArriveText=&TourArea=0&Page=1&SortType=3"
);
await
AddRequestsAsync
(
request
);
}
...
...
src/DotnetSpider.Spiders/Rules/LionRule/LionService.cs
View file @
04ca02ca
...
...
@@ -35,8 +35,6 @@ namespace DotnetSpider.Spiders.Rules.LionRule
//6、持久化数据
await
LionStorageSpider
.
RunAsync
();
//Console.WriteLine(JArray.FromObject(TRAVEL_CONFIGS));
}
}
}
src/DotnetSpider.Spiders/Rules/SouthSastRule/SouthEastDetailsSpider.cs
View file @
04ca02ca
This diff is collapsed.
Click to expand it.
src/DotnetSpider.Spiders/Rules/SouthSastRule/SouthEastListSpider.cs
View file @
04ca02ca
...
...
@@ -62,6 +62,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
{
AddDataFlow
(
new
ListParser
());
List
<
Request
>
requests
=
new
List
<
Request
>();
SouthEastRequest
.
TotalPage
=
2
;
for
(
int
i
=
1
;
i
<=
SouthEastRequest
.
TotalPage
;
i
++)
{
var
request
=
new
Request
(
SouthEastRequest
.
URL
);
...
...
@@ -148,14 +149,16 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
foreach
(
var
item
in
array
)
{
var
x
=
item
.
ToObject
<
JObject
>();
var
exsit
=
SouthEastService
.
TRAVEL_CONFIGS
.
Find
(
y
=>
y
.
AgentId
==
x
[
"prodNo"
].
ToString
());
var
exsit
=
SouthEastService
r
.
TRAVEL_CONFIGS
.
Find
(
y
=>
y
.
AgentId
==
x
[
"prodNo"
].
ToString
());
if
(
exsit
==
null
||
string
.
IsNullOrEmpty
(
exsit
.
AgentId
))
{
var
keyInfo
=
new
JObject
();
keyInfo
.
Add
(
"code"
,
x
[
"prodNo"
].
ToString
());
keyInfo
.
Add
(
"travelCode"
,
x
[
"travelCode"
].
ToString
());
keyInfo
.
Add
(
"travelName"
,
x
[
"travelName"
].
ToString
());
SouthEastService
.
TRAVEL_CONFIGS
.
Add
(
new
RB_Travel_Config
var
price
=
x
[
"price"
].
ToObject
<
JObject
>();
decimal
.
TryParse
(
price
[
"b2cPrice"
].
ToString
(),
out
decimal
b2cPrice
);
var
config
=
new
RB_Travel_Config
{
RealLink
=
string
.
Format
(
"https://trip.settour.com.tw/taiwan/product/{0}"
,
x
[
"prodNo"
].
ToString
()),
KeyInfo
=
keyInfo
.
ToString
(),
...
...
@@ -187,8 +190,10 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
TravelState
=
1
,
UpdateBy
=
0
,
VideoStr
=
string
.
Empty
,
YSeat
=
20
});
YSeat
=
20
,
B2CPrice
=
b2cPrice
};
SouthEastServicer
.
TRAVEL_CONFIGS
.
Add
(
config
);
}
}
}
...
...
src/DotnetSpider.Spiders/Rules/SouthSastRule/SouthEastPageSpider.cs
View file @
04ca02ca
...
...
@@ -121,7 +121,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
var
getDtSearchResult
=
JObject
.
Parse
(
rootData
[
"getDtSearchResult"
].
ToString
());
var
data
=
JObject
.
Parse
(
getDtSearchResult
[
"data"
].
ToString
());
Int32
.
TryParse
(
data
[
"totalPage"
].
ToString
(),
out
int
totalPage
);
SouthEastService
.
RequestConfig
.
TotalPage
=
totalPage
;
SouthEastService
r
.
RequestConfig
.
TotalPage
=
totalPage
;
}
return
Task
.
CompletedTask
;
}
...
...
src/DotnetSpider.Spiders/Rules/SouthSastRule/SouthEastProdHtmlDetailsSpider.cs
View file @
04ca02ca
...
...
@@ -59,7 +59,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
{
string
url
=
"https://gql.settour.com.tw/graphql"
;
string
origin
=
"https://tour.settour.com.tw"
;
SouthEastService
.
TRAVEL_CONFIGS
.
ForEach
(
x
=>
{
SouthEastService
r
.
TRAVEL_CONFIGS
.
ForEach
(
x
=>
{
var
keys
=
JObject
.
Parse
(
x
.
KeyInfo
);
string
_prodNo
=
keys
[
"code"
].
ToString
();
var
request
=
new
Request
(
url
);
...
...
@@ -128,7 +128,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
});
}
foreach
(
var
rootItem
in
SouthEastService
.
TRAVEL_CONFIGS
)
foreach
(
var
rootItem
in
SouthEastService
r
.
TRAVEL_CONFIGS
)
{
var
keys
=
JObject
.
Parse
(
rootItem
.
KeyInfo
);
string
prodNo
=
keys
[
"code"
].
ToString
();
...
...
@@ -137,7 +137,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
}
}
SouthEastService
.
TRAVEL_CONFIGS
.
ForEach
(
x
=>
SouthEastService
r
.
TRAVEL_CONFIGS
.
ForEach
(
x
=>
{
// x.Title = jObject["prodName"].ToString();
...
...
src/DotnetSpider.Spiders/Rules/SouthSastRule/SouthEastService.cs
→
src/DotnetSpider.Spiders/Rules/SouthSastRule/SouthEastService
r
.cs
View file @
04ca02ca
...
...
@@ -9,20 +9,20 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
/// <summary>
/// 东南旅游
/// </summary>
public
class
SouthEastService
public
class
SouthEastService
r
{
public
static
List
<
RB_Travel_Config
>
TRAVEL_CONFIGS
=
new
List
<
RB_Travel_Config
>();
public
static
SouthEastRequestConfig
RequestConfig
=
new
SouthEastRequestConfig
();
public
SouthEastService
()
public
SouthEastService
r
()
{
TRAVEL_CONFIGS
=
new
List
<
RB_Travel_Config
>();
RequestConfig
=
new
SouthEastRequestConfig
()
{
URL
=
"https://gql.settour.com.tw/graphql"
,
StartDate
=
DateTime
.
Now
.
AddDays
(
1
).
ToString
(
"yyyyMMdd"
),
EndDate
=
DateTime
.
Now
.
AddDays
(
7
).
ToString
(
"yyyyMMdd"
),
EndDate
=
DateTime
.
Now
.
AddDays
(
1
).
ToString
(
"yyyyMMdd"
),
TotalPage
=
1
,
Origin
=
"https://trip.settour.com.tw"
};
...
...
@@ -46,15 +46,10 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
//await SouthEastProdHtmlDetailsSpider.RunAsync();
Console
.
WriteLine
(
"COnfig:"
+
Newtonsoft
.
Json
.
JsonConvert
.
SerializeObject
(
TRAVEL_CONFIGS
));
//保存数据
await
SouthEastStorageSpider
.
RunAsync
();
Console
.
WriteLine
(
"********* SouthEastService_End ************"
);
////3、补充酒店,餐食等信息
//await BwtOtherDetailSpider.RunAsync();
////4、数据持久化
//await BwtStorageSpider.RunAsync();
}
}
...
...
src/DotnetSpider.Spiders/Rules/SouthSastRule/SouthEastStorageSpider.cs
0 → 100644
View file @
04ca02ca
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
DotnetSpider.DataFlow
;
using
DotnetSpider.DataFlow.Parser
;
using
DotnetSpider.Http
;
using
DotnetSpider.Scheduler.Component
;
using
DotnetSpider.Spiders.Common
;
using
DotnetSpider.Spiders.Model
;
using
Microsoft.Extensions.Hosting
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Options
;
using
Newtonsoft.Json.Linq
;
using
Serilog
;
namespace
DotnetSpider.Spiders.Rules.SouthSastRule
{
/// <summary>
/// 东南旅游数据存储
/// </summary>
public
class
SouthEastStorageSpider
:
Spider
{
public
static
async
Task
RunAsync
()
{
var
builder
=
Builder
.
CreateDefaultBuilder
<
SouthEastStorageSpider
>(
options
=>
{
options
.
UseProxy
=
false
;
options
.
Speed
=
1
;
options
.
RequestTimeout
=
60
;
});
builder
.
UseSerilog
();
builder
.
UseQueueDistinctBfsScheduler
<
HashSetDuplicateRemover
>();
await
builder
.
Build
().
RunAsync
();
}
public
SouthEastStorageSpider
(
IOptions
<
SpiderOptions
>
options
,
SpiderServices
services
,
ILogger
<
Spider
>
logger
)
:
base
(
options
,
services
,
logger
)
{
}
protected
override
async
Task
InitializeAsync
(
CancellationToken
stoppingToken
)
{
AddDataFlow
(
new
VirtualParser
());
AddDataFlow
(
GetDefaultStorage
());
var
request
=
new
Request
(
"https://www.baidu.com"
);
await
AddRequestsAsync
(
request
);
}
protected
class
VirtualParser
:
DataParser
{
public
VirtualParser
()
{
}
protected
override
Task
Parse
(
DataContext
context
)
{
//不做文档解析,借用context填充自动化持久数据
var
config
=
typeof
(
RB_Travel_Config_Clone
);
var
feature
=
typeof
(
RB_Travel_Feature
);
var
dinner
=
typeof
(
RB_Journey_Dinner
);
var
hotel
=
typeof
(
RB_Journey_Hotel
);
var
scenic
=
typeof
(
RB_Journey_Scenic
);
var
title
=
typeof
(
RB_Journey_Title
);
var
warmtip
=
typeof
(
RB_Journey_Warmtip
);
var
price
=
typeof
(
RB_Travel_Price
);
var
other
=
typeof
(
RB_TravelPrice_OtherFlight
);
List
<
RB_Travel_Config_Clone
>
travelConfigClones
=
new
List
<
RB_Travel_Config_Clone
>();
List
<
RB_Travel_Feature
>
travelFeatures
=
new
List
<
RB_Travel_Feature
>();
List
<
RB_Journey_Dinner
>
journeyDinners
=
new
List
<
RB_Journey_Dinner
>();
List
<
RB_Journey_Hotel
>
journeyHotels
=
new
List
<
RB_Journey_Hotel
>();
List
<
RB_Journey_Scenic
>
journeyScenics
=
new
List
<
RB_Journey_Scenic
>();
List
<
RB_Journey_Title
>
journeyTitles
=
new
List
<
RB_Journey_Title
>();
List
<
RB_Journey_Warmtip
>
journeyWarmtips
=
new
List
<
RB_Journey_Warmtip
>();
List
<
RB_Travel_Price
>
prices
=
new
List
<
RB_Travel_Price
>();
List
<
RB_TravelPrice_OtherFlight
>
otherFlights
=
new
List
<
RB_TravelPrice_OtherFlight
>();
SouthEastServicer
.
TRAVEL_CONFIGS
.
ForEach
(
x
=>
{
if
(
x
.
Feature
!=
null
)
{
travelFeatures
.
Add
(
x
.
Feature
.
Clone
());
}
if
(
x
.
JourneyDinners
!=
null
&&
x
.
JourneyDinners
.
Count
>
0
)
{
journeyDinners
.
AddRange
(
x
.
JourneyDinners
.
Clone
());
}
if
(
x
.
JourneyHotels
!=
null
&&
x
.
JourneyHotels
.
Count
>
0
)
{
journeyHotels
.
AddRange
(
x
.
JourneyHotels
.
Clone
());
}
if
(
x
.
JourneyScenics
!=
null
&&
x
.
JourneyScenics
.
Count
>
0
)
{
journeyScenics
.
AddRange
(
x
.
JourneyScenics
.
Clone
());
}
if
(
x
.
JourneyTitles
!=
null
&&
x
.
JourneyTitles
.
Count
>
0
)
{
journeyTitles
.
AddRange
(
x
.
JourneyTitles
.
Clone
());
}
if
(
x
.
JourneyWarmtips
!=
null
&&
x
.
JourneyWarmtips
.
Count
>
0
)
{
journeyWarmtips
.
AddRange
(
x
.
JourneyWarmtips
.
Clone
());
}
if
(
x
.
Prices
!=
null
&&
x
.
Prices
.
Count
>
0
)
{
prices
.
AddRange
(
x
.
Prices
.
Clone
());
}
if
(
x
.
OtherFlights
!=
null
&&
x
.
OtherFlights
.
Count
>
0
)
{
otherFlights
.
AddRange
(
x
.
OtherFlights
.
Clone
());
}
var
obj
=
JObject
.
FromObject
(
x
);
travelConfigClones
.
Add
(
obj
.
ToObject
<
RB_Travel_Config_Clone
>());
});
context
.
AddData
(
config
,
travelConfigClones
);
context
.
AddData
(
feature
,
travelFeatures
);
context
.
AddData
(
dinner
,
journeyDinners
);
context
.
AddData
(
hotel
,
journeyHotels
);
context
.
AddData
(
scenic
,
journeyScenics
);
context
.
AddData
(
title
,
journeyTitles
);
context
.
AddData
(
warmtip
,
journeyWarmtips
);
context
.
AddData
(
price
,
prices
);
context
.
AddData
(
other
,
otherFlights
);
return
Task
.
CompletedTask
;
}
}
}
}
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