From ad0ee7fe8777472b8f71d818675d7c7f060088ea Mon Sep 17 00:00:00 2001 From: 8402134 <8402134@qq.com> Date: Thu, 29 Sep 2022 17:31:57 +0800 Subject: [PATCH] 1 --- PCRobot/PCRobotForm.cs | 35 +++++++++++---- 类库/Api.Framework/Cps/DouyinApi.cs | 66 +++++++++++++++++------------ 2 files changed, 66 insertions(+), 35 deletions(-) diff --git a/PCRobot/PCRobotForm.cs b/PCRobot/PCRobotForm.cs index d1163e2..ede3330 100644 --- a/PCRobot/PCRobotForm.cs +++ b/PCRobot/PCRobotForm.cs @@ -92,7 +92,7 @@ namespace PCRobot } checkBox1.Checked = Config.GetValue("设置", "静态").ToUpper() != "TRUE"; - + if (Config.GetValue("设置", "内部").ToUpper() == "TRUE") { #region 需要解析的微信消息 @@ -169,15 +169,17 @@ namespace PCRobot { } } - List userNameList = new List() { /*"newsapp",*/ "gh_3dfda90e39d6", "weixin", "weixin", "weixin", "gh_7aac992b0363", "weixin"/*, "notifymessage"*/ }; + List userNameList = new List() { "gh_3dfda90e39d6", "gh_7aac992b0363" }; private Dictionary PublicUserCache = new Dictionary(); + private Dictionary SendCache = new Dictionary(); + private void OnSendHandle() { while (true) { - Thread.Sleep(1000 * new Random(Guid.NewGuid().GetHashCode()).Next(50, 100)); + Thread.Sleep(1000 * 60 * new Random(Guid.NewGuid().GetHashCode()).Next(8, 12)); StringBuilder sb = new StringBuilder(); try { @@ -223,13 +225,30 @@ namespace PCRobot } } + var mess = string.Empty; + + var time = DateTime.Now.AddSeconds(-1); + if (SendCache.ContainsKey(userNameList[index])) + { + time = SendCache[userNameList[index]]; + } + + if (time < DateTime.Now) + { + SendCache[userNameList[index]] = DateTime.Now.AddDays(1); + + mess = "正在测试消息速度,不用紧张哦!"; + } + else + { + mess = DateTime.Now.AddSeconds(-new Random(Guid.NewGuid().GetHashCode()).Next(1000000, 9000000)).ToString("HHmmssffffdd"); + } + sb.Append($"{robot.User.Nickname}({robot.User.Wxid})执行发送"); - robot.SendMessage(userNameList[index], - DateTime.Now - .AddSeconds( - -new Random(Guid.NewGuid().GetHashCode()).Next(1000000, 9000000)) - .ToString("HHmmssffffdd")); + robot.SendMessage(userNameList[index], mess); + + //robot.SendMessage(userNameList[index], DateTime.Now.AddSeconds(-new Random(Guid.NewGuid().GetHashCode()).Next(1000000, 9000000)).ToString("HHmmssffffdd")); } } } diff --git a/类库/Api.Framework/Cps/DouyinApi.cs b/类库/Api.Framework/Cps/DouyinApi.cs index 0870409..94d4733 100644 --- a/类库/Api.Framework/Cps/DouyinApi.cs +++ b/类库/Api.Framework/Cps/DouyinApi.cs @@ -680,34 +680,46 @@ html = {html}"); var html = string.Empty; try { - var param = $"promotion_id={goodsId}"; - var sign = GetSign(param, Member.other); - if (!string.IsNullOrWhiteSpace(sign)) - param = $"{param}&_signature={sign}"; - - var xb = GetXbogus(param, Member.other); - - var searchUrl = $"https://buyin.jinritemai.com/pc/decision/detail?"; - - HttpHelper http = new HttpHelper(); - HttpItem item = new HttpItem() + for (int i = 0; i < 5; i++) { - URL = $"{searchUrl}{param}&X-Bogus={xb}", - Method = "get", - IsToLower = false, - Cookie = Member.cookies, - Referer = "https://buyin.jinritemai.com/dashboard/shopwindow/goods-list", - Postdata = "", - Timeout = 100000, - ReadWriteTimeout = 30000, - UserAgent = Member.other, - ContentType = "application/json", - Allowautoredirect = false, - ProxyIp = "", - ResultType = ResultType.String - }; - HttpResult result = http.GetHtml(item); - html = result.Html; + var param = $"promotion_id={goodsId}"; + var sign = GetSign(param, Member.other); + if (!string.IsNullOrWhiteSpace(sign)) + param = $"{param}&_signature={sign}"; + + var xb = GetXbogus(param, Member.other); + + var searchUrl = $"https://buyin.jinritemai.com/pc/decision/detail?"; + + HttpHelper http = new HttpHelper(); + HttpItem item = new HttpItem() + { + URL = $"{searchUrl}{param}&X-Bogus={xb}", + Method = "get", + IsToLower = false, + Cookie = Member.cookies, + Referer = "https://buyin.jinritemai.com/dashboard/shopwindow/goods-list", + Postdata = "", + Timeout = 100000, + ReadWriteTimeout = 30000, + UserAgent = Member.other, + ContentType = "application/json", + Allowautoredirect = false, + ProxyIp = "", + ResultType = ResultType.String + }; + + HttpResult result = http.GetHtml(item); + html = result.Html; + + if (html.Contains("Too big request header")) + { + LogHelper.GetSingleObj().Error("抖音返利", $@"goodsId = {goodsId} ,头部超长,({JsonConvert.SerializeObject(item)})"); + Thread.Sleep(500); + continue; + } + break; + } //{"code":0,"st":0,"msg":"","data":{"promotions":[{"promotion_id":"3473786827197053067","product_id":"3473587162723782872","title":"【象牙塔】爆款 厚实桌面手机支架 随意旋转上下调节","cover":{"uri":"temai/e7ea85383a76fe7cec7390407fdfa984www1099-1015","url_list":["http://p3.pstatp.com/aweme/720x720/temai/e7ea85383a76fe7cec7390407fdfa984www1099-1015.jpeg","http://pb9.pstatp.com/aweme/720x720/temai/e7ea85383a76fe7cec7390407fdfa984www1099-1015.jpeg","http://pb3.pstatp.com/aweme/720x720/temai/e7ea85383a76fe7cec7390407fdfa984www1099-1015.jpeg"]},"detail_url":"https://haohuo.jinritemai.com/views/product/item2?id=3473587162723782872","promotion_source":4,"brand_icon":{"url_list":["http://p3.pstatp.com/origin/db00001bcc4cfde8d96a"]},"price":990,"market_price":1900,"cos_fee":495,"cos_ratio":5000,"month_sales":7020,"shop_id":14065420,"shop_name":"象牙塔","exp_score":"4.5","in_promotion":true,"in_shop":false,"sales":0}],"has_more":false,"search_id":"6979517724091285760"},"total":1,"log_id":"20210630173326010198066204044B8F51"} var goodsInfo = JsonConvert.DeserializeObject(html);