diff --git a/Assistant/SkuAssist.cs b/Assistant/SkuAssist.cs index d390a1d..a9de2e1 100644 --- a/Assistant/SkuAssist.cs +++ b/Assistant/SkuAssist.cs @@ -1,41 +1,40 @@ -//using System; -//using AngleSharp; -//using AngleSharp.Dom; -//using System.Linq; -//using System.Net; -//using System.Net.Http; -//using System.Threading.Tasks; +using AngleSharp; +using AngleSharp.Dom; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading.Tasks; -//namespace Rehau.Sku.Assist -//{ -// static class SkuAssist -// { -// public async static Task GetContent(string request, HttpClient httpClient) -// { -// string uri = "https://shop-rehau.ru/catalogsearch/result/?q=" + request; -// ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; +namespace Rehau.Sku.Assist +{ + static class SkuAssist + { + public async static Task GetContent(string request, HttpClient httpClient) + { + string uri = "https://shop-rehau.ru/catalogsearch/result/?q=" + request; + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; -// return await httpClient.GetStringAsync(uri); -// } + return await httpClient.GetStringAsync(uri); + } -// public async static Task GetDocument(string source) -// { -// IConfiguration config = Configuration.Default; -// IBrowsingContext context = BrowsingContext.New(config); + public async static Task GetDocument(string source) + { + IConfiguration config = Configuration.Default; + IBrowsingContext context = BrowsingContext.New(config); -// return await context.OpenAsync(req => req.Content(source)); -// } + return await context.OpenAsync(req => req.Content(source)); + } -// public static IProduct GetProductFromDocument(IDocument document) -// { -// return document -// .All -// .Where(e => e.ClassName == "product-item__desc-top") -// .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(); -// } -// } -//} + public static IProduct GetProductFromDocument(IDocument document) + { + return document + .All + .Where(e => e.ClassName == "product-item__desc-top") + .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(); + } + } +} diff --git a/Rehau.Sku.Assist.csproj b/Rehau.Sku.Assist.csproj index a489459..144c4f6 100644 --- a/Rehau.Sku.Assist.csproj +++ b/Rehau.Sku.Assist.csproj @@ -34,6 +34,9 @@ 4 + + packages\AngleSharp.0.16.1\lib\net472\AngleSharp.dll + packages\ExcelDna.Integration.1.5.0\lib\net452\ExcelDna.Integration.dll False @@ -42,14 +45,29 @@ packages\ExcelDna.Registration.1.5.0\lib\net452\ExcelDna.Registration.dll + + packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + packages\System.Memory.4.5.4\lib\net461\System.Memory.dll + + + packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + packages\System.Text.Encoding.CodePages.6.0.0\lib\net461\System.Text.Encoding.CodePages.dll + diff --git a/app.config b/app.config index 59eda38..3f5b7b7 100644 --- a/app.config +++ b/app.config @@ -1,15 +1,15 @@ - + - - + + - - + + - + diff --git a/packages.config b/packages.config index b143486..cc383d8 100644 --- a/packages.config +++ b/packages.config @@ -1,6 +1,12 @@  + + + + + + \ No newline at end of file