temu客户端程序
This commit is contained in:
commit
4aaf264e89
694 files changed
+263780
No files matched your search
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using AllBase;
|
||||
|
||||
namespace Work.ManageClass
|
||||
{
|
||||
public class AddressSetIni
|
||||
{
|
||||
public static Dictionary<int, List<AddressBase>> Addresses = new Dictionary<int, List<AddressBase>>();
|
||||
public static List<AddressBase> AddressList = new List<AddressBase>();
|
||||
public static List<AddressBase> AddressAllList = new List<AddressBase>();
|
||||
public static Dictionary<int, List<AddressBase>> Addressdic = new Dictionary<int, List<AddressBase>>();
|
||||
public void Ini()
|
||||
{
|
||||
string file = FileBase.ReadAllText("taobao_address.tjm", Encoding.UTF8);
|
||||
if (string.IsNullOrEmpty(file))
|
||||
{
|
||||
MessageBox.Show("初始化淘宝地址信息错误,请检查网络", "提示");
|
||||
return;
|
||||
}
|
||||
var m = BaseRegex.GetMatchRegex(ref file, @"\[""([\d]+)"",\[""([^""]+?)"",""[^""]+?""\],""([\d]+)""");
|
||||
for (int i = 0; i < m.Count; i++)
|
||||
{
|
||||
AddressBase a = new AddressBase();
|
||||
a.Id = int.Parse(m[i].Groups[1].Value);
|
||||
a.Name = m[i].Groups[2].Value;
|
||||
a.UpId = int.Parse(m[i].Groups[3].Value);
|
||||
AddressList.Add(a);
|
||||
if (!Addresses.ContainsKey(a.Id))
|
||||
Addresses.Add(a.Id, new List<AddressBase>());
|
||||
if (!Addresses.ContainsKey(a.UpId))
|
||||
Addresses.Add(a.UpId, new List<AddressBase>());
|
||||
Addresses[a.UpId].Add(a);
|
||||
}
|
||||
}
|
||||
public void getAddress1688()
|
||||
{
|
||||
string strContent = FileBase.ReadAllText("1688_address.tjm");
|
||||
strContent = GetHtml.UrlDecode(strContent);
|
||||
var m = BaseRegex.GetMatchRegex(ref strContent, @"{[^}]+?}");
|
||||
for (int i = 0; m != null && i < m.Count; i++)
|
||||
{
|
||||
|
||||
string addressContent = m[i].Groups[0].Value;
|
||||
AddressBase a = new AddressBase();
|
||||
string[] addressArray = addressContent.Split(',');
|
||||
for (int j = 0; j < addressArray.Length; j++)
|
||||
{
|
||||
var itemMatch = BaseRegex.GetMatchRegex(ref addressArray[j], @"([\w\W]+?):([\w\W]+)");
|
||||
string itemname = itemMatch[0].Groups[1].Value.Replace("{", "");
|
||||
string itemvalue = itemMatch[0].Groups[2].Value.Replace("\"", "").Replace("}", "");
|
||||
if (itemname == "a")
|
||||
{
|
||||
a.Id = int.Parse(itemvalue);
|
||||
}
|
||||
if (itemname == "n")
|
||||
{
|
||||
a.Name = itemvalue;
|
||||
}
|
||||
if (itemname == "p")
|
||||
{
|
||||
a.UpId = int.Parse(itemvalue);
|
||||
}
|
||||
}
|
||||
AddressAllList.Add(a);
|
||||
if (!Addressdic.ContainsKey(a.Id))
|
||||
Addressdic.Add(a.Id, new List<AddressBase>());
|
||||
if (!Addressdic.ContainsKey(a.UpId))
|
||||
Addressdic.Add(a.UpId, new List<AddressBase>());
|
||||
Addressdic[a.UpId].Add(a);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class AddressBase
|
||||
{
|
||||
public int Id = 0;
|
||||
public string Name = "";
|
||||
public int UpId = 0;
|
||||
//public Dictionary<int, AddressBase> Address = new Dictionary<int, AddressBase>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
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;
|
||||
using Work.CollectClass;
|
||||
|
||||
namespace Work.ManageClass
|
||||
{
|
||||
public class AdvanceSale
|
||||
{
|
||||
public string Name;
|
||||
public static Dictionary<string, AdvancStatus> dic = new Dictionary<string, AdvancStatus>();
|
||||
public static List<AdvancStatus> AdvanceList = new List<AdvancStatus>();
|
||||
|
||||
public static bool isAdvance = false, SaleSetFalseDown = false, isUpdateAdvance = false;
|
||||
public static bool apiflag = false;
|
||||
public static long endAdvanceTime = 0;
|
||||
public static int ShopThreadCount = 20;
|
||||
public static bool AllRunningGoods = false;
|
||||
public static bool RunningAdvance = false;
|
||||
public static bool NoRunningAdvance = false;
|
||||
public static bool AllRunningAdvance = false;
|
||||
}
|
||||
|
||||
public class AdvancStatus
|
||||
{
|
||||
public string ShopName = "";
|
||||
public int UpCount = 0;
|
||||
public int DownCount = 0;
|
||||
public int PreCount = 0;
|
||||
public int SetSuccess = 0;
|
||||
public int DownSuccess = 0;
|
||||
public string status = "";
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Work.ManageClass
|
||||
{
|
||||
public class AlibabaShop
|
||||
{
|
||||
public static List<string> NoTitleWords = new List<string>();
|
||||
public static List<string> TitleCantHad = new List<string>();
|
||||
public static List<string> NoBrandName = new List<string>();
|
||||
public static List<string> NoPropWords = new List<string>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,496 @@
|
||||
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.ManageClass
|
||||
{
|
||||
public class AutoQuestion
|
||||
{
|
||||
public string Name;
|
||||
public ShopChatBase Shop;
|
||||
public static int ShopThreadCount = 50;
|
||||
public int rowindex = 0;
|
||||
public int colindex = 0;
|
||||
public static List<ShopQuestion> ShopQuestionList = new List<ShopQuestion>();
|
||||
public static List<QuestionKeyValue> pairList = new List<QuestionKeyValue>();
|
||||
public AutoQuestion(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
public void SetQuestion()
|
||||
{
|
||||
List<Thread> ts = new List<Thread>();
|
||||
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
|
||||
{
|
||||
var shop = GetShopLoginInfo.Shops[i];
|
||||
if (!shop.SelectQue)
|
||||
continue;
|
||||
var p = new AutoQuestionControl(Name, shop);
|
||||
p.rowindex = rowindex;
|
||||
p.colindex = colindex;
|
||||
Threadx.ThreadListWait(ref ts, new Thread(p.SetQuestion), ShopThreadCount);
|
||||
Thread.Sleep(3000);
|
||||
}
|
||||
Threadx.ThreadListWait(ref ts);
|
||||
}
|
||||
public void QueryQuestion()
|
||||
{
|
||||
List<Thread> ts = new List<Thread>();
|
||||
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
|
||||
{
|
||||
var shop = GetShopLoginInfo.Shops[i];
|
||||
if (!shop.SelectQue)
|
||||
continue;
|
||||
var p = new AutoQuestionControl(Name, shop);
|
||||
Threadx.ThreadListWait(ref ts, new Thread(p.QueryQuestion), ShopThreadCount);
|
||||
Thread.Sleep(3000);
|
||||
}
|
||||
Threadx.ThreadListWait(ref ts);
|
||||
}
|
||||
|
||||
public void SetAllQuestion()
|
||||
{
|
||||
List<Thread> ts = new List<Thread>();
|
||||
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
|
||||
{
|
||||
var shop = GetShopLoginInfo.Shops[i];
|
||||
if (!shop.SelectQue)
|
||||
continue;
|
||||
var p = new AutoQuestionControl(Name, shop);
|
||||
p.rowindex = rowindex;
|
||||
p.colindex = colindex;
|
||||
Threadx.ThreadListWait(ref ts, new Thread(p.SetAllQuestion), ShopThreadCount);
|
||||
Thread.Sleep(3000);
|
||||
}
|
||||
Threadx.ThreadListWait(ref ts);
|
||||
}
|
||||
|
||||
public void SetAllEquity()
|
||||
{
|
||||
List<Thread> ts = new List<Thread>();
|
||||
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
|
||||
{
|
||||
var shop = GetShopLoginInfo.Shops[i];
|
||||
if (!shop.SelectQue)
|
||||
continue;
|
||||
var p = new AutoQuestionControl(Name, shop);
|
||||
p.rowindex = rowindex;
|
||||
p.colindex = colindex;
|
||||
Threadx.ThreadListWait(ref ts, new Thread(p.SetAllEquity), ShopThreadCount);
|
||||
Thread.Sleep(3000);
|
||||
}
|
||||
Threadx.ThreadListWait(ref ts);
|
||||
}
|
||||
public void SetSingleEquity()
|
||||
{
|
||||
List<Thread> ts = new List<Thread>();
|
||||
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
|
||||
{
|
||||
var shop = GetShopLoginInfo.Shops[i];
|
||||
if (!shop.SelectQue)
|
||||
continue;
|
||||
var p = new AutoQuestionControl(Name, shop);
|
||||
p.rowindex = rowindex;
|
||||
Threadx.ThreadListWait(ref ts, new Thread(p.SetSingleEquity), ShopThreadCount);
|
||||
Thread.Sleep(3000);
|
||||
}
|
||||
Threadx.ThreadListWait(ref ts);
|
||||
}
|
||||
|
||||
}
|
||||
public class AutoQuestionControl
|
||||
{
|
||||
public string Name;
|
||||
public ShopChatBase Shop;
|
||||
public int rowindex = 0;
|
||||
public int colindex = 0;
|
||||
public List<QuestionKeyValue> satusList = new List<QuestionKeyValue>();
|
||||
|
||||
|
||||
public AutoQuestionControl(string name, ShopChatBase shop)
|
||||
{
|
||||
Name = name;
|
||||
Shop = shop;
|
||||
}
|
||||
public void QueryQuestion()
|
||||
{
|
||||
QueryQuestion(0);
|
||||
}
|
||||
|
||||
public void QueryQuestion(int type=0)
|
||||
{
|
||||
AutoQuestion.pairList.Clear();
|
||||
satusList.Clear();
|
||||
string url = "https://mms.pinduoduo.com/rivendell/api/qualification/getQualificationList";
|
||||
string refere = "https://mms.pinduoduo.com/mallcenter/ability/index";
|
||||
string data = "{}";
|
||||
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
|
||||
var m = BaseRegex.GetMatchRegex(ref html, @"{""questionnaireId"":[^}]+?}");
|
||||
for (int j = 0; m != null && j < m.Count; j++)
|
||||
{
|
||||
string item = m[j].Groups[0].Value;
|
||||
int questionnaireId = BaseRegex.GetIntJson(ref item, "questionnaireId");
|
||||
int finished = BaseRegex.GetIntJson(ref item, "finished");
|
||||
QuestionKeyValue qk = new QuestionKeyValue();
|
||||
qk.key = questionnaireId;
|
||||
qk.value = finished;
|
||||
satusList.Add(qk);
|
||||
}
|
||||
ShopQuestion sq = new ShopQuestion();
|
||||
sq.Shop = Shop;
|
||||
sq.satusList = satusList;
|
||||
AutoQuestion.ShopQuestionList.Add(sq);
|
||||
|
||||
m = BaseRegex.GetMatchRegex(ref html, @"""qualificationBenefit"":\s*\[\{[^}]+?\}");
|
||||
for (int j = 0; m != null && j < m.Count; j++)
|
||||
{
|
||||
string item = m[j].Groups[0].Value;
|
||||
int finished = BaseRegex.GetIntJson(ref item, "benefitStatus");
|
||||
QuestionKeyValue qk = new QuestionKeyValue();
|
||||
qk.key = j + 1;
|
||||
qk.value = finished;
|
||||
AutoQuestion.pairList.Add(qk);
|
||||
}
|
||||
if (type == 0)
|
||||
LogSave.Add(Name, Shop.ShopName + "查询店铺答题状况完成。");
|
||||
else
|
||||
{
|
||||
var p = AutoQuestion.pairList.Find(s => s.value == 0);
|
||||
if (p != null)
|
||||
{
|
||||
ShopQuestion sqx = new ShopQuestion();
|
||||
sqx.Shop = Shop;
|
||||
sqx.status = "领取权益部分失败";
|
||||
AutoQuestion.ShopQuestionList.Add(sqx);
|
||||
LogSave.Add(Name, Shop.ShopName + "领取权益部分失败。");
|
||||
}
|
||||
else
|
||||
{
|
||||
ShopQuestion sqx = new ShopQuestion();
|
||||
sqx.Shop = Shop;
|
||||
sqx.status = "领取权益完成";
|
||||
AutoQuestion.ShopQuestionList.Add(sqx);
|
||||
LogSave.Add(Name, Shop.ShopName + "领取权益完成。");
|
||||
}
|
||||
}
|
||||
}
|
||||
public void SetQuestion()
|
||||
{
|
||||
if (rowindex == 0 || colindex == 0)
|
||||
return;
|
||||
string cookies = Shop.Cookies;
|
||||
string url = "https://mms.pinduoduo.com/rivendell/api/qualification/getQualificationList";
|
||||
string refere = "https://mms.pinduoduo.com/mallcenter/ability/index";
|
||||
string data = "{}";
|
||||
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
|
||||
var m = BaseRegex.GetMatchRegex(ref html, @"{""questionnaireId"":[^}]+?}");
|
||||
for (int j = 0; m != null && j < m.Count; j++)
|
||||
{
|
||||
string item = m[j].Groups[0].Value;
|
||||
int questionnaireId = BaseRegex.GetIntJson(ref item, "questionnaireId");
|
||||
int finished = BaseRegex.GetIntJson(ref item, "finished");
|
||||
if (questionnaireId == colindex && finished == 1)
|
||||
{
|
||||
string result = RetResult(colindex, "已通过,考试无需再考");
|
||||
ShopQuestion sq = new ShopQuestion();
|
||||
sq.Shop = Shop;
|
||||
sq.status = "已通过,考试无需再考";
|
||||
AutoQuestion.ShopQuestionList.Add(sq);
|
||||
LogSave.Add(Name, result);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
Thread.Sleep(1000);
|
||||
url = "https://mms.pinduoduo.com/rivendell/api/questionnaire/getQuestionnaireDetail";
|
||||
refere = "https://mms.pinduoduo.com/mallcenter/ability/exam/"+ colindex;
|
||||
data = "{\"questionnaireId\":"+colindex+"}";
|
||||
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
|
||||
Thread.Sleep(1000);
|
||||
|
||||
url = "https://mms.pinduoduo.com/rivendell/api/qualification/detail";
|
||||
refere = "https://mms.pinduoduo.com/mallcenter/ability/exam/"+ colindex;
|
||||
data = "{\"qualificationId\":"+rowindex+"}";
|
||||
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
|
||||
Thread.Sleep(200);
|
||||
|
||||
url = "https://mms.pinduoduo.com/rivendell/api/questionnaire/updateReadRecord";
|
||||
refere = "https://mms.pinduoduo.com/mallcenter/ability/exam/"+ colindex;
|
||||
data = "{\"questionnaireId\":"+ colindex + "}";
|
||||
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
|
||||
if (html.Contains("\"success\":true"))
|
||||
{
|
||||
ShopQuestion sq = new ShopQuestion();
|
||||
sq.Shop = Shop;
|
||||
sq.status = "已通过";
|
||||
AutoQuestion.ShopQuestionList.Add(sq);
|
||||
LogSave.Add(Name, RetResult(colindex));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAllQuestion()
|
||||
{
|
||||
satusList.Clear();
|
||||
string urlx = "https://mms.pinduoduo.com/rivendell/api/qualification/getQualificationList";
|
||||
string referex = "https://mms.pinduoduo.com/mallcenter/ability/index";
|
||||
string datax = "{}";
|
||||
string htmlx = GetPostTaobaoHtml.UploadTaobaoPost(urlx, referex, true, datax, Shop.Cookies);
|
||||
var m = BaseRegex.GetMatchRegex(ref htmlx, @"{""questionnaireId"":[^}]+?}");
|
||||
for (int j = 0; m != null && j < m.Count; j++)
|
||||
{
|
||||
string item = m[j].Groups[0].Value;
|
||||
int questionnaireId = BaseRegex.GetIntJson(ref item, "questionnaireId");
|
||||
int finished = BaseRegex.GetIntJson(ref item, "finished");
|
||||
QuestionKeyValue qk = new QuestionKeyValue();
|
||||
qk.key = questionnaireId;
|
||||
qk.value = finished;
|
||||
satusList.Add(qk);
|
||||
}
|
||||
string cookies = Shop.Cookies;
|
||||
for (int i =1; i < 5; i++)
|
||||
{
|
||||
for (int j = 1; j < 5; j++)
|
||||
{
|
||||
rowindex = i;
|
||||
colindex = j + 4 * (i - 1);
|
||||
var staval = satusList.Find(sa => sa.key == colindex);
|
||||
if (staval.value==1)
|
||||
{
|
||||
string result = RetResult(colindex, "已通过,考试无需再考");
|
||||
ShopQuestion sq = new ShopQuestion();
|
||||
sq.Shop = Shop;
|
||||
sq.status = result;
|
||||
AutoQuestion.ShopQuestionList.Add(sq);
|
||||
LogSave.Add(Name, RetResult(colindex));
|
||||
continue;
|
||||
}
|
||||
string url = "https://mms.pinduoduo.com/rivendell/api/questionnaire/getQuestionnaireDetail";
|
||||
string refere = "https://mms.pinduoduo.com/mallcenter/ability/exam/" + colindex;
|
||||
string data = "{\"questionnaireId\":" + colindex + "}";
|
||||
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
|
||||
Thread.Sleep(200);
|
||||
|
||||
url = "https://mms.pinduoduo.com/rivendell/api/qualification/detail";
|
||||
refere = "https://mms.pinduoduo.com/mallcenter/ability/exam/" + colindex;
|
||||
data = "{\"qualificationId\":" + rowindex + "}";
|
||||
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
|
||||
Thread.Sleep(200);
|
||||
|
||||
url = "https://mms.pinduoduo.com/rivendell/api/questionnaire/updateReadRecord";
|
||||
refere = "https://mms.pinduoduo.com/mallcenter/ability/exam/" + colindex;
|
||||
data = "{\"questionnaireId\":" + colindex + "}";
|
||||
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
|
||||
if (html.Contains("\"success\":true"))
|
||||
{
|
||||
string result = RetResult(colindex);
|
||||
//ShopQuestion sq = new ShopQuestion();
|
||||
//sq.Shop = Shop;
|
||||
//sq.status = result;
|
||||
//AutoQuestion.ShopQuestionList.Add(sq);
|
||||
LogSave.Add(Name, result);
|
||||
}
|
||||
int randx = new Random(Guid.NewGuid().GetHashCode()).Next(1, 5);
|
||||
Thread.Sleep(randx);
|
||||
}
|
||||
}
|
||||
QueryStatusQuestion();
|
||||
}
|
||||
public void QueryStatusQuestion()
|
||||
{
|
||||
satusList.Clear();
|
||||
string url = "https://mms.pinduoduo.com/rivendell/api/qualification/getQualificationList";
|
||||
string refere = "https://mms.pinduoduo.com/mallcenter/ability/index";
|
||||
string data = "{}";
|
||||
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
|
||||
var m = BaseRegex.GetMatchRegex(ref html, @"{""questionnaireId"":[^}]+?}");
|
||||
for (int j = 0; m != null && j < m.Count; j++)
|
||||
{
|
||||
string item = m[j].Groups[0].Value;
|
||||
int questionnaireId = BaseRegex.GetIntJson(ref item, "questionnaireId");
|
||||
int finished = BaseRegex.GetIntJson(ref item, "finished");
|
||||
QuestionKeyValue qk = new QuestionKeyValue();
|
||||
qk.key = questionnaireId;
|
||||
qk.value = finished;
|
||||
satusList.Add(qk);
|
||||
}
|
||||
var p = satusList.Find(s=>s.value==0);
|
||||
if (p != null)
|
||||
{
|
||||
ShopQuestion sq = new ShopQuestion();
|
||||
sq.Shop = Shop;
|
||||
sq.status = "答题部分失败";
|
||||
AutoQuestion.ShopQuestionList.Add(sq);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShopQuestion sq = new ShopQuestion();
|
||||
sq.Shop = Shop;
|
||||
sq.status = "答题全部成功";
|
||||
AutoQuestion.ShopQuestionList.Add(sq);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAllEquity()
|
||||
{
|
||||
satusList.Clear();
|
||||
string urlx = "https://mms.pinduoduo.com/rivendell/api/qualification/getQualificationList";
|
||||
string referex = "https://mms.pinduoduo.com/mallcenter/ability/index";
|
||||
string datax = "{}";
|
||||
string htmlx = GetPostTaobaoHtml.UploadTaobaoPost(urlx, referex, true, datax, Shop.Cookies);
|
||||
var m = BaseRegex.GetMatchRegex(ref htmlx, @"{""questionnaireId"":[^}]+?}");
|
||||
for (int j = 0; m != null && j < m.Count; j++)
|
||||
{
|
||||
string item = m[j].Groups[0].Value;
|
||||
int questionnaireId = BaseRegex.GetIntJson(ref item, "questionnaireId");
|
||||
int finished = BaseRegex.GetIntJson(ref item, "finished");
|
||||
QuestionKeyValue qk = new QuestionKeyValue();
|
||||
qk.key = questionnaireId;
|
||||
qk.value = finished;
|
||||
satusList.Add(qk);
|
||||
}
|
||||
string cookies = Shop.Cookies;
|
||||
for (int i = 1; i < 5; i++)
|
||||
{
|
||||
rowindex = i;
|
||||
if (satusList[4 * i - 4].value != 1 || satusList[4 * i - 3].value != 1 || satusList[4 * i - 2].value != 1 || satusList[4 * i-1].value != 1)
|
||||
continue;
|
||||
string url = "https://mms.pinduoduo.com/rivendell/api/qualification/receiveBenefits";
|
||||
string refere = "https://mms.pinduoduo.com/mallcenter/ability/index";
|
||||
string data = "{\"qualificationId\":" + rowindex + "}";
|
||||
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
|
||||
LogSave.Add(Name, RetResultEqu(i));
|
||||
int randx = new Random(Guid.NewGuid().GetHashCode()).Next(1, 5);
|
||||
Thread.Sleep(randx);
|
||||
}
|
||||
QueryQuestion(1);
|
||||
}
|
||||
public void SetSingleEquity()
|
||||
{
|
||||
satusList.Clear();
|
||||
string urlx = "https://mms.pinduoduo.com/rivendell/api/qualification/getQualificationList";
|
||||
string referex = "https://mms.pinduoduo.com/mallcenter/ability/index";
|
||||
string datax = "{}";
|
||||
string htmlx = GetPostTaobaoHtml.UploadTaobaoPost(urlx, referex, true, datax, Shop.Cookies);
|
||||
var m = BaseRegex.GetMatchRegex(ref htmlx, @"{""questionnaireId"":[^}]+?}");
|
||||
for (int j = 0; m != null && j < m.Count; j++)
|
||||
{
|
||||
string item = m[j].Groups[0].Value;
|
||||
int questionnaireId = BaseRegex.GetIntJson(ref item, "questionnaireId");
|
||||
int finished = BaseRegex.GetIntJson(ref item, "finished");
|
||||
QuestionKeyValue qk = new QuestionKeyValue();
|
||||
qk.key = questionnaireId;
|
||||
qk.value = finished;
|
||||
satusList.Add(qk);
|
||||
}
|
||||
string cookies = Shop.Cookies;
|
||||
if (satusList[4 * rowindex - 4].value != 1 || satusList[4 * rowindex - 3].value != 1 || satusList[4 * rowindex - 2].value != 1 || satusList[4 * rowindex - 1].value != 1)
|
||||
return;
|
||||
string url = "https://mms.pinduoduo.com/rivendell/api/qualification/receiveBenefits";
|
||||
string refere = "https://mms.pinduoduo.com/mallcenter/ability/index";
|
||||
string data = "{\"qualificationId\":" + rowindex + "}";
|
||||
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
|
||||
LogSave.Add(Name, RetResultEqu(rowindex));
|
||||
QueryQuestion(1);
|
||||
int randx = new Random(Guid.NewGuid().GetHashCode()).Next(1, 5);
|
||||
Thread.Sleep(randx);
|
||||
|
||||
}
|
||||
public string RetResultEqu(int col, string str = "已领取权益")
|
||||
{
|
||||
string result = "";
|
||||
switch (col)
|
||||
{
|
||||
case 1:
|
||||
result = "基础经营能力认证,";
|
||||
break;
|
||||
case 2:
|
||||
result = "高级经营能力认证,";
|
||||
break;
|
||||
case 3:
|
||||
result = "推广能力认证,";
|
||||
break;
|
||||
case 4:
|
||||
result = "活动能力认证,";
|
||||
break;
|
||||
}
|
||||
return Shop.ShopName + ":" + result + str;
|
||||
}
|
||||
public string RetResult(int col,string str= "已通过")
|
||||
{
|
||||
string result = "";
|
||||
switch(col)
|
||||
{
|
||||
case 1:
|
||||
result = "基础经营能力认证,试题Ⅰ:新商家入驻";
|
||||
break;
|
||||
case 2:
|
||||
result = "基础经营能力认证,试题Ⅱ:平台规则";
|
||||
break;
|
||||
case 3:
|
||||
result = "基础经营能力认证,试题Ⅲ:商品设置、店铺运营";
|
||||
break;
|
||||
case 4:
|
||||
result = "基础经营能力认证,试题Ⅳ:客户服务";
|
||||
break;
|
||||
case 5:
|
||||
result = "高级经营能力认证,试题Ⅰ:店铺管理";
|
||||
break;
|
||||
case 6:
|
||||
result = "高级经营能力认证,试题Ⅱ:商品管理";
|
||||
break;
|
||||
case 7:
|
||||
result = "高级经营能力认证,试题Ⅲ:订单管理";
|
||||
break;
|
||||
case 8:
|
||||
result = "高级经营能力认证,试题Ⅳ:售后管理";
|
||||
break;
|
||||
case 9:
|
||||
result = "推广能力认证,试题Ⅰ:营销推广入门";
|
||||
break;
|
||||
case 10:
|
||||
result = "推广能力认证,试题Ⅱ:营销推广基础";
|
||||
break;
|
||||
case 11:
|
||||
result = "推广能力认证,试题Ⅲ:营销推广进阶";
|
||||
break;
|
||||
case 12:
|
||||
result = "推广能力认证,试题Ⅳ:多多进宝";
|
||||
break;
|
||||
case 13:
|
||||
result = "活动能力认证,试题Ⅰ:秒杀活动";
|
||||
break;
|
||||
case 14:
|
||||
result = "活动能力认证,试题Ⅱ:领券中心";
|
||||
break;
|
||||
case 15:
|
||||
result = "活动能力认证,试题Ⅲ:竞价";
|
||||
break;
|
||||
case 16:
|
||||
result = "活动能力认证,试题Ⅳ:报名活动注意事项";
|
||||
break;
|
||||
|
||||
}
|
||||
return Shop.ShopName+":"+result+ str;
|
||||
}
|
||||
}
|
||||
public class ShopQuestion
|
||||
{
|
||||
public ShopChatBase Shop;
|
||||
public string status;
|
||||
public List<QuestionKeyValue> satusList = new List<QuestionKeyValue>();
|
||||
}
|
||||
public class QuestionKeyValue
|
||||
{
|
||||
public int key;
|
||||
public int value;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* 纯API设置进宝
|
||||
* 肖俊
|
||||
* 2019-7-31
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Management.Instrumentation;
|
||||
using System.Net;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using AllBase;
|
||||
using JavaScriptEngineSwitcher.Core;
|
||||
using JavaScriptEngineSwitcher.V8;
|
||||
using Work.Api;
|
||||
using Work.CollectClass;
|
||||
|
||||
namespace Work.ManageClass
|
||||
{
|
||||
public class CpsShopNew
|
||||
{
|
||||
public static string Name;
|
||||
public static List<ShopChatBase> ShopTemp = new List<ShopChatBase>();
|
||||
public static int ThreadCount = 3;
|
||||
public static bool IsUseProxy = false;
|
||||
public static bool IsdayProduct = false;
|
||||
public static int dayProduct = 0;
|
||||
/// <summary>
|
||||
/// 是否正在模拟请求并休眠,如果是,将在SleepSim方法中继续休眠,拉开模拟请求间隔
|
||||
/// </summary>
|
||||
private static bool isSleepSim = false;
|
||||
|
||||
|
||||
public static bool ByCouponPercent = false;
|
||||
public static int ShopPerCent = 0, ShopPercentAll = 0,
|
||||
CouponAllCount = 0,
|
||||
CouponCount = 0,
|
||||
ConponDays = 0,
|
||||
SalsPrice1 = 0,
|
||||
SalsPrice11 = 0,
|
||||
CouponPrice1 = 0,
|
||||
SalsPrice2 = 0,
|
||||
SalsPrice22 = 0,
|
||||
CouponPrice2 = 0,
|
||||
SalsPrice3 = 0,
|
||||
SalsPrice33 = 0,
|
||||
CouponPrice3 = 0, CouponPercent = 0;
|
||||
}
|
||||
|
||||
public class CpsSetAllGoods
|
||||
{
|
||||
public static int discount;
|
||||
public static int day;
|
||||
public static int initQuantity;
|
||||
public static int userLimit;
|
||||
public static int Amount;
|
||||
public static string adslName;
|
||||
public static string adslPassWord;
|
||||
public static bool adslflag = false;
|
||||
public static List<CpsPriceRangeCoup> cpsPriceRangeCoupList = new List<CpsPriceRangeCoup>();
|
||||
public static bool isStop = false;
|
||||
|
||||
private AdslHelper adsl = null;
|
||||
private DateTime lasttime = DateTime.MinValue;
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取返回值
|
||||
/// </summary>
|
||||
/// <param name="response"></param>
|
||||
/// <returns></returns>
|
||||
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 class CpsPriceRangeCoup
|
||||
{
|
||||
public int MinPrice = 0;
|
||||
public int MaxPrice = 0;
|
||||
public int CoupPrice = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using AllBase;
|
||||
using Work.Api;
|
||||
using Work.CollectClass;
|
||||
|
||||
namespace Work.ManageClass
|
||||
{
|
||||
public class ShopSingleUpload
|
||||
{
|
||||
public string Name;
|
||||
public ShopChatBase Shop;
|
||||
public List<TaobaoProductBase> Product = new List<TaobaoProductBase>();
|
||||
public static bool TaobaoData = false, PinduoduoData = false, Sleep = false, NoSamePid = false, CreateNew = false, NoSoled = false;
|
||||
public static int VisitMax = 0;
|
||||
public static List<string> NoKeywords = new List<string>();
|
||||
public static List<string> HadShops = new List<string>();
|
||||
public static Dictionary<string, List<TaobaoProductBase>> ShopProductTemp = new Dictionary<string, List<TaobaoProductBase>>();
|
||||
public static Dictionary<string, List<TaobaoProductBase>> FissionTemp = new Dictionary<string, List<TaobaoProductBase>>();
|
||||
public ShopSingleUpload(string name, ShopChatBase shop)
|
||||
{
|
||||
Name = name;
|
||||
Shop = shop;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,938 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AllBase;
|
||||
using Work.Api;
|
||||
using Work.CollectClass;
|
||||
|
||||
namespace Work.ManageClass
|
||||
{
|
||||
public class UpPinduoduoProduct
|
||||
{
|
||||
public static string ExpressId = "";
|
||||
public static int NoReplaceDay = 0;
|
||||
public static int LimitBuy, GroupCount, LimitBuyTimes, AddPercent, AddPrice, SingleBuyAddPrice, BaseBuy, BaseBuyAdd, ThreadCount;
|
||||
public static bool RandAddPrice = false, CatSame = false, NoReplaceDays = false;
|
||||
public static Dictionary<long, DateTime> EditDayTemp = new Dictionary<long, DateTime>();
|
||||
public static Dictionary<int, Dictionary<string, PinduoduoPropBase>> PinduoduoProp = new Dictionary<int, Dictionary<string, PinduoduoPropBase>>();
|
||||
public static string Name;
|
||||
public static List<TaobaoProductBase> ProductTemp = new List<TaobaoProductBase>();
|
||||
public UpPinduoduoProduct(ShopChatBase shop,string name)
|
||||
{
|
||||
Shop = shop;
|
||||
Name = name;
|
||||
}
|
||||
public UpPinduoduoProduct()
|
||||
{
|
||||
}
|
||||
|
||||
public ShopChatBase Shop = null;
|
||||
/// <summary>
|
||||
/// 初始化属性名称
|
||||
/// </summary>
|
||||
public void IniProp(int mainCatId, string cookies)
|
||||
{
|
||||
if (PinduoduoProp.ContainsKey(mainCatId) && PinduoduoProp[mainCatId].Count > 0)
|
||||
return;
|
||||
Dictionary<string, PinduoduoPropBase> props = new Dictionary<string, PinduoduoPropBase>();
|
||||
PinduoduoApiPropId p = new PinduoduoApiPropId(Shop);
|
||||
string html = p.Get(mainCatId);
|
||||
var mm = BaseRegex.GetMatchRegex(ref html,
|
||||
@"\{""parent_spec_id"":([\d]+),""cat_id"":[\d]+,""parent_spec_name"":""([^""]+?)""");
|
||||
for (int j = 0; mm != null && j < mm.Count; j++)
|
||||
{
|
||||
PinduoduoPropBase pp = new PinduoduoPropBase();
|
||||
pp.Name = mm[j].Groups[2].Value;
|
||||
pp.Id = mm[j].Groups[1].Value;
|
||||
try
|
||||
{
|
||||
props.Add(pp.Name, pp);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
if (props.Count > 0)
|
||||
PinduoduoProp.Add(mainCatId, props);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
}
|
||||
if (props.Count > 0)
|
||||
return;
|
||||
|
||||
string url = "https://mms.pinduoduo.com/glide/v2/mms/query/spec/name/list";
|
||||
string refere = "https://mms.pinduoduo.com/Pdd.html";
|
||||
string data = "{}";
|
||||
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
|
||||
if (!string.IsNullOrEmpty(html) && html.Contains("过于频繁"))
|
||||
{
|
||||
Thread.Sleep(30 * 1000);
|
||||
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(html) && html.Contains("过于频繁"))
|
||||
{
|
||||
Thread.Sleep(30 * 1000);
|
||||
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(html) && html.Contains("过于频繁"))
|
||||
{
|
||||
//MessageBox.Show("请不要单个店铺同时开多个软件上传\r\n请调整", "提示");
|
||||
Thread.Sleep(60 * 1000);
|
||||
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(html) && html.Contains("过于频繁"))
|
||||
{
|
||||
Thread.Sleep(60 * 1000);
|
||||
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
|
||||
}
|
||||
|
||||
var m = BaseRegex.GetMatchRegex(ref html, @"""value"":""(.*?)""");
|
||||
for (int j = 0; m != null && j < m.Count; j++)
|
||||
{
|
||||
PinduoduoPropBase pp = new PinduoduoPropBase();
|
||||
pp.Name = m[j].Groups[1].Value;
|
||||
try
|
||||
{
|
||||
if (!props.ContainsKey(pp.Name))
|
||||
props.Add(pp.Name, pp);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
PinduoduoProp.Add(mainCatId, props);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动给无图片的SKU识别对应的图片
|
||||
/// </summary>
|
||||
/// <param name="p"></param>
|
||||
public void BuildSkuMapProps(ref ProductCollectBase p)
|
||||
{
|
||||
if (p.Props.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string cookies = Shop.Cookies;
|
||||
int mainCatId = Shop.MainCatId;
|
||||
int maxImageCut = 0, maxImageCount = 0;
|
||||
for (int i = 0; i < p.Props.Count; i++)
|
||||
{
|
||||
//if (p.Props[i].Values.Count <= 1 && p.from == "淘宝"&&p.cat_id != 3109)//只有一个属性的删除
|
||||
//{
|
||||
// p.Props.RemoveAt(i);
|
||||
// i--;
|
||||
// continue;
|
||||
//}
|
||||
for (int j = 0; j < p.Props[i].Values.Count; j++)
|
||||
{
|
||||
if ( p.Props[i].Values[j].name.Contains("代理"))
|
||||
p.Props[i].Values.RemoveAt(j);
|
||||
continue;
|
||||
}
|
||||
|
||||
int imageCount = 0;
|
||||
for (int j = 0; j < p.Props[i].Values.Count; j++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(p.Props[i].Values[j].image))
|
||||
imageCount++;
|
||||
|
||||
}
|
||||
if (imageCount > maxImageCount)
|
||||
{
|
||||
maxImageCount = imageCount;
|
||||
maxImageCut = i;
|
||||
}
|
||||
}
|
||||
if (p.Props.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string[] l = @"客服
|
||||
QQ
|
||||
定制品
|
||||
定制
|
||||
定金
|
||||
差价
|
||||
限量
|
||||
联系
|
||||
VX
|
||||
抽奖
|
||||
留言
|
||||
明式
|
||||
四季
|
||||
特价
|
||||
专拍
|
||||
补差
|
||||
尺寸
|
||||
价格
|
||||
客服
|
||||
运费到付
|
||||
发货
|
||||
直接拍
|
||||
运费险
|
||||
团购
|
||||
".Split('\n');
|
||||
for (int i = 0; i < p.SkuMaps.Count; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(p.SkuMaps[i].prop_image))
|
||||
{
|
||||
foreach (string s in l)
|
||||
{
|
||||
if (string.IsNullOrEmpty(s))
|
||||
continue;
|
||||
string m = s.Trim();
|
||||
BaseRegex.Relpace(ref p.SkuMaps[i].name, m, "");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
for (int j = 0; j < p.Props[maxImageCut].Values.Count; j++)
|
||||
{
|
||||
if (p.SkuMaps[i].name.Contains(p.Props[maxImageCut].Values[j].name))
|
||||
{
|
||||
p.SkuMaps[i].prop_image = p.Props[maxImageCut].Values[j].image;
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach (string s in l)
|
||||
{
|
||||
if (string.IsNullOrEmpty(s))
|
||||
continue;
|
||||
string m = s.Trim();
|
||||
BaseRegex.Relpace(ref p.SkuMaps[i].name, m, "");
|
||||
}
|
||||
|
||||
}
|
||||
int cut = 0;
|
||||
for (int i = 0; i < p.SkuMaps.Count; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(p.SkuMaps[i].prop_image))
|
||||
continue;
|
||||
p.SkuMaps[i].prop_image = p.Images[cut];
|
||||
cut++;
|
||||
if (cut >= p.Images.Count)
|
||||
cut = 0;
|
||||
}
|
||||
if (p.Props.Count > 2 && p.from == "淘宝")//两个属性以上,去掉一个
|
||||
{
|
||||
int minCount = 100, minCut = -1;
|
||||
for (int i = 0; i < p.Props.Count; i++)
|
||||
{
|
||||
if (p.Props[i].Values.Count < minCount && string.IsNullOrEmpty(p.Props[i].Values[0].image))
|
||||
{
|
||||
minCount = p.Props[i].Values.Count;
|
||||
minCut = i;
|
||||
}
|
||||
}
|
||||
if (minCut > -1)
|
||||
{
|
||||
p.Props.RemoveAt(minCut);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int cutId = 0;
|
||||
PinduoduoPropBase first = new PinduoduoPropBase();
|
||||
PinduoduoPropBase second = new PinduoduoPropBase();
|
||||
if (!PinduoduoProp.ContainsKey(mainCatId))
|
||||
{
|
||||
LogSave.Add(Name, "分类初始化异常,请重新打开软件");
|
||||
return;
|
||||
}
|
||||
for (int j = 0; j < p.Props.Count; j++)
|
||||
{
|
||||
foreach (KeyValuePair<string, PinduoduoPropBase> pb in PinduoduoProp[mainCatId])
|
||||
{
|
||||
if (cutId == 0)
|
||||
first = pb.Value;
|
||||
if (cutId == 1)
|
||||
second = pb.Value;
|
||||
if (pb.Key == p.Props[j].name)
|
||||
{
|
||||
p.Props[j].pinduoduo_name = pb.Key;
|
||||
if (p.cat_id != 3109 || (p.cat_id == 3109 && p.Props[j].pinduoduo_name != "容量"))
|
||||
p.Props[j].pinduoduo_id = pb.Value.Id;
|
||||
break;
|
||||
}
|
||||
cutId++;
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < p.Props.Count; j++)
|
||||
{
|
||||
foreach (KeyValuePair<string, PinduoduoPropBase> pb in PinduoduoProp[mainCatId])
|
||||
{
|
||||
if (string.IsNullOrEmpty(p.Props[j].pinduoduo_name) && p.Props[j].name.Contains(pb.Key))
|
||||
{
|
||||
p.Props[j].pinduoduo_name = pb.Key;
|
||||
if (p.cat_id != 3109||(p.cat_id == 3109 && p.Props[j].pinduoduo_name!="容量"))
|
||||
p.Props[j].pinduoduo_id = pb.Value.Id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (p.Props.Count == 1 && string.IsNullOrEmpty(p.Props[0].pinduoduo_name))
|
||||
{
|
||||
p.Props[0].pinduoduo_name = first.Name;
|
||||
p.Props[0].pinduoduo_id = first.Id;
|
||||
}
|
||||
else if (p.Props.Count == 2)
|
||||
{
|
||||
if (string.IsNullOrEmpty(p.Props[0].pinduoduo_name) &&
|
||||
string.IsNullOrEmpty(p.Props[1].pinduoduo_name))
|
||||
{
|
||||
p.Props[0].pinduoduo_name = first.Name;
|
||||
p.Props[0].pinduoduo_id = first.Id;
|
||||
p.Props[1].pinduoduo_name = second.Name;
|
||||
p.Props[1].pinduoduo_id = second.Id;
|
||||
}
|
||||
else if (string.IsNullOrEmpty(p.Props[0].pinduoduo_name))
|
||||
{
|
||||
if (p.Props[1].pinduoduo_name == first.Name)
|
||||
{
|
||||
p.Props[0].pinduoduo_name = second.Name;
|
||||
p.Props[0].pinduoduo_id = second.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
p.Props[0].pinduoduo_name = first.Name;
|
||||
p.Props[0].pinduoduo_id = first.Id;
|
||||
}
|
||||
}
|
||||
else if (string.IsNullOrEmpty(p.Props[1].pinduoduo_name))
|
||||
{
|
||||
if (p.Props[0].pinduoduo_name == first.Name)
|
||||
{
|
||||
p.Props[1].pinduoduo_name = second.Name;
|
||||
p.Props[1].pinduoduo_id = second.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
p.Props[1].pinduoduo_name = first.Name;
|
||||
p.Props[1].pinduoduo_id = first.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < p.Props.Count; i++)
|
||||
{
|
||||
if (p.cat3 == 3109 && p.Props[i].name.Contains("容量"))
|
||||
continue;
|
||||
string refere = "https://mms.pinduoduo.com/Pdd.html";
|
||||
if (string.IsNullOrEmpty(p.Props[i].pinduoduo_id) || p.Props[i].pinduoduo_id == "0")
|
||||
{
|
||||
string url = "https://mms.pinduoduo.com/glide/v2/mms/query/spec/by/name";
|
||||
string data = "{\"parent_id\":0,\"name\":\"" + p.Props[i].pinduoduo_name + "\"}";
|
||||
string html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
|
||||
string id = BaseRegex.GetLongJson(ref html, "result").ToString();
|
||||
if (id == "0")
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
|
||||
id = BaseRegex.GetLongJson(ref html, "spec_id").ToString();
|
||||
}
|
||||
if (id == "0")
|
||||
{
|
||||
LogSave.Add(Name, "获取类别ID异常:" + p.Props[i].pinduoduo_name);
|
||||
continue;
|
||||
}
|
||||
if (PinduoduoProp[mainCatId].ContainsKey(p.Props[i].pinduoduo_name))
|
||||
PinduoduoProp[mainCatId][p.Props[i].pinduoduo_name].Id = id;
|
||||
p.Props[i].pinduoduo_id = id;
|
||||
}
|
||||
|
||||
for (int j = 0; j < p.Props[i].Values.Count; j++)
|
||||
{
|
||||
//if (p.from_site_id == 1 && j > 12 && p.Props[i].Values.Count > 12)//属性元素超过15个的就丢弃
|
||||
//{
|
||||
// p.Props[i].Values.RemoveAt(j);
|
||||
// j--;
|
||||
// continue;
|
||||
//}
|
||||
foreach (string s in l)
|
||||
{
|
||||
if (string.IsNullOrEmpty(s))
|
||||
continue;
|
||||
string m = s.Trim();
|
||||
BaseRegex.Relpace(ref p.Props[i].Values[j].name, m, "");
|
||||
}
|
||||
|
||||
if (PinduoduoProp[mainCatId].ContainsKey(p.Props[i].pinduoduo_name) &&
|
||||
PinduoduoProp[mainCatId][p.Props[i].pinduoduo_name].Values.ContainsKey(p.Props[i].Values[j].name))
|
||||
{
|
||||
p.Props[i].Values[j].id =
|
||||
PinduoduoProp[mainCatId][p.Props[i].pinduoduo_name].Values[p.Props[i].Values[j].name].ToString();
|
||||
continue;
|
||||
}
|
||||
string html, propvid="";
|
||||
if (BaseClass.UseApiFirst)
|
||||
{
|
||||
PinduoduoApiPropId api = new PinduoduoApiPropId(Shop);
|
||||
html = api.GetPropId(p.Props[i].pinduoduo_id, p.Props[i].Values[j].name);
|
||||
propvid = BaseRegex.GetStringJson(ref html, "spec_id");
|
||||
if (string.IsNullOrEmpty(propvid))
|
||||
{
|
||||
string url = "https://mms.pinduoduo.com/glide/v2/mms/query/spec/by/name";
|
||||
string data = "{\"parent_id\":" + p.Props[i].pinduoduo_id + ",\"name\":\"" +
|
||||
p.Props[i].Values[j].name + "\"}";
|
||||
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
|
||||
propvid = BaseRegex.GetStringJson(ref html, "result");
|
||||
if (string.IsNullOrEmpty(propvid))
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
|
||||
propvid = BaseRegex.GetStringJson(ref html, "result");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string url = "https://mms.pinduoduo.com/glide/v2/mms/query/spec/by/name";
|
||||
string data = "{\"parent_id\":" + p.Props[i].pinduoduo_id + ",\"name\":\"" + p.Props[i].Values[j].name + "\"}";
|
||||
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
|
||||
if(html.Contains("规格名称字数过长"))
|
||||
{
|
||||
string title = p.Props[i].Values[j].name;
|
||||
if (BaseClass.GetCharLength(title) > 30)
|
||||
title = BaseClass.SubCharLength(title, 30);
|
||||
data = "{\"parent_id\":" + p.Props[i].pinduoduo_id + ",\"name\":\"" + title + "\"}";
|
||||
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
|
||||
}
|
||||
propvid = BaseRegex.GetStringJson(ref html, "result");
|
||||
if (string.IsNullOrEmpty(propvid))
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
|
||||
propvid = BaseRegex.GetStringJson(ref html, "result");
|
||||
}
|
||||
if (string.IsNullOrEmpty(propvid))
|
||||
{
|
||||
PinduoduoApiPropId api = new PinduoduoApiPropId(Shop);
|
||||
html = api.GetPropId(p.Props[i].pinduoduo_id, p.Props[i].Values[j].name);
|
||||
propvid = BaseRegex.GetStringJson(ref html, "spec_id");
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(propvid))
|
||||
{
|
||||
p.Props[i].Values.RemoveAt(j);
|
||||
j--;
|
||||
continue;
|
||||
}
|
||||
|
||||
p.Props[i].Values[j].id = propvid;
|
||||
try
|
||||
{
|
||||
PinduoduoProp[mainCatId][p.Props[i].pinduoduo_name].Values.Add(p.Props[i].Values[j].name, long.Parse(p.Props[i].Values[j].id));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void BuildSkuMapProps(ref ProductCollectBase prod, string cookies, int mainCatId)
|
||||
{
|
||||
if (prod.Props.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int maxImageCut = 0, maxImageCount = 0;
|
||||
for (int i = 0; i < prod.Props.Count; i++)
|
||||
{
|
||||
if (prod.Props[i].Values.Count <= 1 && prod.from == "淘宝")//只有一个属性的删除
|
||||
{
|
||||
prod.Props.RemoveAt(i);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
|
||||
int imageCount = 0;
|
||||
for (int j = 0; j < prod.Props[i].Values.Count; j++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(prod.Props[i].Values[j].image))
|
||||
imageCount++;
|
||||
}
|
||||
if (imageCount > maxImageCount)
|
||||
{
|
||||
maxImageCount = imageCount;
|
||||
maxImageCut = i;
|
||||
}
|
||||
}
|
||||
if (prod.Props.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < prod.SkuMaps.Count; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(prod.SkuMaps[i].prop_image))
|
||||
continue;
|
||||
for (int j = 0; j < prod.Props[maxImageCut].Values.Count; j++)
|
||||
{
|
||||
if (prod.SkuMaps[i].name.Contains(prod.Props[maxImageCut].Values[j].name))
|
||||
{
|
||||
prod.SkuMaps[i].prop_image = prod.Props[maxImageCut].Values[j].image;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
int cut = 0;
|
||||
for (int i = 0; i < prod.SkuMaps.Count; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(prod.SkuMaps[i].prop_image))
|
||||
continue;
|
||||
prod.SkuMaps[i].prop_image = prod.Images[cut];
|
||||
cut++;
|
||||
if (cut >= prod.Images.Count)
|
||||
cut = 0;
|
||||
}
|
||||
if (prod.Props.Count > 2 && prod.from == "淘宝")//两个属性以上,去掉一个
|
||||
{
|
||||
int minCount = 100, minCut = -1;
|
||||
for (int i = 0; i < prod.Props.Count; i++)
|
||||
{
|
||||
if (prod.Props[i].Values.Count < minCount && string.IsNullOrEmpty(prod.Props[i].Values[0].image))
|
||||
{
|
||||
minCount = prod.Props[i].Values.Count;
|
||||
minCut = i;
|
||||
}
|
||||
}
|
||||
if (minCut > -1)
|
||||
{
|
||||
prod.Props.RemoveAt(minCut);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int cutId = 0;
|
||||
PinduoduoPropBase first = new PinduoduoPropBase();
|
||||
PinduoduoPropBase second = new PinduoduoPropBase();
|
||||
if (!PinduoduoProp.ContainsKey(mainCatId))
|
||||
{
|
||||
LogSave.Add(Name, "分类初始化异常,请重新打开软件");
|
||||
return;
|
||||
}
|
||||
for (int j = 0; j < prod.Props.Count; j++)
|
||||
{
|
||||
foreach (KeyValuePair<string, PinduoduoPropBase> pb in PinduoduoProp[mainCatId])
|
||||
{
|
||||
if (cutId == 0)
|
||||
first = pb.Value;
|
||||
if (cutId == 1)
|
||||
second = pb.Value;
|
||||
if (pb.Key == prod.Props[j].name)
|
||||
{
|
||||
prod.Props[j].pinduoduo_name = pb.Key;
|
||||
prod.Props[j].pinduoduo_id = pb.Value.Id;
|
||||
break;
|
||||
}
|
||||
cutId++;
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < prod.Props.Count; j++)
|
||||
{
|
||||
foreach (KeyValuePair<string, PinduoduoPropBase> pb in PinduoduoProp[mainCatId])
|
||||
{
|
||||
if (string.IsNullOrEmpty(prod.Props[j].pinduoduo_name) && prod.Props[j].name.Contains(pb.Key))
|
||||
{
|
||||
prod.Props[j].pinduoduo_name = pb.Key;
|
||||
prod.Props[j].pinduoduo_id = pb.Value.Id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (prod.Props.Count == 1 && string.IsNullOrEmpty(prod.Props[0].pinduoduo_name))
|
||||
{
|
||||
prod.Props[0].pinduoduo_name = first.Name;
|
||||
prod.Props[0].pinduoduo_id = first.Id;
|
||||
}
|
||||
else if (prod.Props.Count == 2)
|
||||
{
|
||||
if (string.IsNullOrEmpty(prod.Props[0].pinduoduo_name) &&
|
||||
string.IsNullOrEmpty(prod.Props[1].pinduoduo_name))
|
||||
{
|
||||
prod.Props[0].pinduoduo_name = first.Name;
|
||||
prod.Props[0].pinduoduo_id = first.Id;
|
||||
prod.Props[1].pinduoduo_name = second.Name;
|
||||
prod.Props[1].pinduoduo_id = second.Id;
|
||||
}
|
||||
else if (string.IsNullOrEmpty(prod.Props[0].pinduoduo_name))
|
||||
{
|
||||
if (prod.Props[1].pinduoduo_name == first.Name)
|
||||
{
|
||||
prod.Props[0].pinduoduo_name = second.Name;
|
||||
prod.Props[0].pinduoduo_id = second.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
prod.Props[0].pinduoduo_name = first.Name;
|
||||
prod.Props[0].pinduoduo_id = first.Id;
|
||||
}
|
||||
}
|
||||
else if (string.IsNullOrEmpty(prod.Props[1].pinduoduo_name))
|
||||
{
|
||||
if (prod.Props[0].pinduoduo_name == first.Name)
|
||||
{
|
||||
prod.Props[1].pinduoduo_name = second.Name;
|
||||
prod.Props[1].pinduoduo_id = second.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
prod.Props[1].pinduoduo_name = first.Name;
|
||||
prod.Props[1].pinduoduo_id = first.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < prod.Props.Count; i++)
|
||||
{
|
||||
string refere = "https://mms.pinduoduo.com/Pdd.html";
|
||||
if (string.IsNullOrEmpty(prod.Props[i].pinduoduo_id) || prod.Props[i].pinduoduo_id == "0")
|
||||
{
|
||||
string url = "https://mms.pinduoduo.com/glide/v2/mms/query/spec/by/name";
|
||||
string data = "{\"parent_id\":0,\"name\":\"" + prod.Props[i].pinduoduo_name + "\"}";
|
||||
string html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
|
||||
string id = BaseRegex.GetLongJson(ref html, "result").ToString();
|
||||
if (id == "0")
|
||||
{
|
||||
Thread.Sleep(3000);
|
||||
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
|
||||
id = BaseRegex.GetLongJson(ref html, "spec_id").ToString();
|
||||
}
|
||||
if (id == "0")
|
||||
{
|
||||
LogSave.Add(Name, "获取类别ID异常:" + prod.Props[i].pinduoduo_name);
|
||||
continue;
|
||||
}
|
||||
if (PinduoduoProp[mainCatId].ContainsKey(prod.Props[i].pinduoduo_name))
|
||||
PinduoduoProp[mainCatId][prod.Props[i].pinduoduo_name].Id = id;
|
||||
prod.Props[i].pinduoduo_id = id;
|
||||
}
|
||||
|
||||
for (int j = 0; j < prod.Props[i].Values.Count; j++)
|
||||
{
|
||||
//if (prod.from_site_id == 1 && j >= 30 && prod.Props[i].Values.Count >= 30) // 属性元素超过30个的就丢弃
|
||||
//{
|
||||
// prod.Props[i].Values.RemoveAt(j);
|
||||
// j--;
|
||||
// continue;
|
||||
//}
|
||||
|
||||
if (PinduoduoProp[mainCatId].ContainsKey(prod.Props[i].pinduoduo_name) &&
|
||||
PinduoduoProp[mainCatId][prod.Props[i].pinduoduo_name].Values.ContainsKey(prod.Props[i].Values[j].name))
|
||||
{
|
||||
prod.Props[i].Values[j].id =
|
||||
PinduoduoProp[mainCatId][prod.Props[i].pinduoduo_name].Values[prod.Props[i].Values[j].name].ToString();
|
||||
continue;
|
||||
}
|
||||
PinduoduoApiPropId api = new PinduoduoApiPropId(Shop);
|
||||
string html = api.GetPropId(prod.Props[i].pinduoduo_id, prod.Props[i].Values[j].name);
|
||||
string propvid = BaseRegex.GetStringJson(ref html, "spec_id");
|
||||
if (!string.IsNullOrEmpty(propvid))
|
||||
{
|
||||
prod.Props[i].Values[j].id = propvid;
|
||||
try
|
||||
{
|
||||
PinduoduoProp[mainCatId][prod.Props[i].pinduoduo_name].Values.Add(prod.Props[i].Values[j].name, long.Parse(prod.Props[i].Values[j].id));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
continue;
|
||||
}
|
||||
string url = "https://mms.pinduoduo.com/glide/v2/mms/query/spec/by/name";
|
||||
string data = "{\"parent_id\":" + prod.Props[i].pinduoduo_id + ",\"name\":\"" + prod.Props[i].Values[j].name + "\"}";
|
||||
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
|
||||
propvid = BaseRegex.GetStringJson(ref html, "result");
|
||||
if (string.IsNullOrEmpty(propvid))
|
||||
{
|
||||
Thread.Sleep(3000);
|
||||
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
|
||||
propvid = BaseRegex.GetStringJson(ref html, "result");
|
||||
}
|
||||
if (string.IsNullOrEmpty(propvid))
|
||||
{
|
||||
prod.Props[i].Values.RemoveAt(j);
|
||||
j--;
|
||||
continue;
|
||||
}
|
||||
|
||||
prod.Props[i].Values[j].id = propvid;
|
||||
try
|
||||
{
|
||||
PinduoduoProp[mainCatId][prod.Props[i].pinduoduo_name].Values.Add(prod.Props[i].Values[j].name, long.Parse(prod.Props[i].Values[j].id));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public static Dictionary<string, int> PriceTemp = new Dictionary<string, int>();
|
||||
public static int GetNewPrice(decimal beforePrice, int addPercent, int addPrice, long pid, int addSinglePrice, decimal maxPrice)
|
||||
{
|
||||
//if (UserStepPrice)
|
||||
//{
|
||||
// int p = (int)(beforePrice * 100) + PriceAllAdd*100;
|
||||
// if (beforePrice >= PriceBefor1 && beforePrice <= PriceEnd1)
|
||||
// return p + PriceAdd1 * 100;
|
||||
// if (beforePrice >= PriceBefor2 && beforePrice <= PriceEnd2)
|
||||
// return p + PriceAdd2 * 100;
|
||||
// if (beforePrice >= PriceBefor3 && beforePrice <= PriceEnd3)
|
||||
// return p + PriceAdd3 * 100;
|
||||
// if (beforePrice >= PriceBefor4 && beforePrice <= PriceEnd4)
|
||||
// return p + PriceAdd4 * 100;
|
||||
// if (beforePrice >= PriceBefor5 && beforePrice <= PriceEnd5)
|
||||
// return p + PriceAdd5 * 100;
|
||||
//}
|
||||
|
||||
if (beforePrice < 1)
|
||||
beforePrice = maxPrice;
|
||||
if (beforePrice < 1)
|
||||
beforePrice = 10000;
|
||||
int before = (int)(beforePrice * 100);
|
||||
string key = pid + "," + before + "," + addPercent + "," + addPrice + "," + addSinglePrice;
|
||||
int price;
|
||||
if (PriceTemp.ContainsKey(key))
|
||||
{
|
||||
price = PriceTemp[key];
|
||||
return price;
|
||||
}
|
||||
//if (addSinglePrice == 0)
|
||||
// {
|
||||
price = before * (100 + addPercent) / 100 + addPrice * 100 + (RandAddPrice ? new Random(Guid.NewGuid().GetHashCode()).Next(10, 90) : 0);
|
||||
// }
|
||||
// else
|
||||
// price = (int)((beforePrice + addSinglePrice) * 100) + (RandAddPrice ? new Random(Guid.NewGuid().GetHashCode()).Next(10, 90) : 0);
|
||||
try
|
||||
{
|
||||
PriceTemp.Add(key, price);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return price;
|
||||
}
|
||||
|
||||
public static string UploadImage(byte[] img)
|
||||
{
|
||||
return UploadImage(img, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上传图片
|
||||
/// </summary>
|
||||
/// <param name="img"></param>
|
||||
/// <returns></returns>
|
||||
public static string UploadImage(byte[] img, ShopChatBase Shop)
|
||||
{
|
||||
PinduoduoApiGetProduct p = new PinduoduoApiGetProduct(Shop);
|
||||
string html = p.UploadImage(img);
|
||||
string imgUrl = BaseRegex.GetStringJson(ref html, "image_url");
|
||||
if (string.IsNullOrEmpty(imgUrl))
|
||||
{
|
||||
string Cookies = Shop.Cookies;
|
||||
string url = "https://mms.pinduoduo.com/earth/api/upload/getSignature";
|
||||
string refere = "https://mms.pinduoduo.com/goods/goods_add/index?id=5146155709&type=edit&from=category";
|
||||
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, "{}", Cookies);
|
||||
string sign = BaseRegex.GetStringJson(ref html, "signature");
|
||||
if (string.IsNullOrEmpty(sign))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
string data =
|
||||
"{\"upload_sign\":\"" + sign + "\",\"image\":\"data:image/jpeg;base64," +
|
||||
Convert.ToBase64String(img) + "\"}";
|
||||
url = "https://file.yangkeduo.com/v2/store_image";
|
||||
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Cookies);
|
||||
imgUrl = BaseRegex.GetStringJson(ref html, "url");
|
||||
LogSave.Add(Name, "上传图片:" + imgUrl);
|
||||
return imgUrl;
|
||||
}
|
||||
return imgUrl;
|
||||
}
|
||||
|
||||
|
||||
public static Dictionary<string, int> TypeName = new Dictionary<string, int>();
|
||||
public static Dictionary<string, int> TypeValues = new Dictionary<string, int>();
|
||||
private static int firstKeyId = 0, firstValueId = 0;
|
||||
public static string AddType(ref ProductCollectBase p, int mainCatId, string cookies, int mallId)
|
||||
{
|
||||
if (mainCatId == 5)
|
||||
{
|
||||
if (TypeName.Count == 0)
|
||||
{
|
||||
string url = "https://mms.pinduoduo.com/malls/" + mallId + "/transport/glide/query/clothes_fabric/list";
|
||||
string refere = "https://mms.pinduoduo.com/Pdd.html";
|
||||
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, "{}", cookies);
|
||||
var m = BaseRegex.GetMatchRegex(ref html, @"""code"":([\d]+),""desc"":""(.*?)""");
|
||||
for (int i = 0; m != null && i < m.Count; i++)
|
||||
{
|
||||
string name = m[i].Groups[2].Value;
|
||||
int value = int.Parse(m[i].Groups[1].Value);
|
||||
if (firstKeyId == 0)
|
||||
firstKeyId = value;
|
||||
if (!TypeName.ContainsKey(name))
|
||||
TypeName.Add(name, value);
|
||||
}
|
||||
}
|
||||
if (TypeValues.Count == 0)
|
||||
{
|
||||
string url = "https://mms.pinduoduo.com/malls/" + mallId + "/transport/glide/query/clothes_fabric_content/list";
|
||||
string refere = "https://mms.pinduoduo.com/Pdd.html";
|
||||
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, "{}", cookies);
|
||||
var m = BaseRegex.GetMatchRegex(ref html, @"""code"":([\d]+),""desc"":""(.*?)""");
|
||||
for (int i = 0; m != null && i < m.Count; i++)
|
||||
{
|
||||
string name = m[i].Groups[2].Value;
|
||||
int value = int.Parse(m[i].Groups[1].Value);
|
||||
if (firstValueId == 0)
|
||||
firstValueId = value;
|
||||
if (!TypeValues.ContainsKey(name))
|
||||
TypeValues.Add(name, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mainCatId == 5)
|
||||
{
|
||||
string name = "材质成分";
|
||||
string value = "";
|
||||
for (int i = 0; i < p.Prop.Count; i++)
|
||||
{
|
||||
if (p.Prop[i].Key == name)
|
||||
{
|
||||
value = p.Prop[i].Value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int keyId = 0, valueId = 0;
|
||||
if (!string.IsNullOrEmpty(value) && value.Contains("%"))
|
||||
{
|
||||
string v = BaseRegex.GetMatchRegexString(ref value, @"([\d]+)%");
|
||||
string namex = value.Substring(0, value.IndexOf(v + "%"));
|
||||
if (string.IsNullOrEmpty(v) || string.IsNullOrEmpty(namex))
|
||||
{
|
||||
goto NoValue;
|
||||
}
|
||||
int pe = int.Parse(v);
|
||||
|
||||
foreach (KeyValuePair<string, int> k in TypeName)
|
||||
{
|
||||
if (k.Key.Contains(namex) || namex.Contains(k.Key))
|
||||
{
|
||||
keyId = k.Value;
|
||||
foreach (KeyValuePair<string, int> vv in TypeValues)
|
||||
{
|
||||
var mm = BaseRegex.GetMatchRegex(vv.Key, @"([\d]+)%");
|
||||
if (mm.Count == 2)
|
||||
{
|
||||
int min = int.Parse(mm[0].Groups[1].Value);
|
||||
int max = int.Parse(mm[1].Groups[1].Value);
|
||||
if (pe >= min && pe <= max)
|
||||
{
|
||||
valueId = vv.Value;
|
||||
goto NoValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
NoValue:
|
||||
if (keyId == 0)
|
||||
keyId = firstKeyId;
|
||||
if (valueId == 0)
|
||||
valueId = firstValueId;
|
||||
string addContent = ",\"fabric\":" + keyId + ",\"fabric_content\":" + valueId;
|
||||
return addContent;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下架产品
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public static bool SetOffLine(long id, ShopChatBase shop)
|
||||
{
|
||||
string cookies = shop == null ? "" : shop.Cookies;
|
||||
PinduoduoApiGetProduct api = new PinduoduoApiGetProduct(shop);
|
||||
api.Name = Name;
|
||||
string html = api.SetOnline(id, false);
|
||||
//string data = "{\"goods_id\":" + id + "}";
|
||||
string urlx = "https://mms.pinduoduo.com/vodka/v2/mms/batchOffSale";
|
||||
string refere = "https://mms.pinduoduo.com/Pdd.html";
|
||||
//string html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, cookies);
|
||||
if (string.IsNullOrEmpty(html) || html.Contains("过于频繁"))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(html) && html.Contains("过于频繁"))
|
||||
{
|
||||
LogSave.Add(Name, "速度太快,休眠2-5分钟");
|
||||
Thread.Sleep(100 * 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogSave.Add(Name, "不能下架");
|
||||
return false;
|
||||
}
|
||||
html = api.SetOnline(id, false);
|
||||
}
|
||||
if (string.IsNullOrEmpty(html) || html.Contains("过于频繁"))
|
||||
{
|
||||
Thread.Sleep(100 * 1000);
|
||||
html = api.SetOnline(id, false);
|
||||
}
|
||||
if (string.IsNullOrEmpty(html) || html.Contains("过于频繁"))
|
||||
{
|
||||
Thread.Sleep(100 * 1000);
|
||||
LogSave.Add(Name, "下架产品失败:" + id);
|
||||
return false;
|
||||
}
|
||||
if (html.Contains("使用MMS后台做此"))
|
||||
{
|
||||
if (string.IsNullOrEmpty(PinduoduoAuth.strContent))
|
||||
{
|
||||
PinduoduoAuth.strContent = GetVisitProductNew.strJs;//FileBase.ReadAllText(path);
|
||||
}
|
||||
string NoCode = "";
|
||||
string strTime = BaseClass.GetTime(DateTime.Now).ToString() + "000";
|
||||
if (string.IsNullOrEmpty(NoCode))
|
||||
{
|
||||
string htmlx = GetHtml.Gbk("http://nano.qixiaoke.com/nano.txt");
|
||||
NoCode = BaseRegex.GetMatchRegexString(ref htmlx, @"([\w\W]+?)-----");
|
||||
}
|
||||
string fun2 = string.Format(@"getEncode('{0}','{1}','{2}')", strTime, NoCode, "");
|
||||
string codex = UploadPinduoduoSet.ExecuteScript(fun2, PinduoduoAuth.strContent);
|
||||
|
||||
string data = "{\"goodsId\":" + id + ",\"crawlerInfo\":\"" + codex + "\"}";
|
||||
html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, cookies);
|
||||
}
|
||||
LogSave.Add(Name, "下架产品成功:" + id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class PinduoduoPropBase
|
||||
{
|
||||
public string Name;
|
||||
public string Id;
|
||||
public Dictionary<string, long> Values = new Dictionary<string, long>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using AllBase;
|
||||
using Work.CollectClass;
|
||||
using Work.Api;
|
||||
using Work.ManageClass;
|
||||
|
||||
namespace Work.ManageClass
|
||||
{
|
||||
public class UpPinduoduoProductSet
|
||||
{
|
||||
public static Dictionary<long, ProductCollectBase> TaobaoProductTemp = new Dictionary<long, ProductCollectBase>();
|
||||
public static Dictionary<long, KeyValuesBase> CatTemp = new Dictionary<long, KeyValuesBase>();
|
||||
public static Dictionary<string, ImageUrlBase> ImageTemp = new Dictionary<string, ImageUrlBase>();
|
||||
public string Name, Cookies = "", Message = "";
|
||||
public static string strContent = "";
|
||||
public static bool RandomProps = false, TitleExploder = false, Shield = false, SaveAllImage = false, Relation = false;
|
||||
public bool FullToday = false, Punish = false, Success = false;
|
||||
public int MainCatId = 0;
|
||||
public TaobaoProductBase p;
|
||||
public TaobaoProductBase t;
|
||||
public TaobaoProductBase mt = null;
|
||||
public ShopChatBase Shop = null;
|
||||
public string brandName;
|
||||
public UpPinduoduoProductSet(string name, TaobaoProductBase P, TaobaoProductBase T)
|
||||
{
|
||||
Name = name;
|
||||
p = P;
|
||||
t = T;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加商品图片到到缓存
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
public static void AddImage(string key, string url, int width, int height)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
return;
|
||||
if (ImageTemp.ContainsKey(key) && url.Contains("http:"))
|
||||
ImageTemp[key] = new ImageUrlBase(url, width, height);
|
||||
if (ImageTemp.ContainsKey(key) || string.IsNullOrEmpty(key) || string.IsNullOrEmpty(url))
|
||||
return;
|
||||
try
|
||||
{
|
||||
ImageTemp.Add(key, new ImageUrlBase(url, width, height));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<string, int> PriceTemp = new Dictionary<string, int>();
|
||||
}
|
||||
|
||||
public class ImageUrlBase
|
||||
{
|
||||
public ImageUrlBase(string url, int w, int h)
|
||||
{
|
||||
Url = url;
|
||||
Width = w;
|
||||
Height = h;
|
||||
}
|
||||
|
||||
public string Url;
|
||||
public int Width;
|
||||
public int Height;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AllBase;
|
||||
using Work.Api;
|
||||
using Work.CollectClass;
|
||||
|
||||
namespace Work.ManageClass
|
||||
{
|
||||
public class UploadProductAllShop
|
||||
{
|
||||
public static List<TaobaoProductBase> Products = new List<TaobaoProductBase>();
|
||||
public static List<TaobaoProductBase> ProductTemp = new List<TaobaoProductBase>();
|
||||
public static int ThreadCount = 0, AddMinutes = 10, UserMainImage = 0;
|
||||
public static bool Running = false, AutoUpload = false, OnlyFree = false, UpToDown = false, FissionSameShop = false, ReplaceModel = false, ReplaceVisitMax = false;
|
||||
public static DateTime CreateTime = DateTime.Today.AddDays(-1), UpDate = DateTime.Today.AddDays(-1);
|
||||
public static Dictionary<string, List<long>> JustUpload = new Dictionary<string, List<long>>();
|
||||
public string Name;
|
||||
|
||||
public UploadProductAllShop(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user