模拟提交商品,测试最多能传50件左右就会出限制
This commit is contained in:
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;
|
||||
|
||||
Reference in new issue
Block a user