diff options
author | Serghei Cebotari <51533848+schebotar@users.noreply.github.com> | 2021-11-29 16:36:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-29 16:36:58 +0300 |
commit | 15995027bfbc535e4b9ffa159607caaffdecc478 (patch) | |
tree | 06c5c8ab66889c6e3dac0819280ef1b1bffcf3ac /Assistant | |
parent | 0fe8e038af7f33eae824bba263e7c54dea829679 (diff) | |
parent | e9ec1df01b752b423b66cb30dc2025a396f769f5 (diff) |
Merge pull request #1 from schebotar/experimental
Experimental
Diffstat (limited to 'Assistant')
-rw-r--r-- | Assistant/SkuAssist.cs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Assistant/SkuAssist.cs b/Assistant/SkuAssist.cs index 9eb3328..9d90394 100644 --- a/Assistant/SkuAssist.cs +++ b/Assistant/SkuAssist.cs @@ -1,4 +1,5 @@ using AngleSharp; +using AngleSharp.Dom; using System.Linq; using System.Net; using System.Net.Http; @@ -8,22 +9,23 @@ namespace Rehau.Sku.Assist { static class SkuAssist { - public async static Task<AngleSharp.Dom.IDocument> GetDocumentAsync(string request, HttpClient httpClient) + 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; - HttpResponseMessage response = await httpClient.GetAsync(uri); - response.EnsureSuccessStatusCode(); + return await httpClient.GetStringAsync(uri); + } + + public async static Task<IDocument> GetDocument(Task<string> source) + { IConfiguration config = Configuration.Default; IBrowsingContext context = BrowsingContext.New(config); - string source = await response.Content.ReadAsStringAsync(); - return await context.OpenAsync(req => req.Content(source)); + return await context.OpenAsync(req => req.Content(source.Result)); } - public static IProduct GetProductFromDocument(AngleSharp.Dom.IDocument document) + public static IProduct GetProductFromDocument(IDocument document) { return document .All |