|
|
@@ -4,6 +4,7 @@ using System.Diagnostics;
|
|
|
using System.Text.Json;
|
|
|
using TencentCloud.Fmu.V20191213.Models;
|
|
|
using System;
|
|
|
+using MySqlX.XDevAPI;
|
|
|
|
|
|
namespace molilian.core
|
|
|
{
|
|
|
@@ -131,6 +132,19 @@ namespace molilian.core
|
|
|
return Regex.IsMatch(content, pattern);
|
|
|
}
|
|
|
|
|
|
+ public TimeSpan GetRequestTimeout(int deduction = 0)
|
|
|
+ {
|
|
|
+#if DEBUG
|
|
|
+ return TimeSpan.FromMilliseconds(10 * 1000);
|
|
|
+#endif
|
|
|
+ if (_config.rt_max == 0) return TimeSpan.FromMilliseconds(1000);
|
|
|
+ int timeout = _config.rt_max;
|
|
|
+ if (deduction == 0) return TimeSpan.FromMilliseconds(timeout);
|
|
|
+ timeout = timeout - deduction;
|
|
|
+ if (timeout < 0) return TimeSpan.FromMilliseconds(200);
|
|
|
+ return TimeSpan.FromMilliseconds(timeout);
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 从http获取跳转的url
|
|
|
/// </summary>
|
|
|
@@ -153,9 +167,8 @@ namespace molilian.core
|
|
|
};
|
|
|
#if DEBUG
|
|
|
client.Proxy = null;
|
|
|
-#else
|
|
|
- client.Timeout = TimeSpan.FromMilliseconds(3000);
|
|
|
#endif
|
|
|
+ client.Timeout = GetRequestTimeout(0);
|
|
|
var response = client.Request(url);
|
|
|
|
|
|
var responseBody = response.Body();
|
|
|
@@ -193,7 +206,107 @@ namespace molilian.core
|
|
|
}
|
|
|
|
|
|
|
|
|
- private (bool, string, LinkTypeEnum, string) InternalTextProcessing(string content)
|
|
|
+ private void InternalTextProcessing(string content, ref TkDataDTO result)
|
|
|
+ {
|
|
|
+ //(result.success, result.content, result.link_type, result.shortLinkurl) = InternalTextProcessing(content,ref result);
|
|
|
+
|
|
|
+
|
|
|
+ bool success;
|
|
|
+ string resultText;
|
|
|
+ LinkTypeEnum link_type = LinkTypeEnum.unknown;
|
|
|
+
|
|
|
+ string url = GetLink(content);
|
|
|
+ if (!string.IsNullOrEmpty(url))
|
|
|
+ {
|
|
|
+ //排除已知的淘客链接
|
|
|
+ if (IsAffLink(url))
|
|
|
+ {
|
|
|
+ result.success = false;
|
|
|
+ result.content = "排除淘客链接";
|
|
|
+ result.link_type = LinkTypeEnum.other_aff;
|
|
|
+ result.shortLinkurl = url;
|
|
|
+ return;
|
|
|
+ //return (false, "排除淘客链接", LinkTypeEnum.other_aff, url);
|
|
|
+ }
|
|
|
+
|
|
|
+ //直接提取
|
|
|
+ (success, resultText) = IsTaobaoUrl(url);
|
|
|
+ if (success)
|
|
|
+ {
|
|
|
+ result.success = true;
|
|
|
+ result.content = resultText;
|
|
|
+ result.link_type = LinkTypeEnum.goods;
|
|
|
+ result.shortLinkurl = resultText;
|
|
|
+ return;
|
|
|
+ //return (true, result, LinkTypeEnum.goods, result);
|
|
|
+ }
|
|
|
+
|
|
|
+ //从http获取跳转的url
|
|
|
+ Stopwatch stopwatch = Stopwatch.StartNew();
|
|
|
+ stopwatch.Start();
|
|
|
+ (success, resultText) = GetDesiredUrl(url);
|
|
|
+ stopwatch.Stop();
|
|
|
+ // 获取执行时间
|
|
|
+ result.elapsedTime2 = (int)stopwatch.ElapsedMilliseconds;
|
|
|
+
|
|
|
+ if (success)
|
|
|
+ {
|
|
|
+ //排除已知的淘客链接
|
|
|
+ if (IsAffLink(resultText))
|
|
|
+ {
|
|
|
+ result.success = false;
|
|
|
+ result.content = "排除淘客链接";
|
|
|
+ result.link_type = LinkTypeEnum.other_aff;
|
|
|
+ result.shortLinkurl = url;
|
|
|
+ return;
|
|
|
+ //return (false, "排除淘客链接", LinkTypeEnum.other_aff, url);
|
|
|
+ }
|
|
|
+ (success, resultText) = IsTaobaoUrl(resultText);
|
|
|
+ if (success)
|
|
|
+ {
|
|
|
+ result.success = true;
|
|
|
+ result.content = resultText;
|
|
|
+ result.link_type = LinkTypeEnum.goods;
|
|
|
+ result.shortLinkurl = resultText;
|
|
|
+ return;
|
|
|
+ //return (true, resultText, LinkTypeEnum.goods, resultText);
|
|
|
+ }
|
|
|
+ link_type = GetLinkType(resultText);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ link_type = GetLinkType(url);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ result.success = false;
|
|
|
+ result.content = resultText;
|
|
|
+ result.link_type = link_type;
|
|
|
+ result.shortLinkurl = url;
|
|
|
+ return;
|
|
|
+
|
|
|
+ //return (false, result, link_type, url);
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断淘客的¥羊角符号
|
|
|
+ if (ContainsSpecialFormat(content))
|
|
|
+ {
|
|
|
+ result.success = false;
|
|
|
+ result.content = "排除淘口令";
|
|
|
+ result.link_type = LinkTypeEnum.other_aff;
|
|
|
+ result.shortLinkurl = null;
|
|
|
+ return;
|
|
|
+ //return (false, "排除淘口令", LinkTypeEnum.other_aff, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ //todo 临时应急 0614
|
|
|
+ //return (false, "纯口令 没链接", link_type, null);
|
|
|
+ result.success = false;
|
|
|
+ result.content = "纯口令 没链接";
|
|
|
+ result.link_type = LinkTypeEnum.other_aff;
|
|
|
+ result.shortLinkurl = null;
|
|
|
+ }
|
|
|
+ private (bool, string, LinkTypeEnum, string) InternalTextProcessing222(string content)
|
|
|
{
|
|
|
bool success;
|
|
|
string result;
|
|
|
@@ -210,9 +323,9 @@ namespace molilian.core
|
|
|
if (success) return (true, result, LinkTypeEnum.goods, result);
|
|
|
//https://uland.taobao.com/coupon/edetail?af=4&e=%2B0aTAvEt16MoRnbUfHBdCarU9683KT3AsB67n92UtFJMmdsrkidbOWBzzpT26idJbwZX%2BHY%2B8QD9zJXNeOSc1euXSPKeLUBBWr02LqsxPV8Bf6pSMNy5GSw6iqMObXLLk3toOSlQXmUUcLJJYP0Uq5lvDADUDTeHRiuxU0i9W%2BtrC8Oh6piEfdwyUIuKQbeM8rUgQejRG616MoRnbUfHBdCarU9683KT3AsB67n92UtFv6uIFQszbmWWPZ8ka7%2BkV5xXydLt%2FcnuZ4%2BBFYnwwiUaCWC3TckcCwMW8xe3XqOGsb8uv9wbhxdkKJ0hxTrTkj7DNgliTXDluAYBRglsbQ%3D%3D&traceId=212cbaa417178512249145009e05a8&union_lens=lensId%3APUB%401717851219%402103c04a_0c89_18ff7e96612_9d39%40031w5YJSc7jl3U7gYjdvuCMM%40eyJmbG9vcklkIjo4NTAvEt16MoRnbUfHBdCarU9683JDaxNfPy83okP3kLScwCkGiuMcyC4PcynGV0YWlsX2h0bSIsInNyY0Zsb29ySWQiiOiiI4MDY3NCIsImNyZWF0aXZpdHlHcm91cElkIjowfQieie%3BtkScm%3AselectionPlaza_site_4358%3Bscm%3A1007.30148.329090.pub_search-item_c02df4bb-631f-4cc1-a9d5-abe802b8e134_&un=bfc196d23e155d289f2917200ca32a93&share_crt_v=1&un_site=0&ut_sk=1.utdid_null_1717851225204.TaoPassword-Outside.lianmeng-app&spm=a2159r.13376465.0.0&sp_tk=d2hLeFdDNHpKb3Y%3D&cpp=1&shareurl=true&short_name=h.gVx6mvI
|
|
|
|
|
|
-
|
|
|
//从http获取跳转的url
|
|
|
(success, result) = GetDesiredUrl(url);
|
|
|
+
|
|
|
if (success)
|
|
|
{
|
|
|
//排除已知的淘客链接
|
|
|
@@ -286,8 +399,7 @@ namespace molilian.core
|
|
|
client.Proxy = null;
|
|
|
#endif
|
|
|
if (!string.IsNullOrEmpty(_user_agent)) client.UserAgent = _user_agent;
|
|
|
-
|
|
|
- client.Timeout = TimeSpan.FromMilliseconds(1000);
|
|
|
+ client.Timeout = GetRequestTimeout(result.elapsedTime2);
|
|
|
var response = client.Request(url);
|
|
|
|
|
|
var body = string.Empty;
|
|
|
@@ -456,19 +568,23 @@ namespace molilian.core
|
|
|
string url = "https://pub.alimama.com/openapi/param2/1/gateway.unionpub/xt.entry.json?" +
|
|
|
$"t={t}&_tb_token_={_tb_token}&floorId={_floorId}&refpid={_refpid}&variableMap={variableMap}";
|
|
|
|
|
|
+ Stopwatch stopwatch = Stopwatch.StartNew();
|
|
|
+ stopwatch.Start();
|
|
|
|
|
|
var client = new WebClientUtility().SetContentType("application/json;charset=utf-8")
|
|
|
.AddHeaders("X-Requested-With", "XMLHttpRequest")
|
|
|
.AddHeaders("Cookie", _cookies);
|
|
|
client.Proxy = _proxy;
|
|
|
if (!string.IsNullOrEmpty(_user_agent)) client.UserAgent = _user_agent;
|
|
|
- client.Timeout = TimeSpan.FromMilliseconds(1000);
|
|
|
#if DEBUG
|
|
|
client.Proxy = null;
|
|
|
- client.Timeout = TimeSpan.FromMilliseconds(10000);
|
|
|
#endif
|
|
|
+ client.Timeout = GetRequestTimeout(result.elapsedTime2);
|
|
|
var response = client.Request(url);
|
|
|
|
|
|
+ stopwatch.Stop();
|
|
|
+ result.elapsedTime3 = (int)stopwatch.ElapsedMilliseconds;
|
|
|
+
|
|
|
var body = string.Empty;
|
|
|
try
|
|
|
{
|