public static decimal TaobaoPromoMobilePrice(string onlineKey, List <Sku> skuList) { string.Format("http://item.taobao.com/item.htm?id={0}", new object[] { onlineKey }); string text = string.Format("http://hws.m.taobao.com/cache/wdetail/5.0/?id={0}", new object[] { onlineKey }); string text2 = GetItemPromoPrice.Invoke(text, text, Encoding.GetEncoding("utf-8")); if (!string.IsNullOrEmpty(text2.Trim())) { return(GetItemPromoPrice.GetDiscountPrice(text2, skuList)); } return(0m); }
public static Dictionary <string, string> GetPaipaiItemPromoPrice(string onlineKey) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); string text = string.Empty; string url = "http://auction1.paipai.com/" + onlineKey; string responseContent = GetItemPromoPrice.GetResponseContent(url, Encoding.GetEncoding("gb2312")); if (!string.IsNullOrEmpty(responseContent)) { Regex regex = new Regex("(?is)<input[^>]*?id=\"stockStringNew\"\\s*?value=\"(?<value>.*?)\"", RegexOptions.IgnoreCase); Match match = regex.Match(responseContent); if (match != null && match.Success) { text = match.Groups["value"].Value; } } if (!string.IsNullOrEmpty(text)) { string[] array = text.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (array != null && array.Length > 0) { string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string text2 = array2[i]; string[] array3 = text2.Split(new char[] { ',' }); if (array3 != null && array3.Length == 5) { string key = array3[4]; string value = array3[1]; dictionary[key] = value; } } } } return(dictionary); }
public static GetItemPromoPrice.TaobaoPromoPriceEntity GetTaobaoItemPromoPrice(string onlineKey) { GetItemPromoPrice.TaobaoPromoPriceEntity result = null; string url = "http://a.m.taobao.com/ajax/sku.do?item_id=" + onlineKey; string responseContent = GetItemPromoPrice.GetResponseContent(url, Encoding.GetEncoding("Utf-8")); try { if (!string.IsNullOrEmpty(responseContent)) { result = JsonConvert.DeserializeObject <GetItemPromoPrice.TaobaoPromoPriceEntity>(responseContent); } } catch (Exception ex) { Log.WriteLog(ex); } return(result); }
public static GetItemPromoPrice.TaobaoPromoPriceEntity GetTaobaoItemPromoPrice2(string onlineKey) { GetItemPromoPrice.TaobaoPromoPriceEntity taobaoPromoPriceEntity = new GetItemPromoPrice.TaobaoPromoPriceEntity(); string format = "http://detailskip.taobao.com/json/sib.htm?itemId={0}&u=1&p=1&chnl=pc"; string format2 = "http://item.taobao.com/item.htm?id={0}"; string strUrl = string.Format(format, onlineKey); string refreUrl = string.Format(format2, onlineKey); string text = GetItemPromoPrice.Invoke(strUrl, refreUrl, Encoding.GetEncoding("gb2312")); if (!string.IsNullOrEmpty(text.Trim())) { Regex regex = new Regex("(?is)g_config.PromoData=(.*?}\\s*?);"); Match match = regex.Match(text.Trim()); string value = string.Empty; if (match.Success) { value = match.Groups[1].Value; } if (!string.IsNullOrEmpty(value)) { try { Dictionary <string, List <GetItemPromoPrice.PromoEntity> > dictionary = JsonConvert.DeserializeObject <Dictionary <string, List <GetItemPromoPrice.PromoEntity> > >(value); if (dictionary != null && dictionary.Count >= 0) { foreach (KeyValuePair <string, List <GetItemPromoPrice.PromoEntity> > current in dictionary) { if (current.Value != null && current.Value.Count > 0) { string key = current.Key.Trim(new char[] { ';' }); decimal num = 0m; foreach (GetItemPromoPrice.PromoEntity current2 in current.Value) { if (!string.IsNullOrEmpty(current2.Price)) { if (num == 0m) { num = DataConvert.ToDecimal(current2.Price); } else { if (num > DataConvert.ToDecimal(current2.Price)) { num = DataConvert.ToDecimal(current2.Price); } } } } if (num != 0m) { if (taobaoPromoPriceEntity.availSKUs == null) { taobaoPromoPriceEntity.availSKUs = new Dictionary <string, GetItemPromoPrice.AvailSKU>(); } taobaoPromoPriceEntity.availSKUs[key] = new GetItemPromoPrice.AvailSKU(); taobaoPromoPriceEntity.availSKUs[key].promoPrice = DataConvert.ToString(num); } } } } } catch (Exception ex) { Log.WriteLog(ex); } } } return(taobaoPromoPriceEntity); }