diff --git a/Assistant/SkuAssist.cs b/Assistant/SkuAssist.cs index 9d90394..dc36dc0 100644 --- a/Assistant/SkuAssist.cs +++ b/Assistant/SkuAssist.cs @@ -3,6 +3,7 @@ using AngleSharp.Dom; using System.Linq; using System.Net; using System.Net.Http; +using System.Text.RegularExpressions; using System.Threading.Tasks; namespace Rehau.Sku.Assist @@ -11,7 +12,7 @@ namespace Rehau.Sku.Assist { public async static Task GetContent(string request, HttpClient httpClient) { - string uri = "https://shop-rehau.ru/catalogsearch/result/?q=" + request; + string uri = "https://shop-rehau.ru/catalogsearch/result/?q=" + request._CleanRequest(); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; return await httpClient.GetStringAsync(uri); @@ -31,9 +32,13 @@ namespace Rehau.Sku.Assist .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(); } + + private static string _CleanRequest(this string input) + { + return input.Replace("+", " plus "); + } } } diff --git a/Functions.cs b/Functions.cs index 9112822..6792195 100644 --- a/Functions.cs +++ b/Functions.cs @@ -15,7 +15,7 @@ namespace Rehau.Sku.Assist Task contentTask = Task.Run(() => SkuAssist.GetContent(request, httpClient)); Task documentTask = await contentTask.ContinueWith(content => SkuAssist.GetDocument(content)); IProduct product = await documentTask.ContinueWith(doc => SkuAssist.GetProductFromDocument(doc.Result)); - return product.ToString(); + return product == null ? ExcelError.ExcelErrorNull.ToString() : product.ToString(); } } } \ No newline at end of file diff --git a/Rehau.Sku.Assist-AddIn-packed.xll b/Rehau.Sku.Assist-AddIn-packed.xll new file mode 100644 index 0000000..aea355f Binary files /dev/null and b/Rehau.Sku.Assist-AddIn-packed.xll differ diff --git a/Rehau.Sku.Assist.csproj b/Rehau.Sku.Assist.csproj index 144c4f6..86fe220 100644 --- a/Rehau.Sku.Assist.csproj +++ b/Rehau.Sku.Assist.csproj @@ -36,6 +36,7 @@ packages\AngleSharp.0.16.1\lib\net472\AngleSharp.dll + True packages\ExcelDna.Integration.1.5.0\lib\net452\ExcelDna.Integration.dll @@ -43,6 +44,7 @@ packages\ExcelDna.Registration.1.5.0\lib\net452\ExcelDna.Registration.dll + True