Beispiel #1
0
        public IEnumerable <ProductCategoryObject> GetProductOrCategory(ArgumentObject args)
        {
            if (Debug)
            {
                Console.WriteLine(args.ToString());
            }
            foreach (var block in GetHtmlNode(args).SelectNodes(BlockExp))
            {
                yield return(new ProductCategoryObject(
                                 PropertiesCategory.ToDictionary(x => x.Key, x => x.Value(block, args)), isCategory: true));

                foreach (var reference in block._SelectNodes(block.XPath + RefProductExp))
                {
                    var arguments = new ArgumentObject(url: Url + reference.Attributes["href"].Value, args: args.Args);
                    if (Debug)
                    {
                        Console.WriteLine(arguments.ToString());
                    }
                    var node = GetHtmlNode(arguments);
                    //File.WriteAllText("tmp.html", node.InnerHtml);
                    yield return(new ProductCategoryObject(
                                     SinglePropertiesProduct.ToDictionary(x => x.Key, x => x.Value(node, arguments)),
                                     PluralPropertiesProduct.ToDictionary(x => x.Key, x => x.Value(node, arguments))));
                }
            }
        }
Beispiel #2
0
 private ProductCategoryObject ParseProductObject(HtmlNode node, ArgumentObject args)
 {
     return(new ProductCategoryObject(
                singleProperties: SinglePropertiesProduct.ToDictionary(x => x.Key, x => x.Value(node, args)),
                pluralProperties: PluralPropertiesProduct?.ToDictionary(x => x.Key, x => x.Value(node, args))
                ));
 }