parse_2.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. using dodohold.core;
  2. using System.Text.RegularExpressions;
  3. using System.Diagnostics;
  4. using System.Text.Json;
  5. using TencentCloud.Fmu.V20191213.Models;
  6. using System;
  7. using MySqlX.XDevAPI;
  8. using static dodohold.core.ZTOExpress.CreateOrderArgs;
  9. using System.Threading;
  10. using TencentCloud.Tcm.V20210413.Models;
  11. using COSXML.Network;
  12. using System.Net;
  13. using TencentCloud.Cdb.V20170320.Models;
  14. using System.Security.Cryptography;
  15. namespace molilian.core
  16. {
  17. public partial class AlimamaPlus
  18. {
  19. public static async Task<TkDataDTO> testTaskAsync(TkDataDTO result, CancellationToken token)
  20. {
  21. string url = "https://www.taobao.com";
  22. try
  23. {
  24. WebClientUtility client = new WebClientUtility();
  25. await Task.Delay(5000);
  26. client.Timeout = TimeSpan.FromMilliseconds(3000);
  27. var response = await client.RequestAsync(url);
  28. var body = response.Body();
  29. }
  30. catch
  31. {
  32. result.success = false;
  33. result.message = "Error";
  34. }
  35. return result;
  36. }
  37. /// <summary>
  38. /// 提取url里面的商品id参数
  39. /// </summary>
  40. /// <param name="url"></param>
  41. /// <returns></returns>
  42. public static string? ExtractItemId(string url)
  43. {
  44. Match match = Regex.Match(url, @"(?:\?|&)(?:id|shareDetailItemId|itemIds)=(\d+)");
  45. if (match.Success)
  46. {
  47. return match.Groups[1].Value;
  48. }
  49. return null;
  50. }
  51. /// <summary>
  52. /// 是否淘宝链接,如果是商品链接就格式化成https://item.taobao.com/item.htm?id=****
  53. /// </summary>
  54. /// <param name="url"></param>
  55. /// <returns></returns>
  56. public static (bool, string) IsTaobaoUrl(string url)
  57. {
  58. if (url.Contains("//a.m.taobao.com/i") ||
  59. url.Contains("//internal.tt.detail.taobao.com/i"))
  60. {
  61. //第一种提取方法
  62. string itemId = url.GetContentPart(".com/i", ".htm");
  63. if (!string.IsNullOrEmpty(itemId) && long.TryParse(itemId, out long _))
  64. {
  65. string resultUrl = $"https://item.taobao.com/item.htm?id={itemId}";
  66. return (true, resultUrl);
  67. }
  68. }
  69. //https://pages-g.m.taobao.com/wow/z/app/detail-next/item/index?x-ssr=true&id=753169018016
  70. if (url.Contains("//item.taobao.com/item.htm?") ||
  71. url.Contains("//pages-g.m.taobao.com/wow/z/app/detail-next/item/index?") ||
  72. (url.Contains("//pages-fast.m.taobao.com/wow/bz/jingmi/") && url.Contains("shareDetailItemId=")) ||
  73. url.Contains("//main.m.taobao.com/detail/index.html?") ||
  74. url.Contains("//main.m.taobao.com/security-h5-detail/home?") ||
  75. url.Contains("//h5.m.taobao.com/awp/core/detail.htm?") ||
  76. url.Contains("//new.m.taobao.com/detail.htm?") ||
  77. url.Contains("//outfliggys.m.taobao.com/app/trip/rx-travel-detail") ||
  78. url.Contains("//detail.m.tmall.com/item.htm?") ||
  79. url.Contains("//tmallx.tmall.com/app/tmallx-src/goods-detail") ||
  80. url.Contains("//detail.tmall.com/item.htm?") ||
  81. url.Contains("//internal.tt.detail.taobao.com/item.htm?") ||
  82. url.Contains("//internal.tt.detail.taobao.com/") ||
  83. url.Contains("//detail.tmall.hk/hk/item.htm?"))
  84. {
  85. string? itemId = ExtractItemId(url);
  86. if (!string.IsNullOrEmpty(itemId))
  87. {
  88. string resultUrl = $"https://item.taobao.com/item.htm?id={itemId}";
  89. return (true, resultUrl);
  90. }
  91. }
  92. return (false, url);
  93. }
  94. /// <summary>
  95. /// 排除已知的淘客链接
  96. /// </summary>
  97. /// <param name="url"></param>
  98. /// <returns></returns>
  99. public static bool IsAffLink(string url)
  100. {
  101. if (!url.StartsWith("https://") || !url.StartsWith("https://")) url = "https://" + url;
  102. Uri uri = new(url);
  103. if (uri.Host.Equals("s.click.taobao.com", StringComparison.OrdinalIgnoreCase) ||
  104. uri.Host.Equals("uland.taobao.com", StringComparison.OrdinalIgnoreCase))
  105. {
  106. return true;
  107. }
  108. return false;
  109. }
  110. public static bool IsShortLink(string url)
  111. {
  112. if (!url.StartsWith("https://", StringComparison.OrdinalIgnoreCase) &&
  113. !url.StartsWith("http://", StringComparison.OrdinalIgnoreCase)) url = "https://" + url;
  114. Uri uri = new(url);
  115. if (uri.Host.Equals("e.tb.cn", StringComparison.OrdinalIgnoreCase) ||
  116. uri.Host.Equals("m.tb.cn", StringComparison.OrdinalIgnoreCase) ||
  117. uri.Host.Equals("u.tb.cn", StringComparison.OrdinalIgnoreCase) ||
  118. uri.Host.Equals("s.tb.cn", StringComparison.OrdinalIgnoreCase))
  119. {
  120. return true;
  121. }
  122. return false;
  123. }
  124. /// <summary>
  125. /// 判断淘客的¥羊角符号
  126. /// </summary>
  127. /// <param name="content"></param>
  128. /// <returns></returns>
  129. static bool ContainsSpecialFormat(string content)
  130. {
  131. // 使用正则表达式匹配内容中是否含有特定格式的字符串
  132. //string pattern = @"¥[a-zA-Z0-9\s]+¥";
  133. string pattern = @"[$¥🗝₴€₤£₳✔《💰🔑🎵✔️💲🔐📲₡]+[a-zA-Z0-9\s]+[$¥🗝₴€₤£₳✔《💰🔑🎵✔️💲🔐📲₡]*";
  134. return Regex.IsMatch(content, pattern);
  135. }
  136. public TimeSpan GetRequestTimeout()
  137. {
  138. int min = (int)(_config.rt_max * 0.5);
  139. if (_config.rt_max == 0) return TimeSpan.FromMilliseconds(1000);
  140. int timeout = _config.rt_max;
  141. timeout -= min;
  142. return TimeSpan.FromMilliseconds(timeout);
  143. }
  144. public TimeSpan GetRequestTimeout2(int deduction = 0)
  145. {
  146. int min = (int)(_config.rt_max * 0.5);
  147. if (_config.rt_max == 0) return TimeSpan.FromMilliseconds(1000);
  148. int timeout = _config.rt_max;
  149. timeout -= deduction;
  150. if (timeout <= min) return TimeSpan.FromMilliseconds(min);
  151. return TimeSpan.FromMilliseconds(timeout);
  152. }
  153. /// <summary>
  154. /// 从http获取跳转的url
  155. /// </summary>
  156. /// <param name="url"></param>
  157. /// <returns></returns>
  158. public async Task<(bool, string)> GetDesiredUrlAsync(WebProxy proxy, string url, CancellationToken cancellationToken = default)
  159. {
  160. var result = await GetDesiredUrlResultAsync(proxy, url, cancellationToken);
  161. return (result.Success, result.Content);
  162. }
  163. private readonly record struct DesiredUrlResult(bool Success, string Content, bool UsedGeneralLinkParse);
  164. private async Task<DesiredUrlResult> GetDesiredUrlResultAsync(WebProxy proxy, string url, CancellationToken cancellationToken)
  165. {
  166. string result;
  167. bool usedGeneralLinkParse = false;
  168. try
  169. {
  170. if (!IsShortLink(url)) return new(false, "不是淘宝短网址", false);
  171. if (_account.use_general_link_parse_pool)
  172. {
  173. usedGeneralLinkParse = true;
  174. var parsed = await endpoint_tbk_dg_general_link_parse(url, new TkDataDTO { content = url }, cancellationToken);
  175. if (parsed.subCode != TkSubCodeEnum.GeneralLinkParsePoolUnavailable)
  176. {
  177. if (!parsed.success) return new(false, parsed.reason, true);
  178. string desiredUrl = IsDigitsOnly(parsed.itemId)
  179. ? $"https://item.taobao.com/item.htm?id={parsed.itemId}"
  180. : parsed.item_url;
  181. return new(true, desiredUrl, true);
  182. }
  183. // 账号池无可用账号时,继续按下探网址设置执行原逻辑。
  184. usedGeneralLinkParse = false;
  185. }
  186. cancellationToken.ThrowIfCancellationRequested();
  187. if (!_account.enable_deep_url) return new(true, url, false);
  188. if (_account.use_general_link_parse_pool)
  189. {
  190. proxy ??= ProxyNodesCore.RandomOne(_account.nodeName);
  191. }
  192. string desiredUrlPattern = "var url = '(.*?)'";
  193. WebClientUtility client = new()
  194. {
  195. Proxy = proxy,
  196. UserAgent = Sayaka.Common.ProviderFakeUserAgent.RandomComputer
  197. };
  198. if (url.Contains("u.tb.cn"))
  199. {
  200. client.AllowAutoRedirect = false;
  201. }
  202. url = url.Replace("http://u.tb.cn", "https://u.tb.cn");
  203. #if DEBUG
  204. client.Proxy = null;
  205. var response = await client.RequestAsync(url, "GET");
  206. #else
  207. client.Timeout = GetRequestTimeout();
  208. var response = await client.RequestAsync(url, "GET", cancellationToken);
  209. #endif
  210. if (response.ResponseMessage?.StatusCode == HttpStatusCode.Found &&
  211. !string.IsNullOrEmpty(response.ResponseMessage?.Headers?.Location?.OriginalString))
  212. {
  213. string redirectUrl = response.ResponseMessage?.Headers?.Location?.OriginalString;
  214. return new(true, redirectUrl, false);
  215. }
  216. var responseBody = response.Body();
  217. result = responseBody;
  218. if (response.Successed)
  219. {
  220. if (response.ResponseMessage.IsSuccessStatusCode)
  221. {
  222. Match match = Regex.Match(responseBody, desiredUrlPattern);
  223. if (match.Success)
  224. {
  225. result = match.Groups[1].Value; // 返回匹配的 URL
  226. if (string.IsNullOrEmpty(result)) return new(false, "没有匹配的URL", false);
  227. if (result.StartsWith("//"))
  228. result = "https:" + result;
  229. return new(true, result, false);
  230. }
  231. }
  232. else
  233. {
  234. result = $"{response.ResponseMessage.StatusCode}\n{responseBody}";
  235. }
  236. }
  237. else
  238. {
  239. throw response.ResponseException;
  240. }
  241. }
  242. catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
  243. {
  244. throw;
  245. }
  246. catch (Exception ex)
  247. {
  248. _ = new LoggerLibrary("api_error", "desiredUrl_error").Info(ex.Message, ex.StackTrace).SaveAsync();
  249. result = "网络异常";
  250. }
  251. return new(false, result, usedGeneralLinkParse);
  252. }
  253. /// <summary>
  254. /// 从http获取跳转的url
  255. /// </summary>
  256. /// <param name="url"></param>
  257. /// <returns></returns>
  258. public (bool, string) GetDesiredUrl(string url)
  259. {
  260. string result;
  261. try
  262. {
  263. if (!IsShortLink(url)) return (false, "不是淘宝短网址");
  264. string desiredUrlPattern = "var url = '(.*?)'";
  265. WebClientUtility client = new()
  266. {
  267. Proxy = ProxyNodesCore.RandomOne(_account.nodeName),
  268. UserAgent = Sayaka.Common.ProviderFakeUserAgent.RandomComputer
  269. };
  270. #if DEBUG
  271. client.Proxy = null;
  272. #endif
  273. client.Timeout = GetRequestTimeout();
  274. var response = client.Request(url);
  275. var responseBody = response.Body();
  276. result = responseBody;
  277. if (response.Successed)
  278. {
  279. if (response.ResponseMessage.IsSuccessStatusCode)
  280. {
  281. Match match = Regex.Match(responseBody, desiredUrlPattern);
  282. if (match.Success)
  283. {
  284. result = match.Groups[1].Value; // 返回匹配的 URL
  285. if (string.IsNullOrEmpty(result)) return (false, "没有匹配的URL");
  286. return (true, result);
  287. }
  288. }
  289. else
  290. {
  291. result = $"{response.ResponseMessage.StatusCode}\n{responseBody}";
  292. }
  293. }
  294. else
  295. {
  296. throw response.ResponseException;
  297. }
  298. }
  299. catch (Exception ex)
  300. {
  301. result = $"{ex.Message}\n{ex.StackTrace}";
  302. }
  303. return (false, result);
  304. }
  305. public static (bool, string) GetItemUrl(string url, WebProxy proxy = null)
  306. {
  307. string result;
  308. try
  309. {
  310. if (!IsShortLink(url)) return (false, "不是淘宝短网址");
  311. string desiredUrlPattern = "var url = '(.*?)'";
  312. WebClientUtility client = new()
  313. {
  314. Proxy = proxy,
  315. UserAgent = Sayaka.Common.ProviderFakeUserAgent.RandomComputer
  316. };
  317. #if DEBUG
  318. client.Proxy = null;
  319. #endif
  320. var response = client.Request(url);
  321. var responseBody = response.Body();
  322. result = responseBody;
  323. if (response.Successed)
  324. {
  325. if (response.ResponseMessage.IsSuccessStatusCode)
  326. {
  327. Match match = Regex.Match(responseBody, desiredUrlPattern);
  328. if (match.Success)
  329. {
  330. result = match.Groups[1].Value; // 返回匹配的 URL
  331. if (string.IsNullOrEmpty(result)) return (false, "没有匹配的URL");
  332. return (true, result);
  333. }
  334. }
  335. else
  336. {
  337. result = $"{response.ResponseMessage.StatusCode}\n{responseBody}";
  338. }
  339. }
  340. else
  341. {
  342. throw response.ResponseException;
  343. }
  344. }
  345. catch (Exception ex)
  346. {
  347. result = $"{ex.Message}\n{ex.StackTrace}";
  348. }
  349. return (false, result);
  350. }
  351. private void InternalTextProcessing(string content, ref TkDataDTO result)
  352. {
  353. //(result.success, result.content, result.link_type, result.shortLinkurl) = InternalTextProcessing(content,ref result);
  354. bool success;
  355. string resultText;
  356. LinkTypeEnum link_type = LinkTypeEnum.unknown;
  357. string url = GetLink(content);
  358. if (!string.IsNullOrEmpty(url))
  359. {
  360. //排除已知的淘客链接
  361. if (IsAffLink(url))
  362. {
  363. result.success = false;
  364. result.content = "排除淘客链接";
  365. result.link_type = LinkTypeEnum.other_aff;
  366. result.shortLinkurl = url;
  367. return;
  368. //return (false, "排除淘客链接", LinkTypeEnum.other_aff, url);
  369. }
  370. //直接提取
  371. (success, resultText) = IsTaobaoUrl(url);
  372. if (success)
  373. {
  374. result.success = true;
  375. result.content = resultText;
  376. result.link_type = LinkTypeEnum.goods;
  377. result.shortLinkurl = resultText;
  378. return;
  379. //return (true, result, LinkTypeEnum.goods, result);
  380. }
  381. //从http获取跳转的url
  382. Stopwatch stopwatch = Stopwatch.StartNew();
  383. stopwatch.Start();
  384. (success, resultText) = GetDesiredUrl(url);
  385. stopwatch.Stop();
  386. // 获取执行时间
  387. result.elapsedTime2 = (int)stopwatch.ElapsedMilliseconds;
  388. if (success)
  389. {
  390. //排除已知的淘客链接
  391. if (IsAffLink(resultText))
  392. {
  393. result.success = false;
  394. result.content = "排除淘客链接";
  395. result.link_type = LinkTypeEnum.other_aff;
  396. result.shortLinkurl = url;
  397. return;
  398. //return (false, "排除淘客链接", LinkTypeEnum.other_aff, url);
  399. }
  400. (success, resultText) = IsTaobaoUrl(resultText);
  401. if (success)
  402. {
  403. result.success = true;
  404. result.content = resultText;
  405. result.link_type = LinkTypeEnum.goods;
  406. result.shortLinkurl = resultText;
  407. return;
  408. //return (true, resultText, LinkTypeEnum.goods, resultText);
  409. }
  410. link_type = GetLinkType(resultText);
  411. }
  412. else
  413. {
  414. link_type = GetLinkType(url);
  415. }
  416. result.success = false;
  417. result.content = resultText;
  418. result.link_type = link_type;
  419. result.shortLinkurl = url;
  420. return;
  421. //return (false, result, link_type, url);
  422. }
  423. //判断淘客的¥羊角符号
  424. if (ContainsSpecialFormat(content))
  425. {
  426. result.success = false;
  427. result.content = "排除淘口令";
  428. result.link_type = LinkTypeEnum.other_aff;
  429. result.shortLinkurl = null;
  430. return;
  431. //return (false, "排除淘口令", LinkTypeEnum.other_aff, null);
  432. }
  433. //todo 临时应急 0614
  434. //return (false, "纯口令 没链接", link_type, null);
  435. result.success = false;
  436. result.content = "纯口令 没链接";
  437. result.link_type = LinkTypeEnum.other_aff;
  438. result.shortLinkurl = null;
  439. }
  440. public async Task<TkDataDTO> InternalTextProcessingAsync(string content, TkDataDTO result,
  441. CancellationToken cancellationToken = default,
  442. Dictionary<string, long> swData = null)
  443. {
  444. bool success;
  445. string resultText;
  446. result.link_type = LinkTypeEnum.unknown;
  447. //============================== 放弃转链-其他推广链接 ==============================
  448. string url = GetLink(content);
  449. result.shortLinkurl = url;
  450. if (!string.IsNullOrEmpty(url))
  451. {
  452. bool is_aff = IsAffLink(url);
  453. if (is_aff)
  454. {
  455. result.success = false;
  456. result.message = "放弃转链";
  457. result.reason = "其他推广链接";
  458. result.subCode = TkSubCodeEnum.OtherPromo;
  459. result.link_type = LinkTypeEnum.other_aff;
  460. //result.shortLinkurl = url;
  461. return result;
  462. }
  463. (success, resultText) = IsTaobaoUrl(url);
  464. if (success)
  465. {
  466. result.success = true;
  467. result.content = resultText;
  468. result.link_type = LinkTypeEnum.goods;
  469. //result.shortLinkurl = resultText;
  470. return result;
  471. }
  472. Stopwatch sw = Stopwatch.StartNew();
  473. var proxy = _account.use_general_link_parse_pool ? null : ProxyNodesCore.RandomOne(_account.nodeName);
  474. if (_proxy != null && proxy != null && _proxy.Address != proxy.Address)
  475. {
  476. result.proxy_node = proxy?.Address?.Authority;
  477. }
  478. var desiredUrlResult = await GetDesiredUrlResultAsync(proxy, url, cancellationToken);
  479. success = desiredUrlResult.Success;
  480. resultText = desiredUrlResult.Content;
  481. sw.Stop();
  482. // 获取执行时间
  483. result.elapsedTime2 = (int)sw.ElapsedMilliseconds;
  484. swData?.Add("\tGetDesiredUrlAsync", sw.ElapsedMilliseconds);
  485. if (desiredUrlResult.UsedGeneralLinkParse && !success)
  486. {
  487. result.success = false;
  488. result.message = "解析失败";
  489. result.reason = resultText;
  490. result.subCode = TkSubCodeEnum.NoConvert;
  491. result.link_type = LinkTypeEnum.unknown;
  492. result.content = content;
  493. return result;
  494. }
  495. //============================== 放弃转链-请求超时 ==============================
  496. #if DEBUG
  497. #else
  498. if (result.elapsedTime2 >= _config.rt_max || (!success && resultText.Contains("was canceled")))
  499. {
  500. result.success = false;
  501. result.message = "放弃转链";
  502. result.reason = "请求超时";
  503. result.subCode = TkSubCodeEnum.Other;
  504. return result;
  505. }
  506. #endif
  507. if (!success && resultText.Contains("<!DOCTYPE html>"))
  508. {
  509. result.success = false;
  510. result.message = "放弃转链";
  511. result.reason = "短链解析错误";
  512. result.subCode = TkSubCodeEnum.Other;
  513. return result;
  514. }
  515. if (success)
  516. {
  517. string desiredUrl = resultText;
  518. //============================== 放弃转链-其他推广链接 ==============================
  519. bool is_aff2 = IsAffLink(desiredUrl);
  520. if (is_aff2)
  521. {
  522. result.success = false;
  523. result.message = "放弃转链";
  524. result.reason = "其他推广链接";
  525. result.subCode = TkSubCodeEnum.OtherPromo;
  526. result.link_type = LinkTypeEnum.other_aff;
  527. //result.shortLinkurl = url;
  528. return result;
  529. }
  530. (success, desiredUrl) = IsTaobaoUrl(desiredUrl);
  531. if (success)
  532. {
  533. result.success = true;
  534. result.content = desiredUrl;
  535. result.link_type = LinkTypeEnum.goods;
  536. //result.shortLinkurl = desiredUrl;
  537. return result;
  538. }
  539. result.link_type = GetLinkType(desiredUrl);
  540. }
  541. else
  542. {
  543. result.link_type = GetLinkType(url);
  544. if ("网络错误".Equals(resultText))
  545. {
  546. result.link_type = LinkTypeEnum.unknown;
  547. result.content = resultText;
  548. result.reason = resultText;
  549. }
  550. }
  551. if (result.content.Contains("霸下通用 web 页面-验证码"))
  552. {
  553. result.subCode = TkSubCodeEnum.Captcha;
  554. result.reason = "霸下验证码";
  555. }
  556. else
  557. {
  558. switch (result.link_type)
  559. {
  560. case LinkTypeEnum.profile:
  561. case LinkTypeEnum.live:
  562. case LinkTypeEnum.video:
  563. case LinkTypeEnum.note:
  564. case LinkTypeEnum.goods:
  565. case LinkTypeEnum.baseDomain:
  566. result.reason = string.Empty;
  567. result.content = content;
  568. break;
  569. default:
  570. result.reason = "非标准链接";
  571. result.subCode = TkSubCodeEnum.NonStdLink;
  572. break;
  573. }
  574. //if (result.link_type == LinkTypeEnum.baseDomain)
  575. //{
  576. // result.content = content;
  577. //}
  578. //else
  579. //{
  580. // result.reason = "非标准链接";
  581. // result.subCode = TkSubCodeEnum.NonStdLink;
  582. //}
  583. }
  584. result.success = false;
  585. result.message = "放弃转链";
  586. result.content = resultText;
  587. result.shortLinkurl = url;
  588. return result;
  589. //return (false, result, link_type, url);
  590. }
  591. //判断淘客的¥羊角符号
  592. bool is_aff3 = ContainsSpecialFormat(content);
  593. if (is_aff3)
  594. {
  595. result.success = false;
  596. result.message = "放弃转链";
  597. result.reason = "排除淘口令";
  598. result.subCode = TkSubCodeEnum.OtherPromo;
  599. result.link_type = LinkTypeEnum.other_aff;
  600. result.shortLinkurl = null;
  601. return result;
  602. //return (false, "排除淘口令", LinkTypeEnum.other_aff, null);
  603. }
  604. //todo 临时应急 0614
  605. //return (false, "纯口令 没链接", link_type, null);
  606. result.success = false;
  607. result.message = "放弃转链";
  608. result.reason = "纯口令 没链接";
  609. result.subCode = TkSubCodeEnum.OtherPromo;
  610. result.link_type = LinkTypeEnum.other_aff;
  611. result.shortLinkurl = null;
  612. return result;
  613. }
  614. private LinkTypeEnum GetLinkType(string url)
  615. {
  616. if (string.IsNullOrEmpty(url)) return LinkTypeEnum.unknown;
  617. if (IsShortLink(url)) return LinkTypeEnum.baseDomain;
  618. if (url.StartsWith("https://huodong.m.taobao.com/act/talent/live.html")) return LinkTypeEnum.live;
  619. if (url.StartsWith("https://web.m.taobao.com/app/tnode/web/index")) return LinkTypeEnum.video;
  620. if (url.StartsWith("https://shop.m.taobao.com/shop/shopIndex.htm")) return LinkTypeEnum.profile;
  621. string pattern = @"^https://shop\d+(\.m)*\.taobao\.com";
  622. if (Regex.IsMatch(url, pattern))
  623. {
  624. return LinkTypeEnum.profile;
  625. }
  626. //https://shop.m.taobao.com/shop/shopIndex.htm?
  627. return LinkTypeEnum.unknown;
  628. }
  629. }
  630. }