Beispiel #1
0
        private static void _getElementByUrl(Element el, string Url, ref List <Element> result)
        {
            var link = DomUrlService.GetLinkOrSrc(el);

            if (!string.IsNullOrWhiteSpace(link) && link.Trim().ToLower() == Url)
            {
                result.Add(el);
            }

            foreach (var item in el.childNodes.item)
            {
                if (item.nodeType == enumNodeType.ELEMENT)
                {
                    var subel = item as Element;
                    _getElementByUrl(subel, Url, ref result);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// get all image links
        /// </summary>
        /// <param name="dom"></param>
        /// <returns></returns>
        public static List <string> GetImages(Document dom)
        {
            List <string> imgurls = new List <string>();

            foreach (var item in dom.images.item)
            {
                string itemsrc = DomUrlService.GetLinkOrSrc(item);

                if (!string.IsNullOrEmpty(itemsrc))
                {
                    if (!Kooboo.Lib.Utilities.DataUriService.isDataUri(itemsrc))
                    {
                        imgurls.Add(itemsrc);
                    }
                }
            }
            return(imgurls);
        }
Beispiel #3
0
        /// <summary>
        /// Get all external style urls
        /// </summary>
        /// <param name="dom"></param>
        /// <returns></returns>
        public static List <string> GetReferenceStyles(Document dom)
        {
            List <string> urlList = new List <string>();

            if (dom != null)
            {
                HTMLCollection styletags = dom.getElementsByTagName("link");

                foreach (var item in styletags.item)
                {
                    if (item.hasAttribute("rel") && item.getAttribute("rel").ToLower().Contains("stylesheet"))
                    {
                        string itemurl = DomUrlService.GetLinkOrSrc(item);

                        if (!string.IsNullOrEmpty(itemurl))
                        {
                            urlList.Add(itemurl);
                        }
                    }
                }
            }
            return(urlList);
        }