parse_2.cs 27 KB

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