Browse Source

修复1688爬虫和万邦取图问题

qianyi
shanji 3 years ago
parent
commit
e743d132c1
  1. 2
      BBWY.Client/APIServices/OneBoundAPIService.cs
  2. 18
      BBWY.Client/APIServices/PurchaseProductAPIService.cs

2
BBWY.Client/APIServices/OneBoundAPIService.cs

@ -29,7 +29,7 @@ namespace BBWY.Client.APIServices
{ {
try try
{ {
https://api-gw.onebound.cn/1688/item_get/key=t5060712539&secret=20211103&num_iid=649560646832&lang=zh-CN&cache=no //https://api-gw.onebound.cn/1688/item_get/key=t5060712539&secret=20211103&num_iid=649560646832&lang=zh-CN&cache=no
var result = restApiService.SendRequest("https://api-gw.onebound.cn/", $"{platform}/item_get", $"key={key}&secret={secret}&num_iid={productId}&lang=zh-CN&cache=no", null, HttpMethod.Get, paramPosition: ParamPosition.Query, enableRandomTimeStamp: true); var result = restApiService.SendRequest("https://api-gw.onebound.cn/", $"{platform}/item_get", $"key={key}&secret={secret}&num_iid={productId}&lang=zh-CN&cache=no", null, HttpMethod.Get, paramPosition: ParamPosition.Query, enableRandomTimeStamp: true);
if (result.StatusCode != System.Net.HttpStatusCode.OK) if (result.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception($"{result.StatusCode} {result.Content}"); throw new Exception($"{result.StatusCode} {result.Content}");

18
BBWY.Client/APIServices/PurchaseProductAPIService.cs

@ -92,11 +92,11 @@ namespace BBWY.Client.APIServices
if (result.StatusCode != System.Net.HttpStatusCode.OK) if (result.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception($"{result.StatusCode} {result.Content}"); throw new Exception($"{result.StatusCode} {result.Content}");
var j = JObject.Parse(result.Content); var jobject = JObject.Parse(result.Content);
var isOK = j.Value<string>("error_code") == "0000"; var isOK = jobject.Value<string>("error_code") == "0000";
if (isOK) if (isOK)
{ {
var skuJArray = (JArray)j["item"]["skus"]["sku"]; var skuJArray = (JArray)jobject["item"]["skus"]["sku"];
if (skuJArray.Count == 0) if (skuJArray.Count == 0)
{ {
//errorMsg = $"商品{purchaseSchemeProduct.PurchaseProductId}缺少sku信息"; //errorMsg = $"商品{purchaseSchemeProduct.PurchaseProductId}缺少sku信息";
@ -112,14 +112,14 @@ namespace BBWY.Client.APIServices
PurchaseSkuId = j.Value<string>("sku_id"), PurchaseSkuId = j.Value<string>("sku_id"),
PurchaseSkuSpecId = j.Value<string>("spec_id"), PurchaseSkuSpecId = j.Value<string>("spec_id"),
Title = j.Value<string>("properties_name"), Title = j.Value<string>("properties_name"),
Logo = GetOneBoundSkuLogo(j, (JArray)j["item"]["prop_imgs"]["prop_img"]) Logo = GetOneBoundSkuLogo(j, (JArray)jobject["item"]["prop_imgs"]["prop_img"])
}).ToList(); }).ToList();
var purchaserId = j["item"]["seller_info"].Value<string>("user_num_id"); var purchaserId = jobject["item"]["seller_info"].Value<string>("user_num_id");
var purchaserName = j["item"]["seller_info"].Value<string>("title"); var purchaserName = jobject["item"]["seller_info"].Value<string>("title");
if (string.IsNullOrEmpty(purchaserName)) if (string.IsNullOrEmpty(purchaserName))
purchaserName = j["item"]["seller_info"].Value<string>("shop_name"); purchaserName = jobject["item"]["seller_info"].Value<string>("shop_name");
var purchaserLocation = j["item"].Value<string>("location"); var purchaserLocation = jobject["item"].Value<string>("location");
return (new Purchaser() return (new Purchaser()
{ {
@ -199,7 +199,7 @@ namespace BBWY.Client.APIServices
Location = jobject["data"]["1081181309101"]["data"]["location"].ToString() Location = jobject["data"]["1081181309101"]["data"]["location"].ToString()
}; };
var colorsProperty = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(j => j.Value<int>("fid") == 3216 && var colorsProperty = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(j => j.Value<int>("fid") == 3216 ||
j.Value<int>("fid") == 1627207)["value"] j.Value<int>("fid") == 1627207)["value"]
.Children() .Children()
.Select(j => new .Select(j => new

Loading…
Cancel
Save