using HtmlAgilityPack; using System.Web; namespace JSMR.Infrastructure.Scanning; public static class ScannerUtilities { public static List GetStringListFromNodes(List nodes) { return nodes .Where(node => string.IsNullOrEmpty(node.InnerHtml) == false) .Select(node => HttpUtility.HtmlDecode(node.InnerHtml)) .ToList(); } public static string GetDecodedText(HtmlNode node) { if (node == null) return string.Empty; if (string.IsNullOrWhiteSpace(node.InnerHtml)) return string.Empty; return HttpUtility.HtmlDecode(node.InnerHtml.Replace("\n", "")).Trim(); } public static string GetTextBetween(string text, string startText, string endText) { int startIndex = text.IndexOf(startText) + startText.Length; int endIndex = text.IndexOf(endText); int length = endIndex - startIndex; if (length <= 0) return ""; return text.Substring(startIndex, length); } public static string GetImageSource(HtmlNode imageNode) { string imageSource = imageNode.GetAttributeValue("src", ""); if (string.IsNullOrEmpty(imageSource)) imageSource = imageNode.GetAttributeValue("data-src", ""); return imageSource; } }