using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using AllBase; namespace Work.Api { public class GetVisitProduct { public Dictionary ProductVisit = new Dictionary(); public GetVisitProduct(string name) { Name = name; } public ShopChatBase Shop = null; public static List Product = new List(); public static List ProductTemp = new List(); public static int MaxCount = 0, ThisCount = 0, MinVisitCount = 0, MinSoldCount = 0, Days = 0, MinPrice = 0; public static bool Running = false; public string Name; public void Get() { Running = true; string cookies = ""; if (Shop != null) cookies = Shop.Cookies; string url = "https://mms.pinduoduo.com/earth/api/goodsDataShow/detailList"; string refere = "https://mms.pinduoduo.com/Pdd.html"; string data = "{\"orderBy\":\"pay_ord_cnt\",\"orderStrategy\":\"DESC\",\"pageNumber\":1,\"pageSize\":10,\"spanDays\":" + Days + ",\"readyDate\":\"" + BaseClass.GetServerTimeString().ToString("yyyy-MM-DD") + "\"}"; string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies); int allCount = BaseRegex.GetIntJson(ref html, "total"); int page = allCount / 10 + (allCount % 10 > 0 ? 1 : 0); MaxCount = page; for (int i = 1; i <= page; i++) { if (Shop == null && !Running) break; ThisCount = i; if (i != 1) { data = "{\"orderBy\":\"pay_ord_cnt\",\"orderStrategy\":\"DESC\",\"pageNumber\":" + i + ",\"pageSize\":10,\"spanDays\":" + Days + ",\"readyDate\":\"" + BaseClass.GetServerTimeString().ToString("yyyy-MM-DD") + "\"}"; html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies); } var m = BaseRegex.GetMatchRegex(ref html, @"\{([^\}]+?)\}"); for (int j = 0; m != null && j < m.Count; j++) { string list = m[j].Groups[0].Value; ProductVisitBase p = new ProductVisitBase(); p.Id = BaseRegex.GetLongJson(ref list, "goodsId"); p.GoodsSn = BaseRegex.GetLongJson(ref list, "goodsSn"); p.OrderCount = BaseRegex.GetIntJson(ref list, "payOrderCount"); p.Title = BaseRegex.GetStringJson(ref list, "goodsName"); p.Uv = BaseRegex.GetIntJson(ref list, "goodsUv"); p.Pv = BaseRegex.GetIntJson(ref list, "goodsPv"); p.UvAvgPay = BaseRegex.GetDecimalJson(ref list, "avgGoodsVcr"); p.SoldCount = BaseRegex.GetIntJson(ref list, "payOrderCount"); if (Shop == null) ProductTemp.Add(p); else { if (!ProductVisit.ContainsKey(p.Id)) ProductVisit.Add(p.Id, p.Pv); else ProductVisit[p.Id] = p.Pv; } if (!Product.Exists(pr => pr.Id == p.Id)) Product.Add(p); } LogSave.Add(Name, "获取 " + (Shop == null ? "" : Shop.ShopName) + " 流量:" + i); Thread.Sleep(100); } ThisCount = MaxCount; Running = false; } public DataGridView dataGridViewX5; } public class ProductVisitBase { public string Message = ""; public string Title = ""; public long Id; public long GoodsSn; public int OrderCount = 0; public bool Checked = false; /// /// 支付金额 /// public decimal PayMoney = 0; public int Uv = 0; public decimal Price = 0; /// /// 购物车 /// public int CartCount = 0; /// /// 收藏 /// public int FavCount = 0; /// /// 销量 /// public int SoldCount = 0; public DateTime UpdateTime = DateTime.Now.AddDays(-365); public int Pv = 0; /// /// 平均用户付款数 /// public decimal UvAvgPay = 0; } }