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
dbda263b
Commit
dbda263b
authored
Jul 24, 2020
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
132741d8
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
149 additions
and
18 deletions
+149
-18
Program.cs
src/DotnetSpider.Spiders/Program.cs
+5
-1
SouthEastDetailsSpider.cs
...der.Spiders/Rules/SouthSastRule/SouthEastDetailsSpider.cs
+3
-3
SouthEastListSpider.cs
...Spider.Spiders/Rules/SouthSastRule/SouthEastListSpider.cs
+2
-2
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
-8
SouthEastStorageSpider.cs
...der.Spiders/Rules/SouthSastRule/SouthEastStorageSpider.cs
+130
-0
No files found.
src/DotnetSpider.Spiders/Program.cs
View file @
dbda263b
...
@@ -3,6 +3,7 @@ using System.Threading.Tasks;
...
@@ -3,6 +3,7 @@ using System.Threading.Tasks;
using
DotnetSpider.Spiders.Rules.BestRule
;
using
DotnetSpider.Spiders.Rules.BestRule
;
using
DotnetSpider.Spiders.Rules.BwtRule
;
using
DotnetSpider.Spiders.Rules.BwtRule
;
using
DotnetSpider.Spiders.Rules.LionRule
;
using
DotnetSpider.Spiders.Rules.LionRule
;
using
DotnetSpider.Spiders.Rules.SouthSastRule
;
using
Serilog
;
using
Serilog
;
using
Serilog.Events
;
using
Serilog.Events
;
...
@@ -51,7 +52,10 @@ namespace DotnetSpider.Spiders
...
@@ -51,7 +52,10 @@ namespace DotnetSpider.Spiders
//await new BestService().RunAsync();
//await new BestService().RunAsync();
//
//
await
new
BwtService
().
RunAsync
();
//await new BwtService().RunAsync();
//
await
new
SouthEastServicer
().
RunAsync
();
Console
.
WriteLine
(
"End..."
);
Console
.
WriteLine
(
"End..."
);
Environment
.
Exit
(
0
);
Environment
.
Exit
(
0
);
...
...
src/DotnetSpider.Spiders/Rules/SouthSastRule/SouthEastDetailsSpider.cs
View file @
dbda263b
...
@@ -63,7 +63,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -63,7 +63,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
/// <param name="requests"></param>
/// <param name="requests"></param>
public
void
LoadRequests
(
List
<
Request
>
requests
)
public
void
LoadRequests
(
List
<
Request
>
requests
)
{
{
foreach
(
var
item
in
SouthEastService
.
TRAVEL_CONFIGS
)
foreach
(
var
item
in
SouthEastService
r
.
TRAVEL_CONFIGS
)
{
{
var
keys
=
JObject
.
Parse
(
item
.
KeyInfo
);
var
keys
=
JObject
.
Parse
(
item
.
KeyInfo
);
string
_prodNo
=
keys
[
"code"
].
ToString
();
string
_prodNo
=
keys
[
"code"
].
ToString
();
...
@@ -175,7 +175,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -175,7 +175,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
{
{
if
(
jArray
!=
null
&&
jArray
.
Count
>
0
)
if
(
jArray
!=
null
&&
jArray
.
Count
>
0
)
{
{
SouthEastService
.
TRAVEL_CONFIGS
.
ForEach
(
x
=>
SouthEastService
r
.
TRAVEL_CONFIGS
.
ForEach
(
x
=>
{
{
var
keys
=
JObject
.
Parse
(
x
.
KeyInfo
);
var
keys
=
JObject
.
Parse
(
x
.
KeyInfo
);
string
prodNo
=
keys
[
"code"
].
ToString
();
string
prodNo
=
keys
[
"code"
].
ToString
();
...
@@ -239,7 +239,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -239,7 +239,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
/// <param name="jObject"></param>
/// <param name="jObject"></param>
private
void
ConfigParsing
(
JObject
jObject
)
private
void
ConfigParsing
(
JObject
jObject
)
{
{
SouthEastService
.
TRAVEL_CONFIGS
.
ForEach
(
x
=>
SouthEastService
r
.
TRAVEL_CONFIGS
.
ForEach
(
x
=>
{
{
var
keys
=
JObject
.
Parse
(
x
.
KeyInfo
);
var
keys
=
JObject
.
Parse
(
x
.
KeyInfo
);
string
prodNo
=
keys
[
"code"
].
ToString
();
string
prodNo
=
keys
[
"code"
].
ToString
();
...
...
src/DotnetSpider.Spiders/Rules/SouthSastRule/SouthEastListSpider.cs
View file @
dbda263b
...
@@ -148,14 +148,14 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -148,14 +148,14 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
foreach
(
var
item
in
array
)
foreach
(
var
item
in
array
)
{
{
var
x
=
item
.
ToObject
<
JObject
>();
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
))
if
(
exsit
==
null
||
string
.
IsNullOrEmpty
(
exsit
.
AgentId
))
{
{
var
keyInfo
=
new
JObject
();
var
keyInfo
=
new
JObject
();
keyInfo
.
Add
(
"code"
,
x
[
"prodNo"
].
ToString
());
keyInfo
.
Add
(
"code"
,
x
[
"prodNo"
].
ToString
());
keyInfo
.
Add
(
"travelCode"
,
x
[
"travelCode"
].
ToString
());
keyInfo
.
Add
(
"travelCode"
,
x
[
"travelCode"
].
ToString
());
keyInfo
.
Add
(
"travelName"
,
x
[
"travelName"
].
ToString
());
keyInfo
.
Add
(
"travelName"
,
x
[
"travelName"
].
ToString
());
SouthEastService
.
TRAVEL_CONFIGS
.
Add
(
new
RB_Travel_Config
SouthEastService
r
.
TRAVEL_CONFIGS
.
Add
(
new
RB_Travel_Config
{
{
RealLink
=
string
.
Format
(
"https://trip.settour.com.tw/taiwan/product/{0}"
,
x
[
"prodNo"
].
ToString
()),
RealLink
=
string
.
Format
(
"https://trip.settour.com.tw/taiwan/product/{0}"
,
x
[
"prodNo"
].
ToString
()),
KeyInfo
=
keyInfo
.
ToString
(),
KeyInfo
=
keyInfo
.
ToString
(),
...
...
src/DotnetSpider.Spiders/Rules/SouthSastRule/SouthEastPageSpider.cs
View file @
dbda263b
...
@@ -121,7 +121,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -121,7 +121,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
var
getDtSearchResult
=
JObject
.
Parse
(
rootData
[
"getDtSearchResult"
].
ToString
());
var
getDtSearchResult
=
JObject
.
Parse
(
rootData
[
"getDtSearchResult"
].
ToString
());
var
data
=
JObject
.
Parse
(
getDtSearchResult
[
"data"
].
ToString
());
var
data
=
JObject
.
Parse
(
getDtSearchResult
[
"data"
].
ToString
());
Int32
.
TryParse
(
data
[
"totalPage"
].
ToString
(),
out
int
totalPage
);
Int32
.
TryParse
(
data
[
"totalPage"
].
ToString
(),
out
int
totalPage
);
SouthEastService
.
RequestConfig
.
TotalPage
=
totalPage
;
SouthEastService
r
.
RequestConfig
.
TotalPage
=
totalPage
;
}
}
return
Task
.
CompletedTask
;
return
Task
.
CompletedTask
;
}
}
...
...
src/DotnetSpider.Spiders/Rules/SouthSastRule/SouthEastProdHtmlDetailsSpider.cs
View file @
dbda263b
...
@@ -59,7 +59,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -59,7 +59,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
{
{
string
url
=
"https://gql.settour.com.tw/graphql"
;
string
url
=
"https://gql.settour.com.tw/graphql"
;
string
origin
=
"https://tour.settour.com.tw"
;
string
origin
=
"https://tour.settour.com.tw"
;
SouthEastService
.
TRAVEL_CONFIGS
.
ForEach
(
x
=>
{
SouthEastService
r
.
TRAVEL_CONFIGS
.
ForEach
(
x
=>
{
var
keys
=
JObject
.
Parse
(
x
.
KeyInfo
);
var
keys
=
JObject
.
Parse
(
x
.
KeyInfo
);
string
_prodNo
=
keys
[
"code"
].
ToString
();
string
_prodNo
=
keys
[
"code"
].
ToString
();
var
request
=
new
Request
(
url
);
var
request
=
new
Request
(
url
);
...
@@ -128,7 +128,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -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
);
var
keys
=
JObject
.
Parse
(
rootItem
.
KeyInfo
);
string
prodNo
=
keys
[
"code"
].
ToString
();
string
prodNo
=
keys
[
"code"
].
ToString
();
...
@@ -137,7 +137,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -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();
// x.Title = jObject["prodName"].ToString();
...
...
src/DotnetSpider.Spiders/Rules/SouthSastRule/SouthEastService.cs
→
src/DotnetSpider.Spiders/Rules/SouthSastRule/SouthEastService
r
.cs
View file @
dbda263b
...
@@ -9,20 +9,20 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -9,20 +9,20 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
/// <summary>
/// <summary>
/// 东南旅游
/// 东南旅游
/// </summary>
/// </summary>
public
class
SouthEastService
public
class
SouthEastService
r
{
{
public
static
List
<
RB_Travel_Config
>
TRAVEL_CONFIGS
=
new
List
<
RB_Travel_Config
>();
public
static
List
<
RB_Travel_Config
>
TRAVEL_CONFIGS
=
new
List
<
RB_Travel_Config
>();
public
static
SouthEastRequestConfig
RequestConfig
=
new
SouthEastRequestConfig
();
public
static
SouthEastRequestConfig
RequestConfig
=
new
SouthEastRequestConfig
();
public
SouthEastService
()
public
SouthEastService
r
()
{
{
TRAVEL_CONFIGS
=
new
List
<
RB_Travel_Config
>();
TRAVEL_CONFIGS
=
new
List
<
RB_Travel_Config
>();
RequestConfig
=
new
SouthEastRequestConfig
()
RequestConfig
=
new
SouthEastRequestConfig
()
{
{
URL
=
"https://gql.settour.com.tw/graphql"
,
URL
=
"https://gql.settour.com.tw/graphql"
,
StartDate
=
DateTime
.
Now
.
AddDays
(
1
).
ToString
(
"yyyyMMdd"
),
StartDate
=
DateTime
.
Now
.
AddDays
(
1
).
ToString
(
"yyyyMMdd"
),
EndDate
=
DateTime
.
Now
.
AddDays
(
7
).
ToString
(
"yyyyMMdd"
),
EndDate
=
DateTime
.
Now
.
AddDays
(
2
).
ToString
(
"yyyyMMdd"
),
TotalPage
=
1
,
TotalPage
=
1
,
Origin
=
"https://trip.settour.com.tw"
Origin
=
"https://trip.settour.com.tw"
};
};
...
@@ -50,11 +50,8 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -50,11 +50,8 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
Console
.
WriteLine
(
"********* SouthEastService_End ************"
);
Console
.
WriteLine
(
"********* SouthEastService_End ************"
);
////3、补充酒店,餐食等信息
//保存数据
//await BwtOtherDetailSpider.RunAsync();
await
SouthEastStorageSpider
.
RunAsync
();
////4、数据持久化
//await BwtStorageSpider.RunAsync();
}
}
}
}
...
...
src/DotnetSpider.Spiders/Rules/SouthSastRule/SouthEastStorageSpider.cs
0 → 100644
View file @
dbda263b
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