From 0fe8e038af7f33eae824bba263e7c54dea829679 Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Mon, 29 Nov 2021 11:26:25 +0300 Subject: =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20?= =?UTF-8?q?=D0=BA=D1=8D=D1=88=D0=B8=D0=BD=D0=B3=20=D1=80=D0=B5=D0=B7=D1=83?= =?UTF-8?q?=D0=BB=D1=8C=D1=82=D0=B0=D1=82=D0=BE=D0=B2=20=D0=B7=D0=B0=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D1=81=D0=B0,=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80?= =?UTF-8?q?=D1=84=D0=B5=D0=B9=D1=81=20IProduct?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assistant/SkuAssist.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'Assistant/SkuAssist.cs') diff --git a/Assistant/SkuAssist.cs b/Assistant/SkuAssist.cs index 1167274..9eb3328 100644 --- a/Assistant/SkuAssist.cs +++ b/Assistant/SkuAssist.cs @@ -1,8 +1,8 @@ -using System.Net.Http; -using System.Threading.Tasks; -using AngleSharp; +using AngleSharp; using System.Linq; using System.Net; +using System.Net.Http; +using System.Threading.Tasks; namespace Rehau.Sku.Assist { @@ -23,16 +23,14 @@ namespace Rehau.Sku.Assist return await context.OpenAsync(req => req.Content(source)); } - public static string GetResultFromDocument(AngleSharp.Dom.IDocument document) + public static IProduct GetProductFromDocument(AngleSharp.Dom.IDocument document) { - var result = document + return document .All .Where(e => e.ClassName == "product-item__desc-top") - .Select(e => new { sku = e.Children[0].TextContent, title = e.Children[1].TextContent.Trim(new[] { '\n', ' ' }) }) - .Where(t => !t.sku.Any(c => char.IsLetter(c))) + .Select(e => new Product(e.Children[0].TextContent, e.Children[1].TextContent.Trim(new[] { '\n', ' ' }))) + // .Where(product => !product.Sku.Any(c => char.IsLetter(c))) .FirstOrDefault(); - - return result == null ? "Не найдено" : $"{result.title} ({result.sku})"; } } } -- cgit v1.2.3