parse_2.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  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. namespace molilian.core
  8. {
  9. public partial class AlimamaPlus
  10. {
  11. public void UnionParse2(string content, ref TkDataDTO result)
  12. {
  13. if ("veapi".Equals(_api) && _api_id > 0)
  14. {
  15. var account = VeapiPoolCore.Get(_api_id);
  16. if (account != null)
  17. {
  18. var core = new VeapiPlus(account.name, account.key, account.sessionKey);
  19. core.UnionParse(content, ref result);
  20. return;
  21. }
  22. }
  23. UnionParse(content, ref result);
  24. }
  25. public async Task<TkDataDTO> UnionParse2Async(string content, TkDataDTO result)
  26. {
  27. if ("veapi".Equals(_api) && _api_id > 0)
  28. {
  29. var account = VeapiPoolCore.Get(_api_id);
  30. if (account != null)
  31. {
  32. var core = new VeapiPlus(account.name, account.key, account.sessionKey);
  33. result = await core.UnionParseAsync(content, result);
  34. return result;
  35. }
  36. }
  37. result = await UnionParseAsync(content, result);
  38. return result;
  39. }
  40. /// <summary>
  41. /// 提取url里面的id参数
  42. /// </summary>
  43. /// <param name="url"></param>
  44. /// <returns></returns>
  45. static string? ExtractItemId(string url)
  46. {
  47. Match match = Regex.Match(url, @"(?:\?|&)id=(\d+)");
  48. if (match.Success)
  49. {
  50. return match.Groups[1].Value;
  51. }
  52. return null;
  53. }
  54. /// <summary>
  55. /// 是否淘宝链接
  56. /// </summary>
  57. /// <param name="url"></param>
  58. /// <returns></returns>
  59. private static (bool, string) IsTaobaoUrl(string url)
  60. {
  61. if (url.Contains("//a.m.taobao.com/i"))
  62. {
  63. //第一种提取方法
  64. string itemId = url.GetContentPart("//a.m.taobao.com/i", ".htm");
  65. if (!string.IsNullOrEmpty(itemId))
  66. {
  67. string resultUrl = $"https://item.taobao.com/item.htm?id={itemId}";
  68. return (true, resultUrl);
  69. }
  70. }
  71. if (url.Contains("//item.taobao.com/item.htm?") ||
  72. url.Contains("//h5.m.taobao.com/awp/core/detail.htm?") ||
  73. url.Contains("//new.m.taobao.com/detail.htm?") ||
  74. url.Contains("//outfliggys.m.taobao.com/app/trip/rx-travel-detail") ||
  75. url.Contains("//detail.m.tmall.com/item.htm?") ||
  76. url.Contains("//tmallx.tmall.com/app/tmallx-src/goods-detail") ||
  77. url.Contains("//detail.tmall.com/item.htm?") ||
  78. url.Contains("//detail.tmall.hk/hk/item.htm?"))
  79. {
  80. string? itemId = ExtractItemId(url);
  81. if (!string.IsNullOrEmpty(itemId))
  82. {
  83. string resultUrl = $"https://item.taobao.com/item.htm?id={itemId}";
  84. return (true, resultUrl);
  85. }
  86. }
  87. return (false, url);
  88. }
  89. /// <summary>
  90. /// 排除已知的淘客链接
  91. /// </summary>
  92. /// <param name="url"></param>
  93. /// <returns></returns>
  94. static bool IsAffLink(string url)
  95. {
  96. if (!url.StartsWith("https://") || !url.StartsWith("https://")) url = "https://" + url;
  97. Uri uri = new(url);
  98. if (uri.Host.Equals("s.click.taobao.com", StringComparison.OrdinalIgnoreCase) ||
  99. uri.Host.Equals("uland.taobao.com", StringComparison.OrdinalIgnoreCase))
  100. {
  101. return true;
  102. }
  103. //if (uri.Host.Equals("m.tb.cn", StringComparison.OrdinalIgnoreCase) &&
  104. // uri.AbsolutePath.StartsWith("/h.") &&
  105. // string.IsNullOrEmpty(uri.Query) && // No query parameters
  106. // !url.Contains("?tk=")) // No "tk" parameter
  107. //{
  108. // return true;
  109. //}
  110. return false;
  111. }
  112. /// <summary>
  113. /// 判断淘客的¥羊角符号
  114. /// </summary>
  115. /// <param name="content"></param>
  116. /// <returns></returns>
  117. static bool ContainsSpecialFormat(string content)
  118. {
  119. // 使用正则表达式匹配内容中是否含有特定格式的字符串
  120. //string pattern = @"¥[a-zA-Z0-9\s]+¥";
  121. string pattern = @"[$¥🗝₴€₤£₳✔《💰🔑🎵✔️💲🔐📲₡]+[a-zA-Z0-9\s]+[$¥🗝₴€₤£₳✔《💰🔑🎵✔️💲🔐📲₡]*";
  122. return Regex.IsMatch(content, pattern);
  123. }
  124. /// <summary>
  125. /// 从http获取跳转的url
  126. /// </summary>
  127. /// <param name="url"></param>
  128. /// <returns></returns>
  129. (bool, string) GetDesiredUrl(string url)
  130. {
  131. string result;
  132. try
  133. {
  134. Uri uri = new(url);
  135. if (!uri.Host.Equals("m.tb.cn", StringComparison.OrdinalIgnoreCase)) return (false, "不是淘宝短网址");
  136. string desiredUrlPattern = "var url = '(.*?)'";
  137. WebClientUtility client = new()
  138. {
  139. Proxy = _proxy,
  140. UserAgent = Sayaka.Common.ProviderFakeUserAgent.RandomComputer
  141. };
  142. #if DEBUG
  143. client.Proxy = null;
  144. #else
  145. client.Timeout = TimeSpan.FromMilliseconds(5000);
  146. #endif
  147. var response = client.Request(url);
  148. var responseBody = response.Body();
  149. result = responseBody;
  150. if (response.Successed)
  151. {
  152. if (response.ResponseMessage.IsSuccessStatusCode)
  153. {
  154. Match match = Regex.Match(responseBody, desiredUrlPattern);
  155. if (match.Success)
  156. {
  157. result = match.Groups[1].Value; // 返回匹配的 URL
  158. if (string.IsNullOrEmpty(result)) return (false, "没有匹配的URL");
  159. return (true, result);
  160. }
  161. }
  162. else
  163. {
  164. result = $"{response.ResponseMessage.StatusCode}\n{responseBody}";
  165. }
  166. }
  167. else
  168. {
  169. throw response.ResponseException;
  170. }
  171. }
  172. catch (Exception ex)
  173. {
  174. result = $"{ex.Message}\n{ex.StackTrace}";
  175. }
  176. return (false, result);
  177. }
  178. private (bool, string, LinkTypeEnum, string) InternalTextProcessing(string content)
  179. {
  180. bool success;
  181. string result;
  182. LinkTypeEnum link_type = LinkTypeEnum.unknown;
  183. string url = GetLink(content);
  184. if (!string.IsNullOrEmpty(url))
  185. {
  186. //排除已知的淘客链接
  187. if (IsAffLink(url)) return (false, "排除淘客链接", LinkTypeEnum.other_aff, url);
  188. //直接提取
  189. (success, result) = IsTaobaoUrl(url);
  190. if (success) return (true, result, LinkTypeEnum.goods, result);
  191. //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
  192. //从http获取跳转的url
  193. (success, result) = GetDesiredUrl(url);
  194. if (success)
  195. {
  196. //排除已知的淘客链接
  197. if (IsAffLink(result)) return (false, "排除淘客链接", LinkTypeEnum.other_aff, url);
  198. (success, result) = IsTaobaoUrl(result);
  199. if (success) return (true, result, LinkTypeEnum.goods, result);
  200. link_type = GetLinkType(result);
  201. }
  202. else
  203. {
  204. link_type = GetLinkType(url);
  205. }
  206. return (false, result, link_type, url);
  207. }
  208. //判断淘客的¥羊角符号
  209. if (ContainsSpecialFormat(content)) return (false, "排除淘口令", LinkTypeEnum.other_aff, null);
  210. //todo 临时应急 0614
  211. //return (false, "纯口令 没链接", link_type, null);
  212. return (false, "纯口令 没链接", LinkTypeEnum.other_aff, null);
  213. }
  214. private LinkTypeEnum GetLinkType(string url)
  215. {
  216. if (string.IsNullOrEmpty(url)) return LinkTypeEnum.unknown;
  217. if (url.StartsWith("https://huodong.m.taobao.com/act/talent/live.html")) return LinkTypeEnum.live;
  218. if (url.StartsWith("https://web.m.taobao.com/app/tnode/web/index")) return LinkTypeEnum.video;
  219. string pattern = @"^https://shop\d+\.m\.taobao\.com";
  220. if (Regex.IsMatch(url, pattern))
  221. {
  222. return LinkTypeEnum.profile;
  223. }
  224. return LinkTypeEnum.unknown;
  225. }
  226. private void alimamaParse(string content, ref TkDataDTO result)
  227. {
  228. string t = $"{DateTime.Now.Convert2UnixTimestamp(true)}";
  229. Random random = new();
  230. double randomNumber = random.NextDouble();
  231. string randomString = randomNumber.ToString()[2..];
  232. string cna = _cookies.GetContentPart("cna=", ";");
  233. string firstFiveCharacters = cna[..Math.Min(5, cna.Length)];
  234. var variableMap = new
  235. {
  236. url = content,
  237. union_lens = $"b_pvid:a219t._portal_v2_tool_links_page_home_index_htm_{t}_{randomString}_{firstFiveCharacters}",
  238. lensScene = "PUB",
  239. spmB = "_portal_v2_tool_links_page_home_index_htm"
  240. }.Convert2Json(true).UrlEncode();
  241. variableMap = variableMap.Replace(" ", "%20");
  242. string url = "https://pub.alimama.com/openapi/param2/1/gateway.unionpub/xt.entry.json?" +
  243. $"t={t}&_tb_token_={_tb_token}&floorId={_floorId}&refpid={_refpid}&variableMap={variableMap}";
  244. var client = new WebClientUtility().SetContentType("application/json;charset=utf-8")
  245. .AddHeaders("X-Requested-With", "XMLHttpRequest")
  246. .AddHeaders("Cookie", _cookies);
  247. client.Proxy = _proxy;
  248. #if DEBUG
  249. client.Proxy = null;
  250. #endif
  251. if (!string.IsNullOrEmpty(_user_agent)) client.UserAgent = _user_agent;
  252. client.Timeout = TimeSpan.FromMilliseconds(2000);
  253. var response = client.Request(url);
  254. var body = string.Empty;
  255. try
  256. {
  257. if (!response.Successed)
  258. {
  259. result.channel = TkChannelEnum.tb;
  260. result.accountId = _accountId;
  261. result.accountName = _accountName;
  262. result.link_type = LinkTypeEnum.unknown;
  263. result.success = false;
  264. result.message = "fail";
  265. if (response.ResponseException != null)
  266. {
  267. new LoggerLibrary("api_error", "fail")
  268. .Info(response.ResponseException.Message, response.ResponseException.StackTrace)
  269. .Save();
  270. throw response.ResponseException;
  271. }
  272. return;
  273. }
  274. body = response.Body();
  275. JsonElement root = body.Convert2JsonElement();
  276. bool success = root.Read<bool>("success", false);
  277. string message = root.Read("message", string.Empty);
  278. string info_message = root.PathRead("info.message", string.Empty);
  279. if (!string.IsNullOrEmpty(info_message)) message = info_message;
  280. string taoToken = root.PathRead("data.taoToken", string.Empty);
  281. string shortLinkurl = root.PathRead("data.shortLinkurl", string.Empty);
  282. string couponLinkTaoToken = root.PathRead("data.couponLinkTaoToken", string.Empty);
  283. string couponShortLinkUrl = root.PathRead("data.couponShortLinkUrl", string.Empty);
  284. decimal couponAmount = root.PathRead<decimal>("data.couponAmount", 0);
  285. string itemId = root.PathRead("data.itemId", string.Empty);
  286. string itemName = root.PathRead("data.itemName", string.Empty);
  287. decimal promotionPrice = root.PathRead<decimal>("data.promotionPrice", 0);
  288. string sellerNickName = root.PathRead("data.sellerNickName", string.Empty);
  289. string shopTitle = root.PathRead("data.shopTitle", string.Empty);
  290. string pic = root.PathRead("data.pic", string.Empty);
  291. string qrCodeUrl = root.PathRead("data.qrCodeUrl", string.Empty);
  292. if (response.ResponseMessage != null)
  293. {
  294. switch (response.ResponseMessage.StatusCode)
  295. {
  296. case System.Net.HttpStatusCode.OK:
  297. {
  298. if (couponAmount > 0 && !string.IsNullOrEmpty(couponLinkTaoToken) && !string.IsNullOrEmpty(couponShortLinkUrl))
  299. {
  300. taoToken = couponLinkTaoToken;
  301. shortLinkurl = couponShortLinkUrl;
  302. }
  303. string shortLink = GetLink(taoToken);
  304. content = ReplaceUrls(content, shortLink);
  305. }
  306. break;
  307. case System.Net.HttpStatusCode.Found:
  308. string location = response.ResponseMessage.Headers.Location.OriginalString;
  309. if (!string.IsNullOrEmpty(location) && location.Contains("www.alimama.com/member/login.htm"))
  310. {
  311. success = false;
  312. message = "nologin";
  313. }
  314. break;
  315. default:
  316. {
  317. success = false;
  318. message = "other";
  319. }
  320. break;
  321. }
  322. }
  323. if (!success)
  324. {
  325. shortLinkurl = GetLink(content);
  326. switch (message)
  327. {
  328. case "该链接不支持转化,请更换链接尝试":
  329. case "网络错误":
  330. break;
  331. default:
  332. var _headers = response.ResponseMessage.Headers;
  333. var headers = "";
  334. foreach (var h in _headers)
  335. {
  336. foreach (var Value in h.Value)
  337. {
  338. headers += $"{h.Key}: {Value}\n";
  339. }
  340. }
  341. new LoggerLibrary("api_error", "fail")
  342. .Info(message, content)
  343. .Info(headers, body)
  344. .Save();
  345. break;
  346. }
  347. }
  348. string deeplink_url = GetDeeplink(shortLinkurl);
  349. result.channel = TkChannelEnum.tb;
  350. result.accountId = _accountId;
  351. result.accountName = _accountName;
  352. result.link_type = success ? LinkTypeEnum.goods : result.link_type;
  353. result.success = success;
  354. result.message = message;
  355. result.content = content;
  356. result.couponAmount = couponAmount;
  357. result.taoToken = taoToken;
  358. result.shortLinkurl = shortLinkurl;
  359. result.deeplink_url = deeplink_url;
  360. result.itemId = itemId;
  361. result.itemName = itemName;
  362. result.promotionPrice = promotionPrice;
  363. result.sellerNickName = sellerNickName;
  364. result.shopTitle = shopTitle;
  365. result.pic = pic;
  366. result.qrCodeUrl = qrCodeUrl;
  367. }
  368. catch
  369. {
  370. if (response.ResponseMessage?.StatusCode == System.Net.HttpStatusCode.OK)
  371. {
  372. if (body.Contains("<p>抱歉!页面无法访问……</p>"))
  373. {
  374. throw new APIException("抱歉!页面无法访问……");
  375. }
  376. }
  377. throw;
  378. }
  379. }
  380. private async Task<TkDataDTO> alimamaParseAsync(string content, TkDataDTO result)
  381. {
  382. string t = $"{DateTime.Now.Convert2UnixTimestamp(true)}";
  383. Random random = new();
  384. double randomNumber = random.NextDouble();
  385. string randomString = randomNumber.ToString()[2..];
  386. string cna = _cookies.GetContentPart("cna=", ";");
  387. string firstFiveCharacters = cna[..Math.Min(5, cna.Length)];
  388. var variableMap = new
  389. {
  390. url = content,
  391. union_lens = $"b_pvid:a219t._portal_v2_tool_links_page_home_index_htm_{t}_{randomString}_{firstFiveCharacters}",
  392. lensScene = "PUB",
  393. spmB = "_portal_v2_tool_links_page_home_index_htm"
  394. }.Convert2Json(true).UrlEncode();
  395. variableMap = variableMap.Replace(" ", "%20");
  396. string url = "https://pub.alimama.com/openapi/param2/1/gateway.unionpub/xt.entry.json?" +
  397. $"t={t}&_tb_token_={_tb_token}&floorId={_floorId}&refpid={_refpid}&variableMap={variableMap}";
  398. var client = new WebClientUtility().SetContentType("application/json;charset=utf-8")
  399. .AddHeaders("X-Requested-With", "XMLHttpRequest")
  400. .AddHeaders("Cookie", _cookies);
  401. client.Proxy = _proxy;
  402. if (!string.IsNullOrEmpty(_user_agent)) client.UserAgent = _user_agent;
  403. client.Timeout = TimeSpan.FromMilliseconds(2000);
  404. #if DEBUG
  405. client.Proxy = null;
  406. client.Timeout = TimeSpan.FromMilliseconds(10000);
  407. #endif
  408. var response = client.Request(url);
  409. var body = string.Empty;
  410. try
  411. {
  412. if (!response.Successed)
  413. {
  414. result.channel = TkChannelEnum.tb;
  415. result.accountId = _accountId;
  416. result.accountName = _accountName;
  417. result.link_type = LinkTypeEnum.unknown;
  418. result.success = false;
  419. result.message = "fail";
  420. if (response.ResponseException != null)
  421. {
  422. new LoggerLibrary("api_error", "fail")
  423. .Info(response.ResponseException.Message, response.ResponseException.StackTrace)
  424. .Save();
  425. throw response.ResponseException;
  426. }
  427. return result;
  428. }
  429. body = response.Body();
  430. //{"code":601,"info":{"ok":false,"message":"nologin"}}
  431. JsonElement root = body.Convert2JsonElement();
  432. bool success = root.Read<bool>("success", false);
  433. string message = root.Read("message", string.Empty);
  434. string info_message = root.PathRead("info.message", string.Empty);
  435. if (!string.IsNullOrEmpty(info_message)) message = info_message;
  436. string taoToken = root.PathRead("data.taoToken", string.Empty);
  437. string shortLinkurl = root.PathRead("data.shortLinkurl", string.Empty);
  438. string couponLinkTaoToken = root.PathRead("data.couponLinkTaoToken", string.Empty);
  439. string couponShortLinkUrl = root.PathRead("data.couponShortLinkUrl", string.Empty);
  440. decimal couponAmount = root.PathRead<decimal>("data.couponAmount", 0);
  441. string couponEffectiveEndTime = root.PathRead("data.couponEffectiveEndTime", string.Empty);
  442. string couponEffectiveStartTime = root.PathRead("data.couponEffectiveStartTime", string.Empty);
  443. string itemId = root.PathRead("data.itemId", string.Empty);
  444. string itemName = root.PathRead("data.itemName", string.Empty);
  445. decimal promotionPrice = root.PathRead<decimal>("data.promotionPrice", 0);
  446. string sellerNickName = root.PathRead("data.sellerNickName", string.Empty);
  447. string shopTitle = root.PathRead("data.shopTitle", string.Empty);
  448. string pic = root.PathRead("data.pic", string.Empty);
  449. string qrCodeUrl = root.PathRead("data.qrCodeUrl", string.Empty);
  450. if (response.ResponseMessage != null)
  451. {
  452. switch (response.ResponseMessage.StatusCode)
  453. {
  454. case System.Net.HttpStatusCode.OK:
  455. {
  456. if (couponAmount > 0 && !string.IsNullOrEmpty(couponLinkTaoToken) && !string.IsNullOrEmpty(couponShortLinkUrl))
  457. {
  458. taoToken = couponLinkTaoToken;
  459. shortLinkurl = couponShortLinkUrl;
  460. }
  461. string shortLink = GetLink(taoToken);
  462. content = ReplaceUrls(content, shortLink);
  463. }
  464. break;
  465. case System.Net.HttpStatusCode.Found:
  466. string location = response.ResponseMessage.Headers.Location.OriginalString;
  467. if (!string.IsNullOrEmpty(location) && location.Contains("www.alimama.com/member/login.htm"))
  468. {
  469. success = false;
  470. message = "nologin";
  471. }
  472. break;
  473. default:
  474. {
  475. success = false;
  476. message = "other";
  477. }
  478. break;
  479. }
  480. }
  481. if (!success)
  482. {
  483. shortLinkurl = GetLink(content);
  484. switch (message)
  485. {
  486. case "该链接不支持转化,请更换链接尝试":
  487. case "网络错误":
  488. break;
  489. default:
  490. var _headers = response.ResponseMessage.Headers;
  491. var headers = "";
  492. foreach (var h in _headers)
  493. {
  494. foreach (var Value in h.Value)
  495. {
  496. headers += $"{h.Key}: {Value}\n";
  497. }
  498. }
  499. new LoggerLibrary("api_error", "fail")
  500. .Info(message, content)
  501. .Info(headers, body)
  502. .Save();
  503. break;
  504. }
  505. }
  506. if (success)
  507. {
  508. if (string.IsNullOrEmpty(itemName))
  509. {
  510. itemName = GetTitle(taoToken);
  511. }
  512. }
  513. else
  514. {
  515. itemName = GetTitle(content);
  516. }
  517. string deeplink_url = GetDeeplink(shortLinkurl);
  518. result.channel = TkChannelEnum.tb;
  519. result.accountId = _accountId;
  520. result.accountName = _accountName;
  521. if (success)
  522. {
  523. switch (result.link_type)
  524. {
  525. case LinkTypeEnum.profile:
  526. case LinkTypeEnum.goods:
  527. break;
  528. default:
  529. result.link_type = LinkTypeEnum.goods;
  530. break;
  531. }
  532. }
  533. result.success = success;
  534. result.message = message;
  535. result.content = content;
  536. result.couponAmount = couponAmount;
  537. result.couponEffectiveEndTime = couponEffectiveEndTime;
  538. result.couponEffectiveStartTime = couponEffectiveStartTime;
  539. result.taoToken = taoToken;
  540. result.shortLinkurl = shortLinkurl;
  541. result.deeplink_url = deeplink_url;
  542. result.itemId = itemId;
  543. result.itemName = itemName;
  544. result.promotionPrice = promotionPrice;
  545. result.sellerNickName = sellerNickName;
  546. result.shopTitle = shopTitle;
  547. result.pic = pic;
  548. result.qrCodeUrl = qrCodeUrl;
  549. }
  550. catch
  551. {
  552. if (response.ResponseMessage?.StatusCode == System.Net.HttpStatusCode.OK)
  553. {
  554. if (body.Contains("<p>抱歉!页面无法访问……</p>"))
  555. {
  556. throw new APIException("抱歉!页面无法访问……");
  557. }
  558. }
  559. throw;
  560. }
  561. return result;
  562. }
  563. }
  564. }