模拟提交商品,测试最多能传50件左右就会出限制

This commit is contained in:
wule committed 2025-09-15 10:36:48 +08:00
1 parent 6639224771
commit 6509233208
37 files changed
+2576 -450

No files matched your search

@@ -46,35 +46,104 @@ namespace TemuKJD.PDDForms.ShopForms
var sourceShop = shop;
var sourceProdId = prodId;
string success_err_msg = "";
string errorMsg = "";
var html = GetProdCommitId(sourceShop, sourceProdId.ToString());
if (!html.Contains("\"success\":true") || !html.Contains("\"result\""))
//string errorMsg = "";
var commit_id_rst = GetPddProdCommitId(sourceShop, sourceProdId.ToString());
if (!commit_id_rst.Contains("\"success\":true") || !commit_id_rst.Contains("\"result\""))
{
var errMsg = BaseRegex.GetStringJson(ref html, "error_msg");
var errMsg = BaseRegex.GetStringJson(ref commit_id_rst, "error_msg");
if (string.IsNullOrEmpty(errMsg))
errMsg = html;
errMsg = commit_id_rst;
OnInfoReceived("商品获取失败!" + errMsg);
return;
}
var commitId = BaseRegex.GetStringJson(ref html, "goods_commit_id");
var commitId = BaseRegex.GetStringJson(ref commit_id_rst, "goods_commit_id");
if (string.IsNullOrEmpty(commitId))
{
OnInfoReceived("商品获取失败!商品提交编号获取失败!");
return;
}
html = GetPddProduct(sourceShop, sourceProdId.ToString(), commitId);
JObject obj = JObject.Parse(html);
var result = JsonHelper.SerializeObject(obj["result"]);
var sizeRst = "";
PDDProductDetailInfo product = JsonHelper.DeserializeJsonToObject<PDDProductDetailInfo>(result);
if (product == null)
var detail_json = "{}";
PDDProductDetailInfo product = null;
try
{
OnInfoReceived("商品获取失败!商品数据格式获取失败!");
var prod_detail_rst = GetPddProdDetail(sourceShop, sourceProdId.ToString(), commitId);
JObject prod_detail_obj = JObject.Parse(prod_detail_rst);
detail_json = JsonHelper.SerializeObject(prod_detail_obj["result"]);
product = JsonHelper.DeserializeJsonToObject<PDDProductDetailInfo>(detail_json);
if (product == null)
{
OnInfoReceived("商品获取失败!商品数据格式获取失败!");
return;
}
}
catch (Exception ex) { }
var property_json = "{}";
PDDProductPropertyInfo property = null;
try
{
var prod_property_rst = GetPddProdProperty(sourceShop, sourceProdId.ToString(), commitId);
prod_property_rst = GetHtml.Unicode2String(prod_property_rst);
JObject prod_property_obj = JObject.Parse(prod_property_rst);
property_json = JsonHelper.SerializeObject(prod_property_obj["result"]);
property = JsonHelper.DeserializeJsonToObject<PDDProductPropertyInfo>(property_json);
}
catch (Exception ex) { }
if (property == null)
{
OnInfoReceived("商品获取失败!商品属性获取失败!");
return;
}
//尺码表注释
var decoration_json = "{}";
PDDProductDecorationInfo decoration = null;
try
{
var prod_decoration_rst = GetPddProdDecoration(sourceShop, sourceProdId.ToString(), commitId);
if (!prod_decoration_rst.Contains("\"success\":true"))
{
var errMsg = BaseRegex.GetStringJson(ref prod_decoration_rst, "error_msg");
if (string.IsNullOrEmpty(errMsg))
errMsg = commit_id_rst;
OnInfoReceived("商品获取失败!商品详情图获取失败!" + errMsg);
return;
}
JObject prod_decoration_obj = JObject.Parse(prod_decoration_rst);
if (!prod_decoration_obj["result"].IsNullOrEmpty())
decoration_json = JsonHelper.SerializeObject(prod_decoration_obj["result"]);
decoration = JsonHelper.DeserializeJsonToObject<PDDProductDecorationInfo>(decoration_json);
}
catch (Exception ex)
{
OnInfoReceived("商品获取失败!商品详情图获取失败!" + ex.Message);
return;
}
if (decoration == null)
{
OnInfoReceived("商品获取失败!商品详情图获取失败!");
return;
}
// 属性模板暂时注释
//var prop_template_json = "{}";
//PDDProductTemplateInfo templateInfo = null;
//try
//{
// var prop_template_rst = GetPddCatPropTemplate(sourceShop, product.cat_id.ParseToString(), sourceProdId.ToString(), commitId);
// JObject prop_template_obj = JObject.Parse(prop_template_rst);
// prop_template_json = JsonHelper.SerializeObject(prop_template_obj["result"]);
// templateInfo = JsonHelper.DeserializeJsonToObject<PDDProductTemplateInfo>(prop_template_json);
//}
//catch (Exception ex) { }
//if (templateInfo == null)
//{
// OnInfoReceived("商品获取失败!商品属性模板获取失败!");
// return;
//}
var sizeRst = "";
//尺码表暂时注释
//if (product.sizeTemplateId > 0)
//{
// html = SizeSpecQuery(shop1, prodId1.ToString(), product.sizeTemplateId.ToString());
@@ -92,7 +161,7 @@ namespace TemuKJD.PDDForms.ShopForms
bool isExist = false;
var existUrl = BaseClass.BuildObjString("product/get_product_list");
string existData = UserLogin.GetSignaturex() + "&search_spu=" + product.goods_id;
html = GetHtml.PostUtf8(existUrl, existData);
string html = GetHtml.PostUtf8(existUrl, existData);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(existUrl, existData);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
@@ -103,7 +172,8 @@ namespace TemuKJD.PDDForms.ShopForms
isExist = true;
}
var main_img = product.image_url;
string product_json = "{\"detail\":" + detail_json + ",\"decoration\":" + decoration_json + ",\"property\":" + property_json + "}";
string main_img = product.image_url;
if (string.IsNullOrEmpty(main_img))
main_img = product.hd_thumb_url;
if (string.IsNullOrEmpty(main_img))
@@ -134,7 +204,7 @@ namespace TemuKJD.PDDForms.ShopForms
"&cat_name=" + HttpUtility.UrlEncode((product.cats?.LastOrDefault(c => !string.IsNullOrEmpty(c))).ParseToString(), Encoding.UTF8) +
"&ext_code=" + HttpUtility.UrlEncode(product.out_goods_sn, Encoding.UTF8) +
"&product_name=" + HttpUtility.UrlEncode(product.goods_name, Encoding.UTF8) +
"&product_json=" + HttpUtility.UrlEncode(result, Encoding.UTF8) +
"&product_json=" + HttpUtility.UrlEncode(product_json, Encoding.UTF8) +
"&size_json=" + HttpUtility.UrlEncode(sizeRst, Encoding.UTF8) +
"&main_img=" + HttpUtility.UrlEncode(main_img, Encoding.UTF8);
@@ -218,7 +288,7 @@ namespace TemuKJD.PDDForms.ShopForms
var sourceProdId = prodId;
string success_err_msg = "";
string errorMsg = "";
var html = GetProdCommitId(sourceShop, sourceProdId.ToString());
var html = GetPddProdCommitId(sourceShop, sourceProdId.ToString());
if (!html.Contains("\"success\":true") || !html.Contains("\"result\""))
{
var errMsg = BaseRegex.GetStringJson(ref html, "error_msg");
@@ -233,7 +303,7 @@ namespace TemuKJD.PDDForms.ShopForms
OnInfoReceived("商品获取失败!商品提交编号获取失败!");
return;
}
html = GetPddProduct(sourceShop, sourceProdId.ToString(), commitId);
html = GetPddProdDetail(sourceShop, sourceProdId.ToString(), commitId);
JObject obj = JObject.Parse(html);
var result = JsonHelper.SerializeObject(obj["result"]);
@@ -245,7 +315,7 @@ namespace TemuKJD.PDDForms.ShopForms
return;
}
//拼多多暂时注释
//拼多多暂时注释尺码
//if (product.sizeTemplateId > 0)
//{
// html = SizeSpecQuery(sourceShop, sourceProdId.ToString(), product.sizeTemplateId.ToString());
@@ -380,24 +450,109 @@ namespace TemuKJD.PDDForms.ShopForms
private string GetProdCommitId(ShopLoginInfo shop, string prodId)
{
string url = "https://mms.pinduoduo.com/glide/v2/mms/edit/commit/create_by_sn";
string body = @"{""goods_id"":" + prodId + "}";
string refere = "https://mms.pinduoduo.com/goods/goods_list?msfrom=mms_sidenav";
var result = HttpResponseBLL.PDDPostResponse(shop, url, body, refere, shop.AntiContents.LastOrDefault().ParseToString());
return result;
}
private string GetPddProduct(ShopLoginInfo shop, string prodId, string commitId)
private string GetPddProdCommitId(ShopLoginInfo shop, string prodId)
{
var anti = shop.AntiContents.LastOrDefault().ParseToString();
if (shop.AntiContents.Count > 0)
anti = shop.AntiContents[Randomx.GetId(shop.AntiContents.Count)];
string url = "https://mms.pinduoduo.com/glide/v2/mms/edit/commit/create_by_sn";
string body = @"{""goods_id"":" + prodId + "}";
string refere = "https://mms.pinduoduo.com/goods/goods_list?msfrom=mms_sidenav";
var result = HttpResponseBLL.PDDPostResponse(shop, url, body, refere, anti);
for (int i = 0; i < 5 && result.Contains("网络繁忙,请不要频繁操作"); i++)
{
shop.AntiContents.Remove(anti);
anti = shop.AntiContents.FirstOrDefault().ParseToString();
if (shop.AntiContents.Count > 0)
{
Thread.Sleep(Randomx.GetId(300, 500));
anti = shop.AntiContents[Randomx.GetId(shop.AntiContents.Count)];
result = HttpResponseBLL.PDDPostResponse(shop, url, body, refere, anti);
}
}
return result;
}
private string GetPddProdDetail(ShopLoginInfo shop, string prodId, string commitId)
{
var anti = shop.AntiContents.LastOrDefault().ParseToString();
if (shop.AntiContents.Count > 0)
anti = shop.AntiContents[Randomx.GetId(shop.AntiContents.Count)];
//string url = "https://mms.pinduoduo.com/glide/v2/mms/query/commit/on_shop/detail"; //on_shop获取到的结构不对
string url = "https://mms.pinduoduo.com/glide/v2/mms/query/commit/detail";
//string body = @"{""goods_id"":" + prodId + "}";
string body = @"{""goods_commit_id"":""" + commitId + @""",""goods_id"":""" + prodId + @"""}";
string refere = "https://mms.pinduoduo.com/goods/goods_add/index?id=" + commitId + "&goods_id=" + prodId + "&type=edit";
var result = HttpResponseBLL.PDDPostResponse(shop, url, body, refere, anti);
for (int i = 0; i < 2 && result.Contains("网络繁忙,请不要频繁操作"); i++)
for (int i = 0; i < 5 && result.Contains("网络繁忙,请不要频繁操作"); i++)
{
shop.AntiContents.Remove(anti);
anti = shop.AntiContents.FirstOrDefault().ParseToString();
if (shop.AntiContents.Count > 0)
{
Thread.Sleep(Randomx.GetId(300, 500));
anti = shop.AntiContents[Randomx.GetId(shop.AntiContents.Count)];
result = HttpResponseBLL.PDDPostResponse(shop, url, body, refere, anti);
}
}
return result;
}
private string GetPddProdProperty(ShopLoginInfo shop, string prodId, string commitId)
{
var anti = shop.AntiContents.LastOrDefault().ParseToString();
if (shop.AntiContents.Count > 0)
anti = shop.AntiContents[Randomx.GetId(shop.AntiContents.Count)];
string url = "https://mms.pinduoduo.com/draco-ms/mms/query-goods-property";
string body = @"{""goods_id"":" + prodId + "}";
string refere = "https://mms.pinduoduo.com/goods/goods_add/index?id=" + commitId + "&goods_id=" + prodId + "&type=edit";
var result = HttpResponseBLL.PDDPostResponse(shop, url, body, refere, anti);
for (int i = 0; i < 5 && result.Contains("网络繁忙,请不要频繁操作"); i++)
{
shop.AntiContents.Remove(anti);
anti = shop.AntiContents.FirstOrDefault().ParseToString();
if (shop.AntiContents.Count > 0)
{
Thread.Sleep(Randomx.GetId(300, 500));
anti = shop.AntiContents[Randomx.GetId(shop.AntiContents.Count)];
result = HttpResponseBLL.PDDPostResponse(shop, url, body, refere, anti);
}
}
return result;
}
private string GetPddProdDecoration(ShopLoginInfo shop, string prodId, string commitId)
{
var anti = shop.AntiContents.LastOrDefault().ParseToString();
if (shop.AntiContents.Count > 0)
anti = shop.AntiContents[Randomx.GetId(shop.AntiContents.Count)];
string url = "https://mms.pinduoduo.com/gorse/mms/goods/decoration/commit/query/V2";
string body = @"{""goods_commit_id"":" + commitId + @",""goods_id"":" + prodId + @"}";
string refere = "https://mms.pinduoduo.com/goods/goods_add/index?id=" + commitId + "&goods_id=" + prodId + "&type=edit";
var result = HttpResponseBLL.PDDPostResponse(shop, url, body, refere, anti);
for (int i = 0; i < 5 && result.Contains("网络繁忙,请不要频繁操作"); i++)
{
shop.AntiContents.Remove(anti);
anti = shop.AntiContents.FirstOrDefault().ParseToString();
if (shop.AntiContents.Count > 0)
{
Thread.Sleep(Randomx.GetId(300, 500));
anti = shop.AntiContents[Randomx.GetId(shop.AntiContents.Count)];
result = HttpResponseBLL.PDDPostResponse(shop, url, body, refere, anti);
}
}
return result;
}
private string GetPddCatPropTemplate(ShopLoginInfo shop, string catId, string prodId, string commitId)
{
var anti = shop.AntiContents.LastOrDefault().ParseToString();
if (shop.AntiContents.Count > 0)
anti = shop.AntiContents[Randomx.GetId(shop.AntiContents.Count)];
string url = "https://mms.pinduoduo.com/draco-ms/mms/template/mall?catId=" + catId +
"&goodsCommitId=" + commitId + "&goodsId=" + prodId;
string body = @"";
string refere = "https://mms.pinduoduo.com/goods/goods_add/index?type=add&from=category&id=" + commitId +
"&goods_id=" + prodId + "&sourcePage=goodsList";
var result = HttpResponseBLL.PDDGetResponse(shop, url, body, refere, anti);
for (int i = 0; i < 5 && (result.Contains("操作太过频繁") || result.Contains("网络繁忙,请不要频繁操作")); i++)
{
shop.AntiContents.Remove(anti);
anti = shop.AntiContents.LastOrDefault().ParseToString();
@@ -405,7 +560,7 @@ namespace TemuKJD.PDDForms.ShopForms
{
Thread.Sleep(Randomx.GetId(300, 500));
anti = shop.AntiContents[Randomx.GetId(shop.AntiContents.Count)];
result = HttpResponseBLL.PDDPostResponse(shop, url, body, refere, anti);
result = HttpResponseBLL.PDDGetResponse(shop, url, body, refere, anti);
}
}
return result;
+1
View File
@@ -625,6 +625,7 @@
this.colUpdateCookies.ReadOnly = true;
this.colUpdateCookies.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.colUpdateCookies.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
this.colUpdateCookies.Visible = false;
//
// colCopyCookies
//
+19 -18
View File
@@ -647,24 +647,24 @@ namespace TemuKJD.PDDForms.ShopForms
sc.LastRefreshDate = DateTime.Now.ToString("yyyyMMdd");
}
}
loginResult = PDDShopListForm.GetShopStatus2(shop);
if (!loginResult.Contains("\"success\":true"))
{
shop.Cookies2 = "empty=true;";
foreach (var sc in campanys)
{
sc.LoginStatus2 = "国际版未登录";
sc.Cookies2 = "empty=true;";
}
}
else
{
foreach (var sc in campanys)
{
sc.LoginStatus2 = "国际版在线";
sc.LastRefreshDate = DateTime.Now.ToString("yyyyMMdd");
}
}
//loginResult = PDDShopListForm.GetShopStatus2(shop);
//if (!loginResult.Contains("\"success\":true"))
//{
// shop.Cookies2 = "empty=true;";
// foreach (var sc in campanys)
// {
// sc.LoginStatus2 = "国际版未登录";
// sc.Cookies2 = "empty=true;";
// }
//}
//else
//{
// foreach (var sc in campanys)
// {
// sc.LoginStatus2 = "国际版在线";
// sc.LastRefreshDate = DateTime.Now.ToString("yyyyMMdd");
// }
//}
//if (!string.IsNullOrEmpty(loginResult))
// shop.LastRefreshDate = DateTime.Now.ToString("yyyyMMdd");
UpdateServerShopCookies(shop); // 店铺cookie写入服务端,多店共用一个登录账号一组cookie
@@ -686,6 +686,7 @@ namespace TemuKJD.PDDForms.ShopForms
{
string url = "https://mms.pinduoduo.com/janus/api/userinfo";
string refere = "https://mms.pinduoduo.com/login/";
refere = "https://mms.pinduoduo.com/home";
string body = @"{}";
return HttpResponseBLL.PDDPostResponse(shop, url, body, refere);
}
+11 -7
View File
@@ -157,7 +157,7 @@ namespace TemuKJD.PDDForms.ShopForms
ShopId = sc.AccountId,
SubUserName = shop.SubUserName,
Notes = shop.Notes,
AntiContents = new List<string> { sc.AntiContent },
AntiContents = new NaiBa.Util.ConcurrentList<string> { sc.AntiContent },
};
var oldShop = GlobalConfig.ShopLoginList.FirstOrDefault(l =>
@@ -177,7 +177,7 @@ namespace TemuKJD.PDDForms.ShopForms
oldShop.SubUserName = newShop.SubUserName;
oldShop.Notes = newShop.Notes;
oldShop.AntiContents.AddRange(newShop.AntiContents);
while (oldShop.AntiContents.Count > 10)
while (oldShop.AntiContents.Count > 50)
oldShop.AntiContents.RemoveAt(0);
// 店铺更新写入到服务端
@@ -460,7 +460,7 @@ namespace TemuKJD.PDDForms.ShopForms
cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(sb.ToString());
}
int GetAntiContentsTimes = 0;
int GetAntiContentsTimes = 40;
private void RequestHandler_ResourceLoadComplete(object sender, string url, string postData, string responseData, IRequest request)
{
var antiContent = request.Headers.AllKeys.Contains("Anti-Content") ? request.Headers["Anti-Content"] : "";
@@ -468,9 +468,9 @@ namespace TemuKJD.PDDForms.ShopForms
{
GetAntiContentsTimes++;
shop.AntiContents.Add(antiContent);
while (shop.AntiContents.Count > 10)
while (shop.AntiContents.Count > 50)
shop.AntiContents.RemoveAt(0);
if (!string.IsNullOrEmpty(shop.ShopId) && GetAntiContentsTimes > 5)
if (!string.IsNullOrEmpty(shop.ShopId) && GetAntiContentsTimes > 50)
{
GetAntiContentsTimes = 0;
var antis = shop.AntiContents;
@@ -487,7 +487,11 @@ namespace TemuKJD.PDDForms.ShopForms
}
Task.Run(() =>
{
//var data = responseData;
var data = responseData;
if (data.Contains("\"validate_message\""))
{
}
//if (data.Contains("supplierId") && data.Contains("\"success\":true"))
//{
// var supplierIds = BaseRegex.GetMatchRegex(ref data, "\"supplierId\":\\d{5,20}");
@@ -560,7 +564,7 @@ namespace TemuKJD.PDDForms.ShopForms
addGetProdButton();
function addGetProdButton() {
var productLst = document.getElementsByClassName('goods-id');
var productLst = document.getElementsByClassName('goods-id0000000000');
for(i=0; i<productLst.length; i++) {
var addBtnItem = productLst[i].parentElement.parentElement;
if (addBtnItem.parentElement.innerHTML.indexOf('库存上传') < 0 && addBtnItem.parentElement.innerHTML.indexOf('ID:') >= 0) {