Commit 73cc4efe authored by 黄奎's avatar 黄奎

页面修改

parent e9b7bb95
......@@ -156,12 +156,6 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
var data = JObject.Parse(getDtProduct["data"].ToString());
ConfigParsing(data);
}
//行程特色
else if (rootData.ContainsKey("getGfgProdHtml"))
{
var getGfgProdHtml = JObject.Parse(rootData["getGfgProdHtml"].ToString());
var data = JObject.Parse(getGfgProdHtml["data"].ToString());
}
}
return Task.CompletedTask;
}
......@@ -229,7 +223,6 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
}
});
}
}
/// <summary>
......@@ -266,8 +259,6 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
}
}
});
var config = Newtonsoft.Json.JsonConvert.SerializeObject(SouthEastService.TRAVEL_CONFIGS);
Console.WriteLine("config:" + config);
}
}
}
......
......@@ -61,8 +61,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
string origin = "https://tour.settour.com.tw";
SouthEastService.TRAVEL_CONFIGS.ForEach(x => {
var keys = JObject.Parse(x.KeyInfo);
string _prodNo = keys["code"].ToString();
string _prodNo = keys["code"].ToString();
var request = new Request(url);
request.Method = "POST";
var data = new
......@@ -75,9 +74,9 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
query = "query getGfgProdHtml($prodNo: String!) {getGfgProdHtml(prodNo: $prodNo) { error { msgCode msgDesc __typename } data { htmlNameTw html __typename } __typename }}",
variables = data
};
var content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(param), "application/json", "UTF-8");
request.SetHeader("origin", origin);
request.SetHeader("prodNo", _prodNo);
request.Content = MessagePackSerializer.Typeless.Serialize(content);
requests.Add(request);
});
......@@ -90,77 +89,71 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
}
/// <summary>
/// 解析数据
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
protected override Task Parse(DataContext context)
{
var rootValue = JObject.Parse(context.Selectable.Value);
Console.WriteLine("rootValue", Newtonsoft.Json.JsonConvert.SerializeObject(rootValue));
if (rootValue != null)
{
var rootData = JObject.Parse(rootValue["data"].ToString());
var getGfgProdHtml = JObject.Parse(rootData["getGfgProdHtml"].ToString());
var promoteArray = JArray.Parse(getGfgProdHtml["data"].ToString());
//if (promoteArray != null && promoteArray.Count > 0)
//{
// FormatList(promoteArray);
//}
//var productArray = JArray.Parse(data["products"].ToString());
//if (productArray != null && productArray.Count > 0)
//{
// FormatList(productArray);
//}
var data = JArray.Parse(getGfgProdHtml["data"].ToString());
FormatList(context.Request.Headers["prodNo"].ToString(),data);
}
return Task.CompletedTask;
}
private void FormatList(JArray array)
/// <summary>
/// 解析数据
/// </summary>
/// <param name="jObject"></param>
private void FormatList(string Key,JArray jArray)
{
List<RB_Travel_Config> list = new List<RB_Travel_Config>();
array.ToList().ForEach(item =>
if (jArray != null && jArray.Count > 0)
{
var x = item.ToObject<JObject>();
var exsit = SouthEastService.TRAVEL_CONFIGS.Find(y => y.AgentId == x["prodNo"].ToString());
if (exsit == null || string.IsNullOrEmpty(exsit.AgentId))
jArray.ToList().ForEach(item =>
{
var keyInfo = new JObject();
keyInfo.Add("code", x["ittms_code"].ToString());
keyInfo.Add("no", x["travel_no"].ToString());
keyInfo.Add("travel_title_key", x["travel_title_key"].ToString());
SouthEastService.TRAVEL_CONFIGS.Add(new RB_Travel_Config
{
RealLink = string.Format("https://trip.settour.com.tw/taiwan/product/{0}", x["prodNo"].ToString()),
KeyInfo = keyInfo.ToString(),
PDFAlias = x.ContainsKey("travel_title_1") ? x["travel_title_1"].ToString() : x["travel_title"].ToString(),
CreateBy = 0,
CreateDate = DateTime.Now,
CSeat = 0,
DayNum = x["travel_day"].Value<int>(),
Destination = x["travel_city"].ToString(),
FSeat = 0,
ID = 0,
AgentCode = "Best",
AgentId = x["travel_title_key"].ToString(),
ImgCover = x["travel_image_url"].ToString(),
IsB2B = 1,
IsB2C = 1,
IsDirect = 0,
IsOrder = 1,
IsSubstitution = 1,
LowNum = 1,
OpenState = 1,
OpRemark = string.Empty,
PriceIsDirect = 1,
ProductRecommend = x["travel_title_2"]?.ToString(),
SalePlat = "1,2,3,4,5",
Status = 1,
TCState = 3,
Title = x.ContainsKey("travel_title_1") ? x["travel_title_1"].ToString() : x["travel_title"].ToString(),
TravelState = 1,
UpdateBy = 0,
VideoStr = string.Empty,
YSeat = 20
});
var dataObj =item.ToObject<JObject>();
});
}
foreach (var rootItem in SouthEastService.TRAVEL_CONFIGS)
{
var keys = JObject.Parse(rootItem.KeyInfo);
string prodNo = keys["code"].ToString();
if (prodNo == Key)
{
}
}
SouthEastService.TRAVEL_CONFIGS.ForEach(x =>
{
// x.Title = jObject["prodName"].ToString();
// Int32.TryParse(jObject["tourDay"].ToString(), out int DayNum);
// x.DayNum = DayNum;
// if (x.Feature == null)
// {
// x.Feature = new RB_Travel_Feature()
// {
// FeatureHtml = jObject["prodDescription"].ToString(),
// FeeInclude = jObject["featuresIntroduction"].ToString(),
// FeeNonInclude = jObject["feeNotInc"].ToString(),
// ImportantTip = jObject["prodSpec"].ToString(),
// };
// }
// else
// {
// x.Feature.FeatureHtml = jObject["prodDescription"].ToString();
// x.Feature.FeeInclude = jObject["featuresIntroduction"].ToString();
// x.Feature.FeeNonInclude = jObject["feeNotInc"].ToString();
// x.Feature.ImportantTip = jObject["prodSpec"].ToString();
// }
});
}
}
......
......@@ -29,7 +29,7 @@ namespace DotnetSpider.Spiders.Rules.SouthSastRule
//2、获取详情信息,补充列表不完善信息
var obj = new
{
code = "GFG0000000094",
code = "GDP0000001346",
no = "1",
travel_title_key = "0"
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment