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
9cc7a8e0
Commit
9cc7a8e0
authored
Jul 24, 2020
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
dbda263b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
249 additions
and
14 deletions
+249
-14
RB_Travel_Config.cs
src/DotnetSpider.Spiders/Model/RB_Travel_Config.cs
+5
-0
SouthEastDetailsSpider.cs
...der.Spiders/Rules/SouthSastRule/SouthEastDetailsSpider.cs
+234
-6
SouthEastListSpider.cs
...Spider.Spiders/Rules/SouthSastRule/SouthEastListSpider.cs
+7
-3
SouthEastServicer.cs
...etSpider.Spiders/Rules/SouthSastRule/SouthEastServicer.cs
+3
-5
No files found.
src/DotnetSpider.Spiders/Model/RB_Travel_Config.cs
View file @
9cc7a8e0
...
@@ -363,6 +363,11 @@ namespace DotnetSpider.Spiders.Model
...
@@ -363,6 +363,11 @@ namespace DotnetSpider.Spiders.Model
/// </summary>
/// </summary>
public
string
KeyInfo
{
get
;
set
;
}
public
string
KeyInfo
{
get
;
set
;
}
/// <summary>
/// 直客价
/// </summary>
public
decimal
B2CPrice
{
get
;
set
;
}
/// <summary>
/// <summary>
/// 行程特色
/// 行程特色
/// </summary>
/// </summary>
...
...
src/DotnetSpider.Spiders/Rules/SouthSastRule/SouthEastDetailsSpider.cs
View file @
9cc7a8e0
...
@@ -125,6 +125,32 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -125,6 +125,32 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
};
};
productRequest
.
Content
=
MessagePackSerializer
.
Typeless
.
Serialize
(
new
StringContent
(
Newtonsoft
.
Json
.
JsonConvert
.
SerializeObject
(
productParam
),
"application/json"
,
"UTF-8"
));
productRequest
.
Content
=
MessagePackSerializer
.
Typeless
.
Serialize
(
new
StringContent
(
Newtonsoft
.
Json
.
JsonConvert
.
SerializeObject
(
productParam
),
"application/json"
,
"UTF-8"
));
requests
.
Add
(
productRequest
);
requests
.
Add
(
productRequest
);
var
priceRequest
=
new
Request
(
SouthEastRequest
.
URL
)
{
Method
=
"POST"
};
priceRequest
.
SetHeader
(
"prodNo"
,
_prodNo
);
priceRequest
.
SetHeader
(
"origin"
,
SouthEastRequest
.
Origin
);
var
priceData
=
new
{
prodNo
=
_prodNo
,
portType
=
"B2C"
,
companyNo
=
""
,
hotelGroupNo
=
""
,
hotelRoomNo
=
""
,
isB2C
=
true
,
month
=
"202007"
,
grupNo
=
""
,
};
var
priceParam
=
new
{
operationname
=
"getDtGrupDate"
,
query
=
@"query getDtGrupDate($prodNo: String!, $portType: String!, $month: String!, $hotelGroupNo: String, $hotelRoomNo: String, $companyNo: String, $isB2C: Boolean!) { getDtGrupDate(prodNo: $prodNo, portType: $portType, month: $month, hotelGroupNo: $hotelGroupNo, hotelRoomNo: $hotelRoomNo, companyNo: $companyNo) { error { msgCode msgDesc __typename } data { date grupNo isHoliday mktInfo price { b2cPrice b2bPrice @skip(if: $isB2C) __typename } charge { bookingAmt chargeText __typename } grupTypeCode grupTypeName qty orgQty __typename } __typename }}"
,
variables
=
priceData
};
priceRequest
.
Content
=
MessagePackSerializer
.
Typeless
.
Serialize
(
new
StringContent
(
Newtonsoft
.
Json
.
JsonConvert
.
SerializeObject
(
priceParam
),
"application/json"
,
"UTF-8"
));
requests
.
Add
(
priceRequest
);
}
}
}
}
...
@@ -157,13 +183,20 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -157,13 +183,20 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
var
dataArray
=
JArray
.
Parse
(
getDtProduct
[
"data"
].
ToString
());
var
dataArray
=
JArray
.
Parse
(
getDtProduct
[
"data"
].
ToString
());
TripParsing
(
context
.
Request
.
Headers
[
"prodNo"
].
ToString
(),
dataArray
);
TripParsing
(
context
.
Request
.
Headers
[
"prodNo"
].
ToString
(),
dataArray
);
}
}
//
团期
数据解析
//
配置
数据解析
else
if
(
rootData
.
ContainsKey
(
"getDtProduct"
))
else
if
(
rootData
.
ContainsKey
(
"getDtProduct"
))
{
{
var
getDtProduct
=
JObject
.
Parse
(
rootData
[
"getDtProduct"
].
ToString
());
var
getDtProduct
=
JObject
.
Parse
(
rootData
[
"getDtProduct"
].
ToString
());
var
data
=
JObject
.
Parse
(
getDtProduct
[
"data"
].
ToString
());
var
data
=
JObject
.
Parse
(
getDtProduct
[
"data"
].
ToString
());
ConfigParsing
(
data
);
ConfigParsing
(
data
);
}
}
//团期数据解析
else
if
(
rootData
.
ContainsKey
(
"getDtGrupDate"
))
{
var
getDtGrupDate
=
JObject
.
Parse
(
rootData
[
"getDtGrupDate"
].
ToString
());
var
data
=
JArray
.
Parse
(
getDtGrupDate
[
"data"
].
ToString
());
PriceParing
(
context
.
Request
.
Headers
[
"prodNo"
].
ToString
(),
data
);
}
}
}
return
Task
.
CompletedTask
;
return
Task
.
CompletedTask
;
}
}
...
@@ -175,7 +208,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -175,7 +208,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
{
{
if
(
jArray
!=
null
&&
jArray
.
Count
>
0
)
if
(
jArray
!=
null
&&
jArray
.
Count
>
0
)
{
{
SouthEastServicer
.
TRAVEL_CONFIGS
.
ForEach
(
x
=>
foreach
(
var
x
in
SouthEastServicer
.
TRAVEL_CONFIGS
)
{
{
var
keys
=
JObject
.
Parse
(
x
.
KeyInfo
);
var
keys
=
JObject
.
Parse
(
x
.
KeyInfo
);
string
prodNo
=
keys
[
"code"
].
ToString
();
string
prodNo
=
keys
[
"code"
].
ToString
();
...
@@ -188,7 +221,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -188,7 +221,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
x
.
JourneyHotels
=
new
List
<
RB_Journey_Hotel
>();
x
.
JourneyHotels
=
new
List
<
RB_Journey_Hotel
>();
x
.
JourneyDinners
=
new
List
<
RB_Journey_Dinner
>();
x
.
JourneyDinners
=
new
List
<
RB_Journey_Dinner
>();
x
.
JourneyTitles
=
new
List
<
RB_Journey_Title
>();
x
.
JourneyTitles
=
new
List
<
RB_Journey_Title
>();
jArray
.
ToList
().
ForEach
(
item
=>
foreach
(
var
item
in
jArray
.
ToList
())
{
{
Int32
.
TryParse
(
item
[
"daySeq"
].
ToString
(),
out
int
DayNum
);
Int32
.
TryParse
(
item
[
"daySeq"
].
ToString
(),
out
int
DayNum
);
x
.
JourneyDinners
.
Add
(
new
RB_Journey_Dinner
x
.
JourneyDinners
.
Add
(
new
RB_Journey_Dinner
...
@@ -196,24 +229,106 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -196,24 +229,106 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
DayNum
=
DayNum
,
DayNum
=
DayNum
,
UseDinnerType
=
"1"
,
UseDinnerType
=
"1"
,
DinnerName
=
item
[
"breakfast"
].
ToString
(),
DinnerName
=
item
[
"breakfast"
].
ToString
(),
AgentId
=
x
.
AgentId
,
BreakfastUseType
=
0
,
CityId
=
0
,
CityName
=
string
.
Empty
,
ConfigId
=
0
,
Description
=
string
.
Empty
,
DinnerId
=
0
,
DinnerImg
=
string
.
Empty
,
ID
=
0
,
MD5Sign
=
string
.
Empty
,
MealId
=
0
,
MealName
=
string
.
Empty
,
QCity
=
string
.
Empty
,
Rank
=
2
,
Status
=
0
,
TimeStr
=
string
.
Empty
,
TimeType
=
0
,
UseTimeHour
=
0
,
UseTimeMinutes
=
0
,
});
});
x
.
JourneyDinners
.
Add
(
new
RB_Journey_Dinner
x
.
JourneyDinners
.
Add
(
new
RB_Journey_Dinner
{
{
DayNum
=
DayNum
,
DayNum
=
DayNum
,
UseDinnerType
=
"2"
,
UseDinnerType
=
"2"
,
DinnerName
=
item
[
"lunch"
].
ToString
(),
DinnerName
=
item
[
"lunch"
].
ToString
(),
AgentId
=
x
.
AgentId
,
BreakfastUseType
=
0
,
CityId
=
0
,
CityName
=
string
.
Empty
,
ConfigId
=
0
,
Description
=
string
.
Empty
,
DinnerId
=
0
,
DinnerImg
=
string
.
Empty
,
ID
=
0
,
MD5Sign
=
string
.
Empty
,
MealId
=
0
,
MealName
=
string
.
Empty
,
QCity
=
string
.
Empty
,
Rank
=
2
,
Status
=
0
,
TimeStr
=
string
.
Empty
,
TimeType
=
0
,
UseTimeHour
=
0
,
UseTimeMinutes
=
0
,
});
});
x
.
JourneyDinners
.
Add
(
new
RB_Journey_Dinner
x
.
JourneyDinners
.
Add
(
new
RB_Journey_Dinner
{
{
DayNum
=
DayNum
,
DayNum
=
DayNum
,
UseDinnerType
=
"3"
,
UseDinnerType
=
"3"
,
DinnerName
=
item
[
"dinner"
].
ToString
(),
DinnerName
=
item
[
"dinner"
].
ToString
(),
AgentId
=
x
.
AgentId
,
BreakfastUseType
=
0
,
CityId
=
0
,
CityName
=
string
.
Empty
,
ConfigId
=
0
,
Description
=
string
.
Empty
,
DinnerId
=
0
,
DinnerImg
=
string
.
Empty
,
ID
=
0
,
MD5Sign
=
string
.
Empty
,
MealId
=
0
,
MealName
=
string
.
Empty
,
QCity
=
string
.
Empty
,
Rank
=
2
,
Status
=
0
,
TimeStr
=
string
.
Empty
,
TimeType
=
0
,
UseTimeHour
=
0
,
UseTimeMinutes
=
0
,
});
});
x
.
JourneyHotels
.
Add
(
new
RB_Journey_Hotel
()
x
.
JourneyHotels
.
Add
(
new
RB_Journey_Hotel
()
{
{
DayNum
=
DayNum
,
DayNum
=
DayNum
,
HotelName
=
item
[
"htl"
].
ToString
(),
HotelName
=
item
[
"htl"
].
ToString
(),
CityId
=
0
,
CityName
=
string
.
Empty
,
ConfigId
=
0
,
AgentId
=
x
.
AgentId
,
Description
=
string
.
Empty
,
HotelId
=
0
,
HotelImg
=
string
.
Empty
,
HotelProductId
=
0
,
HotelProductName
=
string
.
Empty
,
HotelProvideType
=
2
,
HotelType
=
1
,
ID
=
0
,
IsSameLevel
=
1
,
IsUseDinner
=
0
,
MD5Sign
=
string
.
Empty
,
QCity
=
string
.
Empty
,
Rank
=
0
,
Status
=
1
,
TimeStr
=
string
.
Empty
,
TimeType
=
0
,
UseDinnerType
=
string
.
Empty
});
});
x
.
JourneyScenics
.
Add
(
new
RB_Journey_Scenic
()
x
.
JourneyScenics
.
Add
(
new
RB_Journey_Scenic
()
...
@@ -221,15 +336,43 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -221,15 +336,43 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
DayNum
=
DayNum
,
DayNum
=
DayNum
,
CouponsName
=
item
[
"tourBrief"
].
ToString
(),
CouponsName
=
item
[
"tourBrief"
].
ToString
(),
Description
=
item
[
"tourContent"
].
ToString
(),
Description
=
item
[
"tourContent"
].
ToString
(),
AgentId
=
x
.
AgentId
,
CityId
=
0
,
CityName
=
string
.
Empty
,
ConfigId
=
0
,
CouponsId
=
0
,
CouponsTicketId
=
0
,
CouponsTicketName
=
string
.
Empty
,
MD5Sign
=
string
.
Empty
,
NewScenicImg
=
string
.
Empty
,
PlayTimeHour
=
0
,
PlayTimeMinutes
=
0
,
QCity
=
string
.
Empty
,
Rank
=
1
,
ScenicImg
=
"["
+
SouthEastServicer
.
RequestConfig
.
Origin
+
item
[
"imageUrl"
]
+
"]"
,
ScenicJsonStr
=
string
.
Empty
,
Status
=
0
,
TimeStr
=
string
.
Empty
,
TimeType
=
1
,
TrafficContent
=
string
.
Empty
,
TrafficImage
=
string
.
Empty
,
TrafficType
=
4
});
});
x
.
JourneyTitles
.
Add
(
new
RB_Journey_Title
()
x
.
JourneyTitles
.
Add
(
new
RB_Journey_Title
()
{
{
DayNum
=
DayNum
,
DayNum
=
DayNum
,
Description
=
item
[
"tourBrief"
].
ToString
(),
Description
=
item
[
"tourBrief"
].
ToString
(),
ConfigId
=
0
,
Title
=
item
[
"tourBrief"
].
ToString
(),
ID
=
0
,
Rank
=
0
,
AgentId
=
x
.
AgentId
});
});
}
);
}
}
}
}
);
}
}
}
}
}
...
@@ -268,6 +411,91 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -268,6 +411,91 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
}
}
});
});
}
}
/// <summary>
/// 团期数据解析
/// </summary>
/// <param name="jArray"></param>
private
void
PriceParing
(
string
prodNo
,
JArray
jArray
)
{
foreach
(
var
item
in
SouthEastServicer
.
TRAVEL_CONFIGS
)
{
if
(
item
.
Prices
==
null
)
{
item
.
Prices
=
new
List
<
RB_Travel_Price
>();
}
var
keys
=
JObject
.
Parse
(
item
.
KeyInfo
);
string
_prodNo
=
keys
[
"code"
].
ToString
();
if
(
prodNo
==
_prodNo
)
{
if
(
jArray
!=
null
&&
jArray
.
Count
>
0
)
{
foreach
(
var
jItem
in
jArray
)
{
var
pItem
=
jItem
.
ToObject
<
JObject
>();
string
dateStr
=
pItem
[
"date"
].
ToString
();
string
newDateStr
=
dateStr
.
Substring
(
0
,
4
)+
"-"
+
dateStr
.
Substring
(
4
,
2
)+
"-"
+
dateStr
.
Substring
(
6
,
2
);
decimal
.
TryParse
(
pItem
[
"b2cPrice"
].
ToString
(),
out
decimal
b2cPrice
);
if
(
b2cPrice
<=
0
)
{
b2cPrice
=
item
.
B2CPrice
;
}
var
price
=
new
RB_Travel_Price
()
{
AirportService
=
string
.
Empty
,
B2CPrice
=
b2cPrice
,
BabyChargePrice
=
0
,
BabyPrice
=
0
,
ChildNeedPrice
=
0
,
ChildNoNeedPrice
=
0
,
ClearOrderHour
=
72
,
ConfigID
=
0
,
AgentId
=
item
.
AgentId
,
CreateBy
=
0
,
CreateDate
=
DateTime
.
Now
,
CSeat
=
0
,
DiscountPrice
=
0
,
DMCNum
=
prodNo
,
FSeat
=
0
,
GatherTag
=
string
.
Empty
,
Inventory
=
0
,
IsB2B
=
1
,
IsB2C
=
1
,
IsOrder
=
1
,
IsSetOut
=
1
,
IsSubstitution
=
1
,
IsSupportChildren
=
1
,
OldManChargePrice
=
0
,
OPUpdateBy
=
0
,
OPUpdateDate
=
null
,
OtherPrice
=
0
,
RebatePrice
=
0
,
SalePlat
=
"1,2,3,4,5"
,
SingleDMCPrice
=
0
,
SingleRoomPrice
=
0
,
StartDate
=
Convert
.
ToDateTime
(
newDateStr
),
Status
=
1
,
SurplusCSeat
=
0
,
SurplusFSeat
=
0
,
SurplusYSeat
=
0
,
Id
=
0
,
TCNUM
=
""
,
TCSaleState
=
1
,
TCState
=
3
,
TeamType
=
0
,
UpdateBy
=
0
,
UpdateDate
=
DateTime
.
Now
,
UseFlightType
=
1
,
VisaPrice
=
0
,
WordPath
=
string
.
Empty
,
YSeat
=
0
};
item
.
Prices
.
Add
(
price
);
}
}
}
}
}
}
}
}
}
}
}
src/DotnetSpider.Spiders/Rules/SouthSastRule/SouthEastListSpider.cs
View file @
9cc7a8e0
...
@@ -155,7 +155,9 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -155,7 +155,9 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
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
());
SouthEastServicer
.
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
()),
RealLink
=
string
.
Format
(
"https://trip.settour.com.tw/taiwan/product/{0}"
,
x
[
"prodNo"
].
ToString
()),
KeyInfo
=
keyInfo
.
ToString
(),
KeyInfo
=
keyInfo
.
ToString
(),
...
@@ -187,8 +189,10 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -187,8 +189,10 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
TravelState
=
1
,
TravelState
=
1
,
UpdateBy
=
0
,
UpdateBy
=
0
,
VideoStr
=
string
.
Empty
,
VideoStr
=
string
.
Empty
,
YSeat
=
20
YSeat
=
20
,
});
B2CPrice
=
b2cPrice
};
SouthEastServicer
.
TRAVEL_CONFIGS
.
Add
(
config
);
}
}
}
}
}
}
...
...
src/DotnetSpider.Spiders/Rules/SouthSastRule/SouthEastServicer.cs
View file @
9cc7a8e0
...
@@ -22,7 +22,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -22,7 +22,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
{
{
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
(
2
).
ToString
(
"yyyyMMdd"
),
EndDate
=
DateTime
.
Now
.
AddDays
(
1
).
ToString
(
"yyyyMMdd"
),
TotalPage
=
1
,
TotalPage
=
1
,
Origin
=
"https://trip.settour.com.tw"
Origin
=
"https://trip.settour.com.tw"
};
};
...
@@ -46,12 +46,10 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
...
@@ -46,12 +46,10 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
//await SouthEastProdHtmlDetailsSpider.RunAsync();
//await SouthEastProdHtmlDetailsSpider.RunAsync();
Console
.
WriteLine
(
"COnfig:"
+
Newtonsoft
.
Json
.
JsonConvert
.
SerializeObject
(
TRAVEL_CONFIGS
));
Console
.
WriteLine
(
"********* SouthEastService_End ************"
);
//保存数据
//保存数据
await
SouthEastStorageSpider
.
RunAsync
();
await
SouthEastStorageSpider
.
RunAsync
();
Console
.
WriteLine
(
"********* SouthEastService_End ************"
);
}
}
}
}
...
...
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