temu客户端程序
This commit is contained in:
commit
4aaf264e89
694 files changed
+263780
No files matched your search
@@ -0,0 +1,129 @@
|
||||
using AllBase;
|
||||
using NaiBa.Util.Extension;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Work.CollectClass;
|
||||
using Work.ManageClass;
|
||||
|
||||
namespace Work.Api
|
||||
{
|
||||
public class TaoJiJiProductGet
|
||||
{
|
||||
public ProductCollectBase Product;
|
||||
public bool IsPinduoduo = false;
|
||||
public bool OnSale = true;
|
||||
public TaoJiJiProductGet(ProductCollectBase p)
|
||||
{
|
||||
Product = p;
|
||||
}
|
||||
|
||||
public void Get()
|
||||
{
|
||||
if (TaobaoMobileCollect.ProductTemp.ContainsKey(Product.from_id))
|
||||
{
|
||||
Product = TaobaoMobileCollect.ProductTemp[Product.from_id].Clone();
|
||||
return;
|
||||
}
|
||||
string url = Product.from_url;
|
||||
string refere = string.Empty;
|
||||
string html = GetPostTaobaoHtml.GetUrl(url, refere, true, string.Empty);
|
||||
JObject json = JObject.Parse(html);
|
||||
if (json["result"].ToString() == "1")
|
||||
{
|
||||
var data = json["data"];
|
||||
Product.from_cat_id = BaseRegex.GetIntJson(ref html, @"catid");
|
||||
Product.item_size = "";
|
||||
Product.item_weight = 1;
|
||||
Product.price = data["price"].ParseToDecimal();
|
||||
Product.discount = 0;
|
||||
Product.discountPrice = 0;
|
||||
if (Product.discount == 0)
|
||||
{
|
||||
Product.discount = 1;
|
||||
Product.discountPrice = Product.price;
|
||||
}
|
||||
Product.name = data["name"].ParseToString();
|
||||
foreach (string s in AlibabaShop.NoTitleWords)
|
||||
{
|
||||
Product.name = Product.name.Replace(s, "");
|
||||
}
|
||||
Product.sell_pt = "";
|
||||
var album = data["album"];
|
||||
foreach (var image in album)
|
||||
{
|
||||
Product.Images.Add(image["img640url"].ParseToString());
|
||||
}
|
||||
Product.image = Product.Images[0];
|
||||
Product.image_from_url = Product.image;
|
||||
Product.image_path = "";
|
||||
|
||||
var contentImage = data["image"];
|
||||
foreach (var image in contentImage)
|
||||
{
|
||||
Product.content += "<img src='" + image["img640url"].ParseToString().Replace("_480_480", "_750_750").Replace("_640_640", "_750_750") + "' />";
|
||||
}
|
||||
SetSkuMap(data);
|
||||
}
|
||||
Product.main_cid = 0;
|
||||
Product.from_title = Product.name;
|
||||
Product.from_site_id = 3;
|
||||
Product.main_cid = new FromTitleToCat().GetMainCatId(Product.cat1);
|
||||
if (Product.main_cid == 0)
|
||||
return;
|
||||
if (TaobaoMobileCollect.ProductTemp.Count > 1000)
|
||||
{
|
||||
TaobaoMobileCollect.ProductTemp.Clear();
|
||||
}
|
||||
|
||||
if (!TaobaoMobileCollect.ProductTemp.ContainsKey(Product.from_id))
|
||||
{
|
||||
TaobaoMobileCollect.ProductTemp.Add(Product.from_id, Product);
|
||||
}
|
||||
LogSave.Add("获取成功:" + Product.name);
|
||||
}
|
||||
|
||||
public void SetSkuMap(JToken json)
|
||||
{
|
||||
var skuList = json["show"];
|
||||
foreach (var sku in skuList.Values())
|
||||
{
|
||||
PropBase p = new PropBase();
|
||||
p.name = sku["label"].ParseToString();
|
||||
p.sort++;
|
||||
|
||||
var skuValueList = sku["list"];
|
||||
foreach (var skuValue in skuValueList)
|
||||
{
|
||||
PropValueBase pr = new PropValueBase();
|
||||
pr.name = skuValue.ParseToString();
|
||||
pr.number = new Random(Guid.NewGuid().GetHashCode()).Next(100, 1000);
|
||||
p.Values.Add(pr);
|
||||
}
|
||||
Product.Props.Add(p);
|
||||
}
|
||||
var specList = json["spec"];
|
||||
foreach (var spec in specList)
|
||||
{
|
||||
SkuMapBase sm = new SkuMapBase();
|
||||
foreach (JProperty attr in spec["attr"].Children().OfType<JProperty>())
|
||||
{
|
||||
string titleName = skuList[attr.Name]["label"].ParseToString();
|
||||
sm.name += titleName + ":" + attr.Value.ToString() + ";";
|
||||
}
|
||||
sm.name = sm.name.Trim(';');
|
||||
sm.prop_image = spec["smallImgUrl"].ParseToString();
|
||||
sm.price = spec["groupPrice"].ParseToDecimal();
|
||||
sm.prop_image = spec["smallImgUrl"].ParseToString();
|
||||
int nu = 0;
|
||||
int.TryParse(spec["stocknum"].ParseToString(), out nu);
|
||||
sm.number = nu;
|
||||
Product.SkuMaps.Add(sm);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user