parse_2.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  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. string result;
  161. try
  162. {
  163. if (!IsShortLink(url)) return (false, "不是淘宝短网址");
  164. if (_account.use_general_link_parse_pool)
  165. {
  166. try
  167. {
  168. var parsed = await endpoint_tbk_dg_general_link_parse(url, new TkDataDTO { content = url }, cancellationToken);
  169. if (parsed.success)
  170. {
  171. string desiredUrl = IsDigitsOnly(parsed.itemId)
  172. ? $"https://item.taobao.com/item.htm?id={parsed.itemId}"
  173. : parsed.item_url;
  174. return (true, desiredUrl);
  175. }
  176. }
  177. catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
  178. {
  179. throw;
  180. }
  181. catch (Exception ex)
  182. {
  183. _ = TaobaoGeneralLinkParseCacheCore.NotifyFailureOnceAsync($"{ex.GetType().Name}: {ex.Message}", 0, _accountId);
  184. }
  185. // 解析失败、接口异常或账号池无可用账号,均回退原 HTTP 逻辑。
  186. }
  187. cancellationToken.ThrowIfCancellationRequested();
  188. if (!_account.enable_deep_url) return (true, url);
  189. string shortUrl = url;
  190. string? cachedUrl = await TaobaoShortLinkCacheCore.GetAsync(shortUrl);
  191. cancellationToken.ThrowIfCancellationRequested();
  192. if (cachedUrl != null) return (true, cachedUrl);
  193. if (_account.use_general_link_parse_pool)
  194. {
  195. proxy ??= ProxyNodesCore.RandomOne(_account.nodeName);
  196. }
  197. string desiredUrlPattern = "var url = '(.*?)'";
  198. WebClientUtility client = new()
  199. {
  200. Proxy = proxy,
  201. UserAgent = Sayaka.Common.ProviderFakeUserAgent.RandomComputer
  202. };
  203. if (url.Contains("u.tb.cn"))
  204. {
  205. client.AllowAutoRedirect = false;
  206. }
  207. url = url.Replace("http://u.tb.cn", "https://u.tb.cn");
  208. #if DEBUG
  209. client.Proxy = null;
  210. var response = await client.RequestAsync(url, "GET");
  211. #else
  212. client.Timeout = GetRequestTimeout();
  213. var response = await client.RequestAsync(url, "GET", cancellationToken);
  214. #endif
  215. if (response.ResponseMessage?.StatusCode == HttpStatusCode.Found &&
  216. !string.IsNullOrEmpty(response.ResponseMessage?.Headers?.Location?.OriginalString))
  217. {
  218. string redirectUrl = response.ResponseMessage?.Headers?.Location?.OriginalString;
  219. if (redirectUrl.StartsWith("//")) redirectUrl = "https:" + redirectUrl;
  220. await TaobaoShortLinkCacheCore.SaveAsync(shortUrl, redirectUrl);
  221. return (true, redirectUrl);
  222. }
  223. var responseBody = response.Body();
  224. result = responseBody;
  225. if (response.Successed)
  226. {
  227. if (response.ResponseMessage.IsSuccessStatusCode)
  228. {
  229. Match match = Regex.Match(responseBody, desiredUrlPattern);
  230. if (match.Success)
  231. {
  232. result = match.Groups[1].Value; // 返回匹配的 URL
  233. if (string.IsNullOrEmpty(result)) return (false, "没有匹配的URL");
  234. if (result.StartsWith("//"))
  235. result = "https:" + result;
  236. await TaobaoShortLinkCacheCore.SaveAsync(shortUrl, result);
  237. return (true, result);
  238. }
  239. }
  240. else
  241. {
  242. result = $"{response.ResponseMessage.StatusCode}\n{responseBody}";
  243. }
  244. }
  245. else
  246. {
  247. throw response.ResponseException;
  248. }
  249. }
  250. catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
  251. {
  252. throw;
  253. }
  254. catch (Exception ex)
  255. {
  256. _ = new LoggerLibrary("api_error", "desiredUrl_error").Info(ex.Message, ex.StackTrace).SaveAsync();
  257. result = "网络异常";
  258. }
  259. return (false, result);
  260. }
  261. /// <summary>
  262. /// 从http获取跳转的url
  263. /// </summary>
  264. /// <param name="url"></param>
  265. /// <returns></returns>
  266. public (bool, string) GetDesiredUrl(string url)
  267. {
  268. string result;
  269. try
  270. {
  271. if (!IsShortLink(url)) return (false, "不是淘宝短网址");
  272. string? cachedUrl = TaobaoShortLinkCacheCore.Get(url);
  273. if (cachedUrl != null) return (true, cachedUrl);
  274. string desiredUrlPattern = "var url = '(.*?)'";
  275. WebClientUtility client = new()
  276. {
  277. Proxy = ProxyNodesCore.RandomOne(_account.nodeName),
  278. UserAgent = Sayaka.Common.ProviderFakeUserAgent.RandomComputer
  279. };
  280. #if DEBUG
  281. client.Proxy = null;
  282. #endif
  283. client.Timeout = GetRequestTimeout();
  284. var response = client.Request(url);
  285. var responseBody = response.Body();
  286. result = responseBody;
  287. if (response.Successed)
  288. {
  289. if (response.ResponseMessage.IsSuccessStatusCode)
  290. {
  291. Match match = Regex.Match(responseBody, desiredUrlPattern);
  292. if (match.Success)
  293. {
  294. result = match.Groups[1].Value; // 返回匹配的 URL
  295. if (string.IsNullOrEmpty(result)) return (false, "没有匹配的URL");
  296. if (result.StartsWith("//")) result = "https:" + result;
  297. TaobaoShortLinkCacheCore.Save(url, result);
  298. return (true, result);
  299. }
  300. }
  301. else
  302. {
  303. result = $"{response.ResponseMessage.StatusCode}\n{responseBody}";
  304. }
  305. }
  306. else
  307. {
  308. throw response.ResponseException;
  309. }
  310. }
  311. catch (Exception ex)
  312. {
  313. result = $"{ex.Message}\n{ex.StackTrace}";
  314. }
  315. return (false, result);
  316. }
  317. public static (bool, string) GetItemUrl(string url, WebProxy proxy = null)
  318. {
  319. string result;
  320. try
  321. {
  322. if (!IsShortLink(url)) return (false, "不是淘宝短网址");
  323. string? cachedUrl = TaobaoShortLinkCacheCore.Get(url);
  324. if (cachedUrl != null) return (true, cachedUrl);
  325. string desiredUrlPattern = "var url = '(.*?)'";
  326. WebClientUtility client = new()
  327. {
  328. Proxy = proxy,
  329. UserAgent = Sayaka.Common.ProviderFakeUserAgent.RandomComputer
  330. };
  331. #if DEBUG
  332. client.Proxy = null;
  333. #endif
  334. var response = client.Request(url);
  335. var responseBody = response.Body();
  336. result = responseBody;
  337. if (response.Successed)
  338. {
  339. if (response.ResponseMessage.IsSuccessStatusCode)
  340. {
  341. Match match = Regex.Match(responseBody, desiredUrlPattern);
  342. if (match.Success)
  343. {
  344. result = match.Groups[1].Value; // 返回匹配的 URL
  345. if (string.IsNullOrEmpty(result)) return (false, "没有匹配的URL");
  346. if (result.StartsWith("//")) result = "https:" + result;
  347. TaobaoShortLinkCacheCore.Save(url, result);
  348. return (true, result);
  349. }
  350. }
  351. else
  352. {
  353. result = $"{response.ResponseMessage.StatusCode}\n{responseBody}";
  354. }
  355. }
  356. else
  357. {
  358. throw response.ResponseException;
  359. }
  360. }
  361. catch (Exception ex)
  362. {
  363. result = $"{ex.Message}\n{ex.StackTrace}";
  364. }
  365. return (false, result);
  366. }
  367. private void InternalTextProcessing(string content, ref TkDataDTO result)
  368. {
  369. //(result.success, result.content, result.link_type, result.shortLinkurl) = InternalTextProcessing(content,ref result);
  370. bool success;
  371. string resultText;
  372. LinkTypeEnum link_type = LinkTypeEnum.unknown;
  373. string url = GetLink(content);
  374. if (!string.IsNullOrEmpty(url))
  375. {
  376. //排除已知的淘客链接
  377. if (IsAffLink(url))
  378. {
  379. result.success = false;
  380. result.content = "排除淘客链接";
  381. result.link_type = LinkTypeEnum.other_aff;
  382. result.shortLinkurl = url;
  383. return;
  384. //return (false, "排除淘客链接", LinkTypeEnum.other_aff, url);
  385. }
  386. //直接提取
  387. (success, resultText) = IsTaobaoUrl(url);
  388. if (success)
  389. {
  390. result.success = true;
  391. result.content = resultText;
  392. result.link_type = LinkTypeEnum.goods;
  393. result.shortLinkurl = resultText;
  394. return;
  395. //return (true, result, LinkTypeEnum.goods, result);
  396. }
  397. //从http获取跳转的url
  398. Stopwatch stopwatch = Stopwatch.StartNew();
  399. stopwatch.Start();
  400. (success, resultText) = GetDesiredUrl(url);
  401. stopwatch.Stop();
  402. // 获取执行时间
  403. result.elapsedTime2 = (int)stopwatch.ElapsedMilliseconds;
  404. if (success)
  405. {
  406. //排除已知的淘客链接
  407. if (IsAffLink(resultText))
  408. {
  409. result.success = false;
  410. result.content = "排除淘客链接";
  411. result.link_type = LinkTypeEnum.other_aff;
  412. result.shortLinkurl = url;
  413. return;
  414. //return (false, "排除淘客链接", LinkTypeEnum.other_aff, url);
  415. }
  416. (success, resultText) = IsTaobaoUrl(resultText);
  417. if (success)
  418. {
  419. result.success = true;
  420. result.content = resultText;
  421. result.link_type = LinkTypeEnum.goods;
  422. result.shortLinkurl = resultText;
  423. return;
  424. //return (true, resultText, LinkTypeEnum.goods, resultText);
  425. }
  426. link_type = GetLinkType(resultText);
  427. }
  428. else
  429. {
  430. link_type = GetLinkType(url);
  431. }
  432. result.success = false;
  433. result.content = resultText;
  434. result.link_type = link_type;
  435. result.shortLinkurl = url;
  436. return;
  437. //return (false, result, link_type, url);
  438. }
  439. //判断淘客的¥羊角符号
  440. if (ContainsSpecialFormat(content))
  441. {
  442. result.success = false;
  443. result.content = "排除淘口令";
  444. result.link_type = LinkTypeEnum.other_aff;
  445. result.shortLinkurl = null;
  446. return;
  447. //return (false, "排除淘口令", LinkTypeEnum.other_aff, null);
  448. }
  449. //todo 临时应急 0614
  450. //return (false, "纯口令 没链接", link_type, null);
  451. result.success = false;
  452. result.content = "纯口令 没链接";
  453. result.link_type = LinkTypeEnum.other_aff;
  454. result.shortLinkurl = null;
  455. }
  456. public async Task<TkDataDTO> InternalTextProcessingAsync(string content, TkDataDTO result,
  457. CancellationToken cancellationToken = default,
  458. Dictionary<string, long> swData = null)
  459. {
  460. bool success;
  461. string resultText;
  462. result.link_type = LinkTypeEnum.unknown;
  463. //============================== 放弃转链-其他推广链接 ==============================
  464. string url = GetLink(content);
  465. result.shortLinkurl = url;
  466. if (!string.IsNullOrEmpty(url))
  467. {
  468. bool is_aff = IsAffLink(url);
  469. if (is_aff)
  470. {
  471. result.success = false;
  472. result.message = "放弃转链";
  473. result.reason = "其他推广链接";
  474. result.subCode = TkSubCodeEnum.OtherPromo;
  475. result.link_type = LinkTypeEnum.other_aff;
  476. //result.shortLinkurl = url;
  477. return result;
  478. }
  479. (success, resultText) = IsTaobaoUrl(url);
  480. if (success)
  481. {
  482. result.success = true;
  483. result.content = resultText;
  484. result.link_type = LinkTypeEnum.goods;
  485. //result.shortLinkurl = resultText;
  486. return result;
  487. }
  488. Stopwatch sw = Stopwatch.StartNew();
  489. var proxy = _account.use_general_link_parse_pool ? null : ProxyNodesCore.RandomOne(_account.nodeName);
  490. if (_proxy != null && proxy != null && _proxy.Address != proxy.Address)
  491. {
  492. result.proxy_node = proxy?.Address?.Authority;
  493. }
  494. (success, resultText) = await GetDesiredUrlAsync(proxy, url, cancellationToken);
  495. sw.Stop();
  496. // 获取执行时间
  497. result.elapsedTime2 = (int)sw.ElapsedMilliseconds;
  498. swData?.Add("\tGetDesiredUrlAsync", sw.ElapsedMilliseconds);
  499. //============================== 放弃转链-请求超时 ==============================
  500. #if DEBUG
  501. #else
  502. if (result.elapsedTime2 >= _config.rt_max || (!success && resultText.Contains("was canceled")))
  503. {
  504. result.success = false;
  505. result.message = "放弃转链";
  506. result.reason = "请求超时";
  507. result.subCode = TkSubCodeEnum.Other;
  508. return result;
  509. }
  510. #endif
  511. if (!success && resultText.Contains("<!DOCTYPE html>"))
  512. {
  513. result.success = false;
  514. result.message = "放弃转链";
  515. result.reason = "短链解析错误";
  516. result.subCode = TkSubCodeEnum.Other;
  517. return result;
  518. }
  519. if (success)
  520. {
  521. string desiredUrl = resultText;
  522. //============================== 放弃转链-其他推广链接 ==============================
  523. bool is_aff2 = IsAffLink(desiredUrl);
  524. if (is_aff2)
  525. {
  526. result.success = false;
  527. result.message = "放弃转链";
  528. result.reason = "其他推广链接";
  529. result.subCode = TkSubCodeEnum.OtherPromo;
  530. result.link_type = LinkTypeEnum.other_aff;
  531. //result.shortLinkurl = url;
  532. return result;
  533. }
  534. (success, desiredUrl) = IsTaobaoUrl(desiredUrl);
  535. if (success)
  536. {
  537. result.success = true;
  538. result.content = desiredUrl;
  539. result.link_type = LinkTypeEnum.goods;
  540. //result.shortLinkurl = desiredUrl;
  541. return result;
  542. }
  543. result.link_type = GetLinkType(desiredUrl);
  544. }
  545. else
  546. {
  547. result.link_type = GetLinkType(url);
  548. if ("网络错误".Equals(resultText))
  549. {
  550. result.link_type = LinkTypeEnum.unknown;
  551. result.content = resultText;
  552. result.reason = resultText;
  553. }
  554. }
  555. if (result.content.Contains("霸下通用 web 页面-验证码"))
  556. {
  557. result.subCode = TkSubCodeEnum.Captcha;
  558. result.reason = "霸下验证码";
  559. }
  560. else
  561. {
  562. switch (result.link_type)
  563. {
  564. case LinkTypeEnum.profile:
  565. case LinkTypeEnum.live:
  566. case LinkTypeEnum.video:
  567. case LinkTypeEnum.note:
  568. case LinkTypeEnum.goods:
  569. case LinkTypeEnum.baseDomain:
  570. result.reason = string.Empty;
  571. result.content = content;
  572. break;
  573. default:
  574. result.reason = "非标准链接";
  575. result.subCode = TkSubCodeEnum.NonStdLink;
  576. break;
  577. }
  578. //if (result.link_type == LinkTypeEnum.baseDomain)
  579. //{
  580. // result.content = content;
  581. //}
  582. //else
  583. //{
  584. // result.reason = "非标准链接";
  585. // result.subCode = TkSubCodeEnum.NonStdLink;
  586. //}
  587. }
  588. result.success = false;
  589. result.message = "放弃转链";
  590. result.content = resultText;
  591. result.shortLinkurl = url;
  592. return result;
  593. //return (false, result, link_type, url);
  594. }
  595. //判断淘客的¥羊角符号
  596. bool is_aff3 = ContainsSpecialFormat(content);
  597. if (is_aff3)
  598. {
  599. result.success = false;
  600. result.message = "放弃转链";
  601. result.reason = "排除淘口令";
  602. result.subCode = TkSubCodeEnum.OtherPromo;
  603. result.link_type = LinkTypeEnum.other_aff;
  604. result.shortLinkurl = null;
  605. return result;
  606. //return (false, "排除淘口令", LinkTypeEnum.other_aff, null);
  607. }
  608. //todo 临时应急 0614
  609. //return (false, "纯口令 没链接", link_type, null);
  610. result.success = false;
  611. result.message = "放弃转链";
  612. result.reason = "纯口令 没链接";
  613. result.subCode = TkSubCodeEnum.OtherPromo;
  614. result.link_type = LinkTypeEnum.other_aff;
  615. result.shortLinkurl = null;
  616. return result;
  617. }
  618. private LinkTypeEnum GetLinkType(string url)
  619. {
  620. if (string.IsNullOrEmpty(url)) return LinkTypeEnum.unknown;
  621. if (IsShortLink(url)) return LinkTypeEnum.baseDomain;
  622. if (url.StartsWith("https://huodong.m.taobao.com/act/talent/live.html")) return LinkTypeEnum.live;
  623. if (url.StartsWith("https://web.m.taobao.com/app/tnode/web/index")) return LinkTypeEnum.video;
  624. if (url.StartsWith("https://shop.m.taobao.com/shop/shopIndex.htm")) return LinkTypeEnum.profile;
  625. string pattern = @"^https://shop\d+(\.m)*\.taobao\.com";
  626. if (Regex.IsMatch(url, pattern))
  627. {
  628. return LinkTypeEnum.profile;
  629. }
  630. //https://shop.m.taobao.com/shop/shopIndex.htm?
  631. return LinkTypeEnum.unknown;
  632. }
  633. }
  634. }