示例#1
0
        public List <ParsoProduct> ParseProductList(ParsoCatalog catalog)
        {
            var listOfProducts = GetDocument(catalog.Url).CssSelect(@"div.product");
            var productList    = new List <ParsoProduct>();

            foreach (var product in listOfProducts)
            {
                ParsoProduct tmp = new ParsoProduct();

                tmp.ProductId          = ParserUtil.GetIntAttribute(product, "id");
                tmp.OldPrice           = ParserUtil.GetDecimalValueOfElement(product, @"span.oldprice", @"([\d,]+)");
                tmp.Price              = ParserUtil.GetDecimalValueOfElement(product, @"span.price", @"([\d,]+)");
                tmp.ProductName        = ParserUtil.GetStringValueOfElement(product, "a.title");
                tmp.PictureUrl         = ParserUtil.GetStringAttribute(product, "src", @"img.lazyload");
                tmp.ProductDetailUrl   = ParserUtil.GetStringAttribute(product, "href", @"a.title");
                tmp.CatalogId          = catalog.Id;
                tmp.ProductDescription = Parse("https://www.carrefoursa.com" + tmp.ProductDetailUrl, @"div.tab-pane.active");

                productList.Add(tmp);

                SaveProduct(tmp);
            }
            ParseFinishedEventArgs e = new ParseFinishedEventArgs(catalog.Id);

            OnParseFinished(e);

            return(productList);
        }
示例#2
0
 protected virtual void OnParseFinished(ParseFinishedEventArgs e)
 {
     if (ParseFinished != null)
     {
         ParseFinished(this, e);
     }
 }
示例#3
0
        public List <ParsoProduct> ParseProductList(ParsoCatalog catalog)
        {
            JSONParser <MigrosProduct> migrosProductParser = new JSONParser <MigrosProduct>();
            var listOfProducts = migrosProductParser.ParseDetail(catalog.Url);
            var productList    = new List <ParsoProduct>();

            foreach (var product in listOfProducts.aaData)
            {
                if (String.IsNullOrWhiteSpace(product.nm))
                {
                    continue;
                }

                ParsoProduct tmp = new ParsoProduct();

                tmp.ProductId        = Convert.ToInt64(product.psi);
                tmp.OldPrice         = Convert.ToDecimal(product.mprc);
                tmp.Price            = Convert.ToDecimal(product.prc);
                tmp.ProductName      = product.nm;
                tmp.PictureUrl       = product.img;
                tmp.ProductDetailUrl = product.uri;
                tmp.CatalogId        = catalog.Id;

                HDocument workload = GetDocument("https://www.sanalmarket.com.tr" + tmp.ProductDetailUrl);

                tmp.ProductDescription = Parse(workload, @"#groupPromo", false);
                tmp.DiscountDetail     = Parse(workload, @"div.udIndirimText", false);

                productList.Add(tmp);

                SaveProduct(tmp);
            }

            ParseFinishedEventArgs e = new ParseFinishedEventArgs(catalog.Id);

            OnParseFinished(e);

            return(productList);
        }