diff options
-rw-r--r-- | Assistant/SkuAssist.cs | 67 | ||||
-rw-r--r-- | Rehau.Sku.Assist.csproj | 18 | ||||
-rw-r--r-- | app.config | 12 | ||||
-rw-r--r-- | packages.config | 6 |
4 files changed, 63 insertions, 40 deletions
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<string> 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<string> 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<AngleSharp.Dom.IDocument> GetDocument(string source) -// { -// IConfiguration config = Configuration.Default; -// IBrowsingContext context = BrowsingContext.New(config); + public async static Task<IDocument> 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 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> + <Reference Include="AngleSharp, Version=0.16.1.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea, processorArchitecture=MSIL"> + <HintPath>packages\AngleSharp.0.16.1\lib\net472\AngleSharp.dll</HintPath> + </Reference> <Reference Include="ExcelDna.Integration, Version=1.1.0.0, Culture=neutral, PublicKeyToken=f225e9659857edbe, processorArchitecture=MSIL"> <HintPath>packages\ExcelDna.Integration.1.5.0\lib\net452\ExcelDna.Integration.dll</HintPath> <Private>False</Private> @@ -42,14 +45,29 @@ <HintPath>packages\ExcelDna.Registration.1.5.0\lib\net452\ExcelDna.Registration.dll</HintPath> </Reference> <Reference Include="System" /> + <Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath> + </Reference> <Reference Include="System.Configuration" /> <Reference Include="System.Core" /> <Reference Include="System.Data.OracleClient" /> + <Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath> + </Reference> <Reference Include="System.Net" /> <Reference Include="System.Numerics" /> + <Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath> + </Reference> <Reference Include="System.Runtime.Caching" /> + <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath> + </Reference> <Reference Include="System.Security" /> <Reference Include="System.ServiceProcess" /> + <Reference Include="System.Text.Encoding.CodePages, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>packages\System.Text.Encoding.CodePages.6.0.0\lib\net461\System.Text.Encoding.CodePages.dll</HintPath> + </Reference> <Reference Include="System.Transactions" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> @@ -1,15 +1,15 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> - <assemblyIdentity name="System.Text.Encoding.CodePages" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> - <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/> + <assemblyIdentity name="System.Text.Encoding.CodePages" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> </dependentAssembly> <dependentAssembly> - <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> - <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/> + <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> -<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration> +<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /></startup></configuration> diff --git a/packages.config b/packages.config index b143486..cc383d8 100644 --- a/packages.config +++ b/packages.config @@ -1,6 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> <packages> + <package id="AngleSharp" version="0.16.1" targetFramework="net48" /> <package id="ExcelDna.AddIn" version="1.5.0" targetFramework="net480" /> <package id="ExcelDna.Integration" version="1.5.0" targetFramework="net480" /> <package id="ExcelDna.Registration" version="1.5.0" targetFramework="net480" /> + <package id="System.Buffers" version="4.5.1" targetFramework="net48" /> + <package id="System.Memory" version="4.5.4" targetFramework="net48" /> + <package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" /> + <package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net48" /> + <package id="System.Text.Encoding.CodePages" version="6.0.0" targetFramework="net48" /> </packages>
\ No newline at end of file |