diff options
author | Sergey Chebotar <s.chebotar@gmail.com> | 2022-12-19 08:37:26 +0300 |
---|---|---|
committer | Sergey Chebotar <s.chebotar@gmail.com> | 2022-12-19 08:37:26 +0300 |
commit | a7e5a500e1c78ebc556f09831402838903fa4b79 (patch) | |
tree | 6a974a96e2d9012fe05d22eb2cd5cdd0206589ba /src/Assistant/ParseUtil.cs | |
parent | e7d590bd2387f656d0b12db6fbe09abf647623bd (diff) | |
parent | b66cc8fdce099daaf42f90ca8ae488bebd47d125 (diff) |
Merge branch 'dev'
Diffstat (limited to 'src/Assistant/ParseUtil.cs')
-rw-r--r-- | src/Assistant/ParseUtil.cs | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/src/Assistant/ParseUtil.cs b/src/Assistant/ParseUtil.cs deleted file mode 100644 index a93c658..0000000 --- a/src/Assistant/ParseUtil.cs +++ /dev/null @@ -1,44 +0,0 @@ -using AngleSharp; -using AngleSharp.Dom; -using Newtonsoft.Json; -using System.Linq; -using System.Threading.Tasks; - -namespace RehauSku.Assistant -{ - static class ParseUtil - { - public async static Task<IDocument> ContentToDocAsync(string content) - { - IConfiguration config = Configuration.Default; - IBrowsingContext context = BrowsingContext.New(config); - - return await context.OpenAsync(req => req.Content(content)); - } - - public static IProduct GetProduct(IDocument document) - { - string script = document - .Scripts - .Where(s => s.InnerHtml.Contains("dataLayer")) - .FirstOrDefault() - .InnerHtml; - - string json = script - .Substring(script.IndexOf("push(") + 5) - .TrimEnd(new[] { ')', ';', '\n', ' ' }); - - if (!json.Contains("impressions")) - return null; - - StoreResponce storeResponse = JsonConvert.DeserializeObject<StoreResponce>(json); - IProduct product = storeResponse - .Ecommerce - .Impressions - .Where(p => p.Id.IsRehauSku()) - .FirstOrDefault(); - - return product; - } - } -}
\ No newline at end of file |