//разбор полученых данных и инициализация объекта WishSku public WishSku parseStringToSku(string skuhtml) { skuhtml = skuhtml.Replace("\n", ""); var sku = new WishSku(); //var s = "<h1 class=\"detail-title\" itemprop=\"name\">(.*?)<\\/h1>"; var patternName = "<span class=\"detail-tabs-i-title-inner\">(.*?)<\\/span>"; var patternPrice = "<span itemprop=\"price\"><meta itemprop=\"priceCurrency\" content=\"UAH\">(.*?)<\\/span>"; var patternCode = "<span class=\"detail-code-i block\" name=\"goods_code\">(.*?)<\\/span>"; string patternBaseImage = "<img src=\"(.*?)\" *?>"; string patternDescription = "<div class=\"detail-description\" itemprop=\"description\">(.*?)</div>"; string patternCurrency = "<span class=\"detail-price-uah-sign\"> (.*?)</span>"; var str = ""; var matches = Regex.Matches(skuhtml, patternName); if (matches.Count > 0 && matches[0].Groups.Count>0) { sku.name = matches[0].Groups[1].ToString().Trim().Replace("{", "").Replace("}", ""); } matches = Regex.Matches(skuhtml, patternPrice); if (matches.Count > 0 && matches[0].Groups.Count > 0) { sku.price = matches[0].Groups[1].ToString().Replace("{", "").Replace("}", "").Replace(" ", ""); } matches = Regex.Matches(skuhtml, patternCode); if (matches.Count > 0 && matches[0].Groups.Count > 0) { sku.code = matches[0].Groups[1].ToString().Trim().Replace("{", "").Replace("}", ""); } matches = Regex.Matches(skuhtml, patternDescription); if (matches.Count > 0 && matches[0].Groups.Count > 0) { sku.description = matches[0].Groups[1].ToString().Trim().Replace("{", "").Replace("}", ""); } matches = Regex.Matches(skuhtml, patternCurrency); if (matches.Count > 0 && matches[0].Groups.Count > 0) { sku.currency = matches[0].Groups[1].ToString().Trim().Replace("{", "").Replace("}", ""); } matches = Regex.Matches(skuhtml, patternBaseImage); for (int i = 0; i < matches.Count; i++) { if (matches[i].Groups[0].ToString().Contains("id=\"base_image\"")) { if (matches[i].Groups[1].ToString().Length > matches[i].Groups[1].ToString().IndexOf("\"")) { sku.baseImage = matches[i].Groups[1].ToString().Remove(matches[i].Groups[1].ToString().IndexOf("\"")); } } } return sku; }
public PaymentModel(WishSku sku) { this.sku = sku; }
public PaymentModel() { sku=new WishSku(); }